Add unit tests for callback, Client, edge cases, and thread safety#3
Merged
Conversation
New test/test_unit.cpp covers previously untested paths: - callback: null inputs, zero size/num, size*num overflow, normal append, multi-chunk accumulation - Client: construction with empty/non-empty params, setTimeout (zero and positive) - Edge cases: special characters in location query, empty query string, default param merging - Response integrity: search always returns parseable JSON object - Thread safety: 4 concurrent location() calls with std::call_once CURL init Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
test/test_unit.cppto cover critical gaps in test coverage. All 22 tests pass (5 existing + 17 new).New tests
callback (8 tests)
outandinpointers return 0size == 0ornum == 0return 0size * numoverflow returns 0Client construction & config (4 tests)
setTimeout()with positive and zero valuesEdge cases / network (4 tests)
&, spaces) in location query — verifies URL encodingsearch()always returns a parseable JSON objectThread safety (1 test)
location()calls verifystd::call_onceCURL init is race-freeWhat still requires mocking to test
curl_easy_init()returning null (OOM)curl_easy_perform()network failure pathHasParseError()branch (needs injected bad response body)curl_easy_escape()null return (OOM)🤖 Generated with Claude Code