Debian Codegraph @

version_test.go

raw
1 package uuid
2
3 import (
4 "github.com/stretchr/testify/assert"
5 "testing"
6 )
7
8 func TestVersion_String(t *testing.T) {
9 for _, v := range []Version{
10 One, Two, Three, Four, Five, Unknown,
11 } {
12 assert.NotEmpty(t, v.String(), "Expected a value")
13 }
14 }
15
16 // Used to determine that a byte result from getting the variant is with the
17 // correct constraints and bounded values.
18 func tVariantConstraint(v byte, b byte, o UUID, t *testing.T) {
19 switch v {
20 case VariantNCS:
21 switch b {
22 case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07:
23 break
24 default:
25 t.Errorf("%X most high bits do not resolve to 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07", b)
26 }
27 case VariantRFC4122:
28 switch b {
29 case 0x08, 0x09, 0x0A, 0x0B:
30 break
31 default:
32 t.Errorf("%X most high bits do not resolve to 0x08, 0x09, 0x0A, 0x0B", b)
33 }
34 case VariantMicrosoft:
35 switch b {
36 case 0x0C, 0x0D:
37 break
38 default:
39 t.Errorf("%X most high bits do not resolve to 0x0C, 0x0D", b)
40 }
41 case VariantFuture:
42 switch b {
43 case 0x0E, 0x0F:
44 break
45 default:
46 t.Errorf("%X most high bits do not resolve to 0x0E, 0x0F", b)
47 }
48 }
49 }