mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
8dad771daa
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
25 lines
677 B
Go
25 lines
677 B
Go
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)
|
|
|
|
}
|