Skip to content

Commit 9fce777

Browse files
authored
test(internal): expand coverage for http_error (#1035)
Add tests/unit/http_error_coverage_test.cpp exercising branches not reached by tests/test_network_config_http_error.cpp: - get_error_status_text default/unknown-code arm - http_error::is_client_error / is_server_error boundary values (399, 400, 499, 500, 599, 600) - parse_error::to_http_error with and without context - http_error_response::make_error with/without detail and request_id - build_json_error detail-fallback ternary, request_id if-branch, escape_json_string switch (", \\, \b, \f, \n, \r, \t, low control bytes, plain ASCII, high-bit bytes) - build_html_error message / detail / request_id empty-vs-present branches and escape_html_string switch (& < > " ' default) - deterministic ISO-8601 timestamp rendering through strftime path Tests are hermetic (no network, filesystem, or sleeps) and hit every switch arm of the two file-local escape helpers plus every if-branch of the JSON and HTML builders. Closes #1023
1 parent fc5eae5 commit 9fce777

2 files changed

Lines changed: 434 additions & 0 deletions

File tree

tests/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,6 +4740,13 @@ add_network_test(network_http2_client_extended_coverage_test
47404740
# conditions (Issue #1013)
47414741
add_network_test(network_http_parser_coverage_test unit/http_parser_coverage_test.cpp)
47424742

4743+
# HTTP error extended coverage: get_error_status_text default branch,
4744+
# escape_json_string switch branches (all special chars, low control bytes,
4745+
# plain ASCII, high-bit bytes), escape_html_string switch branches, and the
4746+
# detail / request_id / message empty-vs-non-empty branches of
4747+
# http_error_response::build_json_error and build_html_error (Issue #1023)
4748+
add_network_test(network_http_error_coverage_test unit/http_error_coverage_test.cpp)
4749+
47434750
# Secure transport module tests
47444751
add_network_test(network_secure_tcp_socket_module_test unit/secure_tcp_socket_test.cpp)
47454752
# secure_messaging_udp_client/server excluded: depend on dtls_socket from

0 commit comments

Comments
 (0)