@@ -31,59 +31,56 @@ object Tests extends Suite(t"Inimitable Tests"):
31
31
Uuid ()
32
32
.matches:
33
33
case Uuid (a, b) => (a, b)
34
-
34
+
35
35
test(t " Get bytes from UUID " ):
36
36
Uuid ().bytes
37
37
.assert(_.length == 16 )
38
38
39
39
test(t " Parse a UUID at compiletime " ):
40
40
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c "
41
41
.assert()
42
-
42
+
43
43
test(t " Get the most significant bits from a UUID " ):
44
44
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " .msb
45
45
.assert(_ == - 6860364383762101208L )
46
-
46
+
47
47
test(t " Get the least significant bits from a UUID " ):
48
48
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " .lsb
49
49
.assert(_ == - 8777588922722300788L )
50
-
50
+
51
51
test(t " Get the Java UUID " ):
52
52
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " .java
53
53
.assert(_ == java.util.UUID .fromString(" a0cb16f0-d41e-4c28-862f-bd6164bbcc8c" ))
54
-
54
+
55
55
test(t " Get the bytes from a UUID " ):
56
56
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " .bytes.to(List )
57
57
.assert(_ == List [Byte ](- 96 , - 53 , 22 , - 16 , - 44 , 30 , 76 , 40 , - 122 , 47 , - 67 , 97 , 100 , - 69 , - 52 , - 116 ))
58
-
58
+
59
59
test(t " Convert a UUID to Text " ):
60
60
uuid " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " .text
61
61
.assert(_ == t " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " )
62
-
62
+
63
63
test(t " Parse a UUID at runtime " ):
64
64
unsafely(Uuid .parse(t " a0cb16f0-d41e-4c28-862f-bd6164bbcc8c " ))
65
65
.assert(_ == Uuid (- 6860364383762101208L , - 8777588922722300788L ))
66
-
66
+
67
67
test(t " Parse a bad UUID at runtime " ):
68
68
unsafely(capture[UuidError ](Uuid .parse(t " not-a-uuid " )))
69
69
.assert(_ == UuidError (t " not-a-uuid " ))
70
-
70
+
71
71
val uuid1 = Uuid ()
72
72
val uuid2 = Uuid ()
73
-
73
+
74
74
test(t " XOR two UUIDs " ):
75
75
uuid1 ^ uuid2
76
76
.assert { uuid => uuid != uuid1 && uuid != uuid2 }
77
-
77
+
78
78
test(t " Invert a UUID " ):
79
79
~ uuid1
80
80
.assert(_ != uuid1)
81
-
81
+
82
82
test(t " Parse a bad UUID at compiletime " ):
83
83
demilitarize :
84
84
uuid " not-a-uuid "
85
85
.map(_.message)
86
86
.assert(_ == List (t " inimitable: not-a-uuid is not a valid UUID " ))
87
-
88
-
89
-
0 commit comments