Skip to content

Commit 66d13d7

Browse files
nandojvejhedberg
authored andcommitted
tests: lib: json: add escape handling tests
Add extensive test coverage for JSON escape sequence handling to ensure robustness and prevent regression in string encoding/decoding operations. The new test suite includes: 1. **Escape Sequence Stability**: Tests multiple encode/decode cycles to prevent backslash duplication bugs where sequences like \n, \t could be duplicated with each cycle. 2. **Individual Escape Sequences**: Comprehensive testing of each JSON escape type: - \n (newline), \t (tab), \r (carriage return), \f (form feed) - \b (backspace), \\ (backslash), \" (quote), \/ (slash) 3. **Quote Handling**: Special focus on quote escaping/unescaping to ensure proper JSON syntax and data integrity. 4. **Mixed Escape Sequences**: Complex scenarios with multiple different escape sequences in single strings to test edge cases. 5. **Multiple Cycle Stability**: Repeated encode/decode operations to simulate real-world usage patterns and detect gradual corruption. 6. **Backslash Duplication Detection**: Specific tests targeting the common bug where backslashes accumulate during multiple processing cycles. 7. **Round-trip Validation**: Complete encode → decode → encode cycles to verify data preservation. 8. **Edge Cases**: Testing boundary conditions like strings containing only quotes or complex escape combinations. These tests use a new `escape_test_data` structure with both string value and string buffer fields to verify proper handling of both JSON_TOK_STRING and JSON_TOK_STRING_BUF descriptor types. The test suite ensures that: - Escape sequences are properly encoded in JSON output - Escape sequences are correctly unescaped during parsing - No data corruption occurs during multiple processing cycles - Both string pointer and string buffer fields behave correctly - Complex escape scenarios are handled robustly Signed-off-by: BUDKE Gerson Fernando <gerson.budke@leica-geosystems.com>
1 parent 0ddb8e4 commit 66d13d7

File tree

1 file changed

+589
-0
lines changed

1 file changed

+589
-0
lines changed

0 commit comments

Comments
 (0)