numerus/pkg/uuid_test.go

34 lines
740 B
Go
Raw Normal View History

package pkg
import (
"strings"
"testing"
)
type test struct {
in string
isUuid bool
}
var tests = []test{
{"f47ac10b-58cc-0372-8567-0e02b2c3d479", true},
{"2bc1be74-169d-4300-a239-49a1196a045d", true},
{"12bc1be74-169d-4300-a239-49a1196a045d", false},
{"2bc1be74-169d-4300-a239-49a1196a045", false},
{"2bc1be74-1x9d-4300-a239-49a1196a045d", false},
{"2bc1be74-169d-4300-a239-49a1196ag45d", false},
}
func testValidUuid(t *testing.T, in string, isUuid bool) {
if ok := ValidUuid(in); ok != isUuid {
t.Errorf("ValidUuid(%s) got %v expected %v", in, ok, isUuid)
}
}
func TestUUID(t *testing.T) {
for _, tt := range tests {
testValidUuid(t, tt.in, tt.isUuid)
testValidUuid(t, strings.ToUpper(tt.in), tt.isUuid)
}
}