From 12affdcc64f6fd78b3cfe88c0254a51cff734f86 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Mar 2026 00:44:04 +0000 Subject: [PATCH] Address code review feedback: .gitignore path, fuzzer docs, trailing whitespace test Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com> --- .gitignore | 2 +- tests/fuzzer/fuzz_gltf_customjson.cc | 5 ++++- tests/tester_intensive_customjson.cc | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 15d073a..8c7b8f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # CMake -build/ +/build/ CMakeCache.txt CMakeFiles CMakeScripts diff --git a/tests/fuzzer/fuzz_gltf_customjson.cc b/tests/fuzzer/fuzz_gltf_customjson.cc index cdab09e..8f8da75 100644 --- a/tests/fuzzer/fuzz_gltf_customjson.cc +++ b/tests/fuzzer/fuzz_gltf_customjson.cc @@ -61,7 +61,10 @@ static void fuzz_binary(const uint8_t *data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (size == 0) return 0; - /* Use the first byte to select the parse path, pass the rest as input. */ + /* Use the lowest bit of the first byte to select the parse path. + * The remaining bits are left for the fuzzer engine to explore; + * additional paths (e.g. LoadASCIIFromFile, check_sections flags) + * can be added here in the future using more selector bits. */ uint8_t selector = data[0]; const uint8_t *payload = data + 1; size_t payload_size = size - 1; diff --git a/tests/tester_intensive_customjson.cc b/tests/tester_intensive_customjson.cc index d681b7e..ad41fbf 100644 --- a/tests/tester_intensive_customjson.cc +++ b/tests/tester_intensive_customjson.cc @@ -401,11 +401,18 @@ TEST_CASE("cj-malformed-incomplete-null", "[customjson][malformed]") { } TEST_CASE("cj-malformed-extra-data", "[customjson][malformed]") { - // Valid JSON followed by extra data + // Valid JSON followed by extra non-whitespace data auto doc = JsonConstruct("42 extra"); REQUIRE(doc.is_null()); } +TEST_CASE("cj-trailing-whitespace-ok", "[customjson][parse]") { + // Valid JSON followed by whitespace only should be accepted + auto doc = JsonConstruct("42 \t\n "); + REQUIRE(doc.is_number()); + REQUIRE(doc.get() == 42); +} + TEST_CASE("cj-malformed-just-brace", "[customjson][malformed]") { auto doc = JsonConstruct("{"); REQUIRE(doc.is_null());