File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments