File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,8 @@ function _build_uuid1(rng::AbstractRNG, timestamp::UInt64)
74
74
# mask off clock sequence and node
75
75
u &= 0x00000000000000003fffffffffffffff
76
76
77
- # set the unicast/multicast bit and version
78
- u |= 0x00000000000010000000010000000000
77
+ # set the version, variant, and unicast/multicast bit
78
+ u |= 0x00000000000010008000010000000000
79
79
80
80
ts_low = timestamp & typemax (UInt32)
81
81
ts_mid = (timestamp >> 32 ) & typemax (UInt16)
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ u7 = uuid7()
42
42
@test uuid_version (u7) == 7
43
43
end
44
44
45
+ @testset " Extraction of variant bits" begin
46
+ # RFC 4122, section 4.1.1
47
+ uuid_variant (u:: UUID ) = Int ((u. value >> 62 ) & 0x3 )
48
+ @test uuid_variant (u1) == 2
49
+ @test uuid_variant (u4) == 2
50
+ @test uuid_variant (u5) == 2
51
+ @test uuid_variant (u7) == 2
52
+ end
53
+
45
54
@testset " Parsing from string" begin
46
55
@test u1 == UUID (string (u1)) == UUID (GenericString (string (u1)))
47
56
@test u4 == UUID (string (u4)) == UUID (GenericString (string (u4)))
You can’t perform that action at this time.
0 commit comments