2022-07-29 06:29:21 +02:00
|
|
|
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
|
|
|
// All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
2022-09-05 17:46:38 +02:00
|
|
|
package archive
|
2022-03-14 10:18:56 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNodeList(t *testing.T) {
|
|
|
|
nl, err := ParseNodeList("hallo,wel123t,emmy[01-99],fritz[005-500],woody[100-200]")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if nl.Contains("hello") || nl.Contains("woody") {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
if nl.Contains("fritz1") || nl.Contains("fritz9") || nl.Contains("fritz004") || nl.Contains("woody201") {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nl.Contains("hallo") || !nl.Contains("wel123t") {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nl.Contains("emmy01") || !nl.Contains("emmy42") || !nl.Contains("emmy99") {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nl.Contains("woody100") || !nl.Contains("woody199") {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
2022-05-16 09:10:55 +02:00
|
|
|
|
|
|
|
func TestNodeListCommasInBrackets(t *testing.T) {
|
|
|
|
nl, err := ParseNodeList("a[1000-2000,2010-2090,3000-5000]")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if nl.Contains("hello") || nl.Contains("woody") {
|
|
|
|
t.Fatal("1")
|
|
|
|
}
|
|
|
|
|
|
|
|
if nl.Contains("a0") || nl.Contains("a0000") || nl.Contains("a5001") || nl.Contains("a2005") {
|
|
|
|
t.Fatal("2")
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nl.Contains("a1001") || !nl.Contains("a2000") {
|
|
|
|
t.Fatal("3")
|
|
|
|
}
|
|
|
|
|
|
|
|
if !nl.Contains("a2042") || !nl.Contains("a4321") || !nl.Contains("a3000") {
|
|
|
|
t.Fatal("4")
|
|
|
|
}
|
|
|
|
}
|