cri-o/vendor/github.com/blang/semver/sql_test.go
Mrunal Patel 24df2538db Update runtime-spec to v1.0.0.rc5
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-04-12 19:15:53 -07:00

38 lines
779 B
Go

package semver
import (
"testing"
)
type scanTest struct {
val interface{}
shouldError bool
expected string
}
var scanTests = []scanTest{
{"1.2.3", false, "1.2.3"},
{[]byte("1.2.3"), false, "1.2.3"},
{7, true, ""},
{7e4, true, ""},
{true, true, ""},
}
func TestScanString(t *testing.T) {
for _, tc := range scanTests {
s := &Version{}
err := s.Scan(tc.val)
if tc.shouldError {
if err == nil {
t.Fatalf("Scan did not return an error on %v (%T)", tc.val, tc.val)
}
} else {
if err != nil {
t.Fatalf("Scan returned an unexpected error: %s (%T) on %v (%T)", tc.val, tc.val, tc.val, tc.val)
}
if val, _ := s.Value(); val != tc.expected {
t.Errorf("Wrong Value returned, expected %q, got %q", tc.expected, val)
}
}
}
}