package main

import "testing"

func TestParseAndCompareVersion(t *testing.T) {
	if _, ok := parseVersion("1.2.3"); !ok {
		t.Fatal("parseVersion() unexpectedly failed")
	}
	for _, v := range []string{"1.2", "v1.2.3", "1.2.x", "1.2.3.4"} {
		if _, ok := parseVersion(v); ok {
			t.Fatalf("parseVersion(%q) unexpectedly succeeded", v)
		}
	}
	if compareVersion("1.10.0", "1.9.9") <= 0 || compareVersion("1.0.0", "1.0.0") != 0 || compareVersion("1.0.0", "1.0.1") >= 0 {
		t.Fatal("compareVersion returned an unexpected ordering")
	}
}
