-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
54 lines (49 loc) · 1019 Bytes
/
parser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package semver_test
import (
"testing"
. "github.com/kmcsr/semver"
)
func TestParseComparator(t *testing.T){
type T struct {
S string
E bool
}
data := []T{
{"1.2.3", false},
{"=1.2.3", false},
{"==1.2.3", false},
{"== 1.2.3", false},
{"!1.2.3", false},
{"!=1.2.3", false},
{"<1.2.3", false},
{">1.2.3", false},
{"<=1.2.3", false},
{">=1.2.3", false},
{"~1.2.3", false},
{"^1.2.3", false},
{"1.2.3 ||", true},
{"1.2.3 || ", true},
{"1.2.3 || 2", false},
{"1.2.3 || || 2", true},
{"|| 1.2.3", true},
{"* || 1.2.3", false},
{"v1.2.3", false},
{"v1", false},
{"v", false},
{"v*", false},
{"vx", false},
{"1.2.3 || v4.5.6", false},
{"1.2.3 || v4", false},
{"1.2.3 || v", false},
}
for _, d := range data {
v, e := ParseComparatorSet(d.S)
if d.E {
if e == nil {
t.Errorf("Expect error when parsing ComparatorSet %q, but got %#v", d.S, v)
}
}else if e != nil {
t.Errorf("Unexpect error when parsing ComparatorSet %q: %v", d.S, e)
}
}
}