@@ -4,13 +4,53 @@ using Test, UUIDs, Random
4
4
5
5
u1 = uuid1 ()
6
6
u4 = uuid4 ()
7
+ u5 = uuid5 (u1, " julia" )
7
8
@test uuid_version (u1) == 1
8
9
@test uuid_version (u4) == 4
10
+ @test uuid_version (u5) == 5
9
11
@test u1 == UUID (string (u1)) == UUID (GenericString (string (u1)))
10
12
@test u4 == UUID (string (u4)) == UUID (GenericString (string (u4)))
13
+ @test u5 == UUID (string (u5)) == UUID (GenericString (string (u5)))
11
14
@test u1 == UUID (UInt128 (u1))
12
15
@test u4 == UUID (UInt128 (u4))
16
+ @test u5 == UUID (UInt128 (u5))
13
17
@test uuid4 (MersenneTwister (0 )) == uuid4 (MersenneTwister (0 ))
14
18
@test_throws ArgumentError UUID (" 550e8400e29b-41d4-a716-446655440000" )
15
19
@test_throws ArgumentError UUID (" 550e8400e29b-41d4-a716-44665544000098" )
16
20
@test_throws ArgumentError UUID (" z50e8400-e29b-41d4-a716-446655440000" )
21
+
22
+ # results similar to Python builtin uuid
23
+ # To reproduce the sequence
24
+ #=
25
+ import uuid
26
+ uuids = [uuid.UUID("22b4a8a1-e548-4eeb-9270-60426d66a48e")]
27
+ for _ in range(5):
28
+ uuids.append(uuid.uuid5(uuids[-1], "julia"))
29
+ =#
30
+
31
+ const following_uuids = [
32
+ UUID (" 22b4a8a1-e548-4eeb-9270-60426d66a48e" ),
33
+ UUID (" 30ea6cfd-c270-569f-b4cb-795dead63686" ),
34
+ UUID (" 31099374-e3a0-5fde-9482-791c639bf29b" ),
35
+ UUID (" 6b34b357-a348-53aa-8c71-fb9b06c3a51e" ),
36
+ UUID (" fdbd7d4d-c462-59cc-ae6a-0c3b010240e2" ),
37
+ UUID (" d8cc6298-75d5-57e0-996c-279259ab365c" ),
38
+ ]
39
+
40
+ for (idx, init_uuid) in enumerate (following_uuids[1 : end - 1 ])
41
+ next_id = uuid5 (init_uuid, " julia" )
42
+ @test next_id == following_uuids[idx+ 1 ]
43
+ end
44
+
45
+ # Python-generated UUID following each of the standard namespaces
46
+ const standard_namespace_uuids = [
47
+ (UUIDs. namespace_dns, UUID (" 00ca23ad-40ef-500c-a910-157de3950d07" )),
48
+ (UUIDs. namespace_oid, UUID (" b7bf72b0-fb4e-538b-952a-3be296f07f6d" )),
49
+ (UUIDs. namespace_url, UUID (" 997cd5be-4705-5439-9fe6-d77b18d612e5" )),
50
+ (UUIDs. namespace_x500, UUID (" 993c6684-82e7-5cdb-bd46-9bff0362e6a9" )),
51
+ ]
52
+
53
+ for (init_uuid, next_uuid) in standard_namespace_uuids
54
+ result = uuid5 (init_uuid, " julia" )
55
+ @test next_uuid == result
56
+ end
0 commit comments