/
helper_test.go
45 lines (41 loc) · 1.09 KB
/
helper_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
package uuid
import (
"testing"
)
func TestEncodeDecode(t *testing.T) {
u1 := NewV1()
encoded := u1.Encode()
u2, err := Decode(encoded)
if err != nil {
t.Error("decode failed")
return
}
if u1 != u2 {
t.Error("encode and decode mismatch")
return
}
}
//var (
// NamespaceDNS, _ = Decode([]byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
// NamespaceURL, _ = Decode([]byte("6ba7b811-9dad-11d1-80b4-00c04fd430c8"))
// NamespaceOID, _ = Decode([]byte("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
// NamespaceX500, _ = Decode([]byte("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
//)
func TestNamespace(t *testing.T) {
if NamespaceDNS.String() != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" {
t.Error("decode and encode mismatch")
return
}
if NamespaceURL.String() != "6ba7b811-9dad-11d1-80b4-00c04fd430c8" {
t.Error("decode and encode mismatch")
return
}
if NamespaceOID.String() != "6ba7b812-9dad-11d1-80b4-00c04fd430c8" {
t.Error("decode and encode mismatch")
return
}
if NamespaceX500.String() != "6ba7b814-9dad-11d1-80b4-00c04fd430c8" {
t.Error("decode and encode mismatch")
return
}
}