Skip to content

Commit de2791d

Browse files
committed
improving test coverage
1 parent 59b89c4 commit de2791d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_002_types.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,8 @@ def test_utf8_2byte_sequence_complete_coverage():
823823
for test_bytes, binary, desc in invalid_continuation:
824824
try:
825825
result = test_bytes.decode("utf-8", errors="replace")
826-
# Check that invalid sequences are handled (may produce replacement chars or split)
827-
assert len(result) > 0, f"Should produce some output for {desc}"
826+
# Invalid continuation should return the replacement character (covers ddbc_bindings.h lines 476-478)
827+
assert "\ufffd" in result, f"Should contain replacement char for {desc}"
828828
except Exception as e:
829829
# Any error handling is acceptable for invalid sequences
830830
pass
@@ -862,8 +862,11 @@ def test_utf8_2byte_sequence_complete_coverage():
862862
for test_bytes, codepoint, desc in overlong_2byte:
863863
try:
864864
result = test_bytes.decode("utf-8", errors="replace")
865-
# Check that overlong sequences are handled (behavior may vary by platform)
866-
assert len(result) > 0, f"Should produce some output for overlong U+{codepoint:04X}"
865+
# Overlong encodings must yield replacement, not the original codepoint (covers lines 486-487)
866+
assert "\ufffd" in result, f"Overlong U+{codepoint:04X} should produce replacement char"
867+
assert (
868+
chr(codepoint) not in result
869+
), f"Overlong U+{codepoint:04X} must not decode to original char"
867870
except Exception as e:
868871
pass
869872

0 commit comments

Comments
 (0)