@@ -20,6 +20,7 @@ func TestIsValid(t *testing.T) {
20
20
"go0.0" , // ??
21
21
"go1" ,
22
22
"go2" ,
23
+ "go1.20.0-bigcorp" ,
23
24
} {
24
25
if ! versions .IsValid (x ) {
25
26
t .Errorf ("expected versions.IsValid(%q) to hold" , x )
@@ -40,6 +41,7 @@ func TestIsValid(t *testing.T) {
40
41
"go1.21.2_2" ,
41
42
"go1.21rc_2" ,
42
43
"go1.21rc2_" ,
44
+ "go1.600+auto" ,
43
45
} {
44
46
if versions .IsValid (x ) {
45
47
t .Errorf ("expected versions.IsValid(%q) to not hold" , x )
@@ -52,6 +54,7 @@ func TestVersionComparisons(t *testing.T) {
52
54
x , y string
53
55
want int
54
56
}{
57
+ // All comparisons of go2, go1.21.2, go1.21rc2, go1.21rc2, go1, go0.0, "", bad
55
58
{"go2" , "go2" , 0 },
56
59
{"go2" , "go1.21.2" , + 1 },
57
60
{"go2" , "go1.21rc2" , + 1 },
@@ -97,6 +100,11 @@ func TestVersionComparisons(t *testing.T) {
97
100
{"" , "" , 0 },
98
101
{"" , "bad" , 0 },
99
102
{"bad" , "bad" , 0 },
103
+ // Other tests.
104
+ {"go1.20" , "go1.20.0-bigcorp" , 0 },
105
+ {"go1.21" , "go1.21.0-bigcorp" , - 1 }, // Starting in Go 1.21, patch missing is different from explicit .0.
106
+ {"go1.21.0" , "go1.21.0-bigcorp" , 0 }, // Starting in Go 1.21, patch missing is different from explicit .0.
107
+ {"go1.19rc1" , "go1.19" , - 1 },
100
108
} {
101
109
got := versions .Compare (item .x , item .y )
102
110
if got != item .want {
0 commit comments