Conversation
eb93056 to
b67b662
Compare
|
I think the C++ implementation needs a similar fix? |
There was a problem hiding this comment.
Pull request overview
This pull request addresses serialization issues with invalid characters in C by implementing hex formatting for characters with the high bit set. The PR also improves code formatting in the escape function and adds a test for detecting wrong function signatures in C.
Changes:
- Modified the
escape()function to output high-bit characters in hex format (e.g.,0xA4) instead of attempting standard escaping - Improved code formatting and structure in the escape function
- Added test case for detecting C function signature mismatches (returning wrong type)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tested/languages/c/templates/values.c | Updated escape function to handle high-bit characters with hex formatting; improved formatting and memory allocation |
| tests/test_language_quirks.py | Added test for detecting wrong function return type in C |
| tests/exercises/echo-function/solution/wrong-signature.c | Added test solution file with intentional type mismatch (returns char instead of char*) |
Comments suppressed due to low confidence (2)
tests/test_language_quirks.py:29
- The test name
test_c_pointer_char_returndoesn't clearly describe what's being tested. Consider renaming to something more descriptive liketest_c_wrong_return_type_signatureortest_c_return_type_mismatch_detectionto better convey that this test verifies the system correctly detects when a function returns the wrong type (char instead of char*).
tests/test_language_quirks.py:40 - The new test
test_c_pointer_char_returnis testing for a wrong function signature (returningcharinstead ofchar*), but it doesn't actually test the new hex formatting functionality for invalid characters that was added in this PR. Consider adding a test case that passes a string containing high-bit or non-printable characters to verify that the hex formatting (e.g.,0xA4) works correctly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
At least not the same fix; the serialization uses |
b67b662 to
641d2d6
Compare
|
Did some tests, this is much harder to trigger in cpp, but still possible, so I added a fix for that serializer as well. |
5ab360d to
8440326
Compare
8440326 to
959a2b9
Compare
niknetniko
left a comment
There was a problem hiding this comment.
Seems a reasonable solution to me.
Also took the opportunity to format the serialization a bit better.
Invalid characters are now treated as unsigned chars and written out in hex format (e.g.
0xA4). Better suggestions are welcome.