tcp punch
This commit is contained in:
@@ -49,6 +49,11 @@ func assertCompareVersion(t *testing.T, v1 string, v2 string, result int) {
|
||||
t.Errorf("compare version %s %s fail\n", v1, v2)
|
||||
}
|
||||
}
|
||||
func assertParseMajorVer(t *testing.T, v string, result int) {
|
||||
if parseMajorVer(v) != result {
|
||||
t.Errorf("ParseMajorVer %s fail\n", v)
|
||||
}
|
||||
}
|
||||
func TestCompareVersion(t *testing.T) {
|
||||
// test =
|
||||
assertCompareVersion(t, "0.98.0", "0.98.0", EQUAL)
|
||||
@@ -69,3 +74,23 @@ func TestCompareVersion(t *testing.T) {
|
||||
assertCompareVersion(t, "", "1.5.0", LESS)
|
||||
|
||||
}
|
||||
|
||||
func TestParseMajorVer(t *testing.T) {
|
||||
|
||||
assertParseMajorVer(t, "0.98.0", 0)
|
||||
assertParseMajorVer(t, "0.98", 0)
|
||||
assertParseMajorVer(t, "1.4.0", 1)
|
||||
assertParseMajorVer(t, "1.5.0", 1)
|
||||
|
||||
assertParseMajorVer(t, "0.98.0.22345", 0)
|
||||
assertParseMajorVer(t, "1.98.0.12345", 1)
|
||||
assertParseMajorVer(t, "10.98.0.12345", 10)
|
||||
assertParseMajorVer(t, "1.4.0", 1)
|
||||
assertParseMajorVer(t, "1.4", 1)
|
||||
assertParseMajorVer(t, "1", 1)
|
||||
assertParseMajorVer(t, "2", 2)
|
||||
assertParseMajorVer(t, "3", 3)
|
||||
assertParseMajorVer(t, "2.1.0", 2)
|
||||
assertParseMajorVer(t, "3.0.0", 3)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user