Skip to content

Commit

Permalink
Test generated UUIDs against regular expressions (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
oittaa committed Feb 5, 2022
1 parent 6aef1b4 commit dc979a6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/test_uuid6.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from uuid6 import UUID, uuid6, uuid7

REGEX_UUID6 = r"^[0-9a-f]{8}-[0-9a-f]{4}-6[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
REGEX_UUID7 = r"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
YEAR_IN_NS = 3600 * 24 * 36525 * 10**7


Expand All @@ -14,6 +16,7 @@ def test_uuid6_generation(self):
uuid6_1 = uuid6()
self.assertEqual(uuid6_1.version, 6)
for _ in range(1000):
self.assertRegex(str(uuid6_1), REGEX_UUID6)
uuid6_2 = uuid6()
self.assertLess(uuid6_1, uuid6_2)
uuid6_1 = uuid6_2
Expand All @@ -22,6 +25,7 @@ def test_uuid7_generation(self):
uuid7_1 = uuid7()
self.assertEqual(uuid7_1.version, 7)
for _ in range(1000):
self.assertRegex(str(uuid7_1), REGEX_UUID7)
uuid7_2 = uuid7()
self.assertLess(uuid7_1, uuid7_2)
uuid7_1 = uuid7_2
Expand Down

0 comments on commit dc979a6

Please sign in to comment.