]> Cypherpunks repositories - keks.git/commitdiff
Additional TAI64NA generation strategy
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 12:33:16 +0000 (15:33 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 12:35:59 +0000 (15:35 +0300)
py3/tests/strategies.py

index 0f077d226a57a6a3760410f5157d0949ab9ca1f23c4c8f2f82886d4d6ba7467a..5a8e81931ca5c1a91f04e08bea6c9bacd1b89517c1425becaa76aac4756ea583 100644 (file)
@@ -29,14 +29,22 @@ from hypothesis.strategies import text
 from hypothesis.strategies import tuples
 from hypothesis.strategies import uuids
 
+from keks import _byte
 from keks import Blob
+from keks import Raw
+from keks import TagTAI64NA
+from keks import TAI64Base
 
 
+TagTAI64NAb = _byte(TagTAI64NA)
 junk_st = binary(max_size=8)
 blobs_st = tuples(integers(1, 20), binary(max_size=60)).map(lambda x: Blob(*x))
 unicode_allowed = characters(exclude_characters="\x00", exclude_categories=("Cs",))
 text_st = text(alphabet=unicode_allowed, max_size=32)
 mapkey_st = text(alphabet=unicode_allowed, min_size=1, max_size=8)
+tai64na_st = tuples(integers(1, 100), integers(1, 100)).map(lambda x: Raw(
+    TagTAI64NAb + (TAI64Base + x[0]).to_bytes(8, "big") + (x[1] + 1).to_bytes(8, "big")
+))
 any_st = one_of(
     booleans(),
     integers(),
@@ -48,6 +56,7 @@ any_st = one_of(
     uuids(),
     datetimes(),
     blobs_st,
+    tai64na_st,
 )
 everything_st = deferred(
     lambda: any_st |