Skip to content

test: expand coverage for src/internal/http_error.cpp #1020

Description

@kcenon

Part of #953

What

Raise line coverage of src/internal/http_error.cpp from 3.2% to >= 70%, and branch coverage to >= 60%.

Current state (pre-Step-1 snapshot, 2026-04-13 measurement from parent epic #953):

  • Lines hit: 6 / 190 (3.2%)
  • File size: 190 LOC

Note: These numbers predate the BUILD_WITH_* workflow fix (#987, #989). A re-measurement on the current develop baseline will be captured in the PR description before merging.

Why

  • http_error.cpp at 3.2% line coverage is one of the lowest-covered implementation files in the project.
  • HTTP error mapping is consumed across all HTTP client/server code paths; incorrect error translation leaks implementation detail to downstream users.
  • Small file, high leverage: ~190 lines is a tractable single-PR scope that meaningfully moves overall line coverage.
  • v1.0 target (80% line / 70% branch) depends on Expand unit test coverage from 40% to 80% #953 completion.

Where

  • Source: src/internal/http_error.cpp
  • Headers: include/kcenon/network/internal/http_error.hpp (verify exact path)
  • Existing tests to extend: tests/unit/ — check for existing http_error_test.cpp before adding
  • Possibly add: tests/unit/internal/http_error_test.cpp

How

Approach

  1. Enumerate every HTTP status code / error enum value handled in http_error.cpp.
  2. Write table-driven parameterized tests covering:
    • Every error-code → status-string mapping
    • Boundary conditions (invalid codes, unknown enum values, default-case branches)
    • Round-trip conversions if the file defines parse + format pairs
  3. Target remaining untested branches per the coverage HTML report.

Acceptance Criteria

  • src/internal/http_error.cpp line coverage >= 70%
  • src/internal/http_error.cpp branch coverage >= 60%
  • New or extended tests in tests/unit/
  • All tests pass on Ubuntu/macOS/Windows CI
  • ASAN/TSAN/UBSAN all green on the new tests
  • Current develop baseline re-measured in PR description

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions