22from hypothesis import given
33from hypothesis import strategies as st
44
5- from pyjelly .errors import JellyAssertionError
5+ from pyjelly .errors import JellyAssertionError , JellyConformanceError
66from pyjelly .options import MAX_LOOKUP_SIZE
77from pyjelly .parse .lookup import LookupDecoder
88
@@ -17,3 +17,25 @@ def test_max_lookup_size_exceeded(size: int) -> None:
1717 with pytest .raises (JellyAssertionError ) as excinfo :
1818 LookupDecoder (lookup_size = size )
1919 assert str (excinfo .value ) == f"lookup size must be less than { MAX_LOOKUP_SIZE } "
20+
21+
22+ def test_decode_zero_error () -> None :
23+ dec = LookupDecoder (lookup_size = 1 )
24+ dec .last_reused_index = - 1
25+ with pytest .raises (JellyConformanceError ):
26+ dec .decode_name_term_index (0 )
27+
28+
29+ def test_datatype_index_zero_error () -> None :
30+ decoder = LookupDecoder (lookup_size = 0 )
31+ with pytest .raises (JellyConformanceError ) as excinfo :
32+ decoder .decode_datatype_term_index (0 )
33+ assert str (excinfo .value ) == "0 is not a valid datatype term index"
34+
35+
36+ def test_at_invalid_index () -> None :
37+ decoder = LookupDecoder (lookup_size = 4 )
38+ with pytest .raises (IndexError ) as excinfo :
39+ decoder .at (2 )
40+ assert "invalid resolved index 2" in str (excinfo .value )
41+ assert decoder .last_reused_index == 2
0 commit comments