Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/UUIDs/src/UUIDs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ function _build_uuid1(rng::AbstractRNG, timestamp::UInt64)
# mask off clock sequence and node
u &= 0x00000000000000003fffffffffffffff

# set the unicast/multicast bit and version
u |= 0x00000000000010000000010000000000
# set the version, variant, and unicast/multicast bit
u |= 0x00000000000010008000010000000000

ts_low = timestamp & typemax(UInt32)
ts_mid = (timestamp >> 32) & typemax(UInt16)
Expand Down
9 changes: 9 additions & 0 deletions stdlib/UUIDs/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ u7 = uuid7()
@test uuid_version(u7) == 7
end

@testset "Extraction of variant bits" begin
# RFC 4122, section 4.1.1
uuid_variant(u::UUID) = Int((u.value >> 62) & 0x3)
@test uuid_variant(u1) == 2
@test uuid_variant(u4) == 2
@test uuid_variant(u5) == 2
@test uuid_variant(u7) == 2
end

@testset "Parsing from string" begin
@test u1 == UUID(string(u1)) == UUID(GenericString(string(u1)))
@test u4 == UUID(string(u4)) == UUID(GenericString(string(u4)))
Expand Down