-
Notifications
You must be signed in to change notification settings - Fork 0
/
uuid_test.go
59 lines (55 loc) · 1.47 KB
/
uuid_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package uuid
import (
"testing"
"github.com/google/uuid"
"github.com/xo/ox"
)
func TestUUID(t *testing.T) {
for _, exp := range uuidTests() {
t.Run(exp, func(t *testing.T) {
v, err := ox.UUIDT.New()
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
if err := v.Set(exp); err != nil {
t.Fatalf("expected no error, got: %v", err)
}
val, err := ox.As[*uuid.UUID](v)
if err != nil {
t.Fatalf("expected no error, got: %v", err)
}
if val == nil {
t.Fatalf("expected non-nil value")
}
if exp == "" {
exp = "00000000-0000-0000-0000-000000000000"
}
if s := val.String(); s != exp {
t.Errorf("expected %s, got: %s", exp, s)
}
t.Logf("u: %v", val)
})
}
}
func uuidTests() []string {
return []string{
"",
"00000000-0000-0000-0000-000000000000",
"f47ac10b-58cc-0372-8567-0e02b2c3d479",
"f47ac10b-58cc-1372-8567-0e02b2c3d479",
"f47ac10b-58cc-2372-8567-0e02b2c3d479",
"f47ac10b-58cc-3372-8567-0e02b2c3d479",
"f47ac10b-58cc-4372-8567-0e02b2c3d479",
"f47ac10b-58cc-5372-8567-0e02b2c3d479",
"f47ac10b-58cc-6372-8567-0e02b2c3d479",
"f47ac10b-58cc-7372-8567-0e02b2c3d479",
"f47ac10b-58cc-8372-8567-0e02b2c3d479",
"f47ac10b-58cc-9372-8567-0e02b2c3d479",
"f47ac10b-58cc-a372-8567-0e02b2c3d479",
"f47ac10b-58cc-b372-8567-0e02b2c3d479",
"f47ac10b-58cc-c372-8567-0e02b2c3d479",
"f47ac10b-58cc-d372-8567-0e02b2c3d479",
"f47ac10b-58cc-e372-8567-0e02b2c3d479",
"f47ac10b-58cc-f372-8567-0e02b2c3d479",
}
}