forked from twinj/uuid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_test.go
49 lines (46 loc) · 1.09 KB
/
version_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
package uuid
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestVersion_String(t *testing.T) {
for _, v := range []Version{
One, Two, Three, Four, Five, Unknown,
} {
assert.NotEmpty(t, v.String(), "Expected a value")
}
}
// Used to determine that a byte result from getting the variant is with the
// correct constraints and bounded values.
func tVariantConstraint(v byte, b byte, o UUID, t *testing.T) {
switch v {
case VariantNCS:
switch b {
case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07:
break
default:
t.Errorf("%X most high bits do not resolve to 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07", b)
}
case VariantRFC4122:
switch b {
case 0x08, 0x09, 0x0A, 0x0B:
break
default:
t.Errorf("%X most high bits do not resolve to 0x08, 0x09, 0x0A, 0x0B", b)
}
case VariantMicrosoft:
switch b {
case 0x0C, 0x0D:
break
default:
t.Errorf("%X most high bits do not resolve to 0x0C, 0x0D", b)
}
case VariantFuture:
switch b {
case 0x0E, 0x0F:
break
default:
t.Errorf("%X most high bits do not resolve to 0x0E, 0x0F", b)
}
}
}