@@ -34,6 +34,47 @@ def get_command_stdout(command, args):
3434class BaseTestUUID :
3535 uuid = None
3636
37+ def test_nil_uuid (self ):
38+ nil_uuid = self .uuid .NIL
39+
40+ s = '00000000-0000-0000-0000-000000000000'
41+ i = 0
42+ self .assertEqual (nil_uuid , self .uuid .UUID (s ))
43+ self .assertEqual (nil_uuid , self .uuid .UUID (int = i ))
44+ self .assertEqual (nil_uuid .int , i )
45+ self .assertEqual (str (nil_uuid ), s )
46+ # The Nil UUID falls within the range of the Apollo NCS variant as per
47+ # RFC 9562.
48+ # See https://www.rfc-editor.org/rfc/rfc9562.html#section-5.9-4
49+ self .assertEqual (nil_uuid .variant , self .uuid .RESERVED_NCS )
50+ # A version field of all zeros is "Unused" in RFC 9562, but the version
51+ # field also only applies to the 10xx variant, i.e. the variant
52+ # specified in RFC 9562. As such, because the Nil UUID falls under a
53+ # different variant, its version is considered undefined.
54+ # See https://www.rfc-editor.org/rfc/rfc9562.html#table2
55+ self .assertIsNone (nil_uuid .version )
56+
57+ def test_max_uuid (self ):
58+ max_uuid = self .uuid .MAX
59+
60+ s = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
61+ i = (1 << 128 ) - 1
62+ self .assertEqual (max_uuid , self .uuid .UUID (s ))
63+ self .assertEqual (max_uuid , self .uuid .UUID (int = i ))
64+ self .assertEqual (max_uuid .int , i )
65+ self .assertEqual (str (max_uuid ), s )
66+ # The Max UUID falls within the range of the "yet-to-be defined" future
67+ # UUID variant as per RFC 9562.
68+ # See https://www.rfc-editor.org/rfc/rfc9562.html#section-5.10-4
69+ self .assertEqual (max_uuid .variant , self .uuid .RESERVED_FUTURE )
70+ # A version field of all ones is "Reserved for future definition" in
71+ # RFC 9562, but the version field also only applies to the 10xx
72+ # variant, i.e. the variant specified in RFC 9562. As such, because the
73+ # Max UUID falls under a different variant, its version is considered
74+ # undefined.
75+ # See https://www.rfc-editor.org/rfc/rfc9562.html#table2
76+ self .assertIsNone (max_uuid .version )
77+
3778 def test_safe_uuid_enum (self ):
3879 class CheckedSafeUUID (enum .Enum ):
3980 safe = 0
0 commit comments