Arch Linux helpers and parsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

27 lines
504 B

package version
import "testing"
func TestVersion(t *testing.T) {
var tests = []struct {
A, B string
Cmp int
}{
{"", "", 0},
{"a", "a", 0},
{"a", "aa", -1},
{"b", "ab", 1},
{"1:1", "1", 1},
{"0:1", "1", 0},
{"1:0.1.2-3", "1.2.3-4", 1},
{"1.2.3-4", "1.2.3-3", 1},
{"", "a", -1},
{"a", "", 1},
}
for _, test := range tests {
c := CompareString(test.A, test.B)
if c != test.Cmp {
t.Fatalf(`expected %q <> %q to return %d, got %d`, test.A, test.B, test.Cmp, c)
}
}
}