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)
|
|
}
|
|
}
|
|
}
|