Skip to content

Strengthen parser required-field and FlexBuffers JSON null test oracles#9080

Open
parasol-aser wants to merge 1 commit intogoogle:masterfrom
parasol-aser:test-refine/tc001-tc002
Open

Strengthen parser required-field and FlexBuffers JSON null test oracles#9080
parasol-aser wants to merge 1 commit intogoogle:masterfrom
parasol-aser:test-refine/tc001-tc002

Conversation

@parasol-aser
Copy link
Copy Markdown

Summary

  • Add four TestError() cases in ErrorTest() pinning parser diagnostics for required annotations: required on scalar table fields, required on struct fields, and missing required scalar/table fields during JSON parse.
  • Strengthen ParseFlexbuffersFromJsonWithNullTest() so each int / double / null case asserts Parser::ParseFlexBuffer(...) == true and flexbuffers::VerifyBuffer(...) == true before reading values. Previously the return value of ParseFlexBuffer was silently dropped, so a parser regression would only surface as UB in the downstream AsInt64() / AsDouble() / IsNull() reads.

Coverage

Targeted lcov before/after on flattests shows src/idl_parser.cpp gaining 4 newly-hit lines (1155, 1164, 1627, 1628) — the Error() call sites for the new diagnostics.

Validation

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
  -DFLATBUFFERS_BUILD_TESTS=ON -DFLATBUFFERS_BUILD_CPP17=OFF \
  -DFLATBUFFERS_BUILD_GRPCTEST=OFF -DFLATBUFFERS_BUILD_BENCHMARKS=OFF \
  -DFLATBUFFERS_INSTALL=OFF
cmake --build build --target flattests
ctest --test-dir build -R '^flattests$' --output-on-failure

Passes. Diff is test-only; no production changes.

Risk

Low. The parser-error assertions match diagnostic substrings, so they would need an update if those messages are ever reworded — consistent with the ~50 existing TestError() cases in this file.

@parasol-aser parasol-aser requested a review from dbaileychess as a code owner May 7, 2026 03:06
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 7, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the c++ label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant