FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add unit tests for callback, Client, edge cases, and thread safety by jvmvik · Pull Request #3 · serpapi/serpapi-cpp · GitHub

Add unit tests for callback, Client, edge cases, and thread safety - #3

Merged
jvmvik merged 1 commit into
mainfrom
fix/test-coverage
Jun 9, 2026
Merged

Add unit tests for callback, Client, edge cases, and thread safety#3
jvmvik merged 1 commit into
mainfrom
fix/test-coverage

Conversation

jvmvik commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds test/test_unit.cpp to cover critical gaps in test coverage. All 22 tests pass (5 existing + 17 new).

New tests

callback (8 tests)

  • Null out and in pointers return 0
  • size == 0 or num == 0 return 0
  • size * num overflow returns 0
  • Normal single and multi-chunk appends

Client construction & config (4 tests)

  • Empty and populated parameter maps
  • setTimeout() with positive and zero values

Edge cases / network (4 tests)

  • Special characters (&, spaces) in location query — verifies URL encoding
  • Empty query string — verifies no crash
  • Default params at construction merged with per-call params
  • search() always returns a parseable JSON object

Thread safety (1 test)

  • 4 concurrent location() calls verify std::call_once CURL init is race-free

What still requires mocking to test

  • curl_easy_init() returning null (OOM)
  • curl_easy_perform() network failure path
  • HasParseError() branch (needs injected bad response body)
  • curl_easy_escape() null return (OOM)

🤖 Generated with Claude Code

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>
jvmvik self-assigned this Jun 9, 2026
jvmvik merged commit 379798b into main Jun 9, 2026
1 check passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL