add version pkg
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
parent
f8923d8060
commit
98f0a748a7
2 changed files with 77 additions and 0 deletions
25
version/version_test.go
Normal file
25
version/version_test.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func assertVersion(t *testing.T, a, b string, result int) {
|
||||
if r := Version(a).compareTo(b); r != result {
|
||||
t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompareVersion(t *testing.T) {
|
||||
assertVersion(t, "1.12", "1.12", 0)
|
||||
assertVersion(t, "1.05.00.0156", "1.0.221.9289", 1)
|
||||
assertVersion(t, "1", "1.0.1", -1)
|
||||
assertVersion(t, "1.0.1", "1", 1)
|
||||
assertVersion(t, "1.0.1", "1.0.2", -1)
|
||||
assertVersion(t, "1.0.2", "1.0.3", -1)
|
||||
assertVersion(t, "1.0.3", "1.1", -1)
|
||||
assertVersion(t, "1.1", "1.1.1", -1)
|
||||
assertVersion(t, "1.1.1", "1.1.2", -1)
|
||||
assertVersion(t, "1.1.2", "1.2", -1)
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue