mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
fix: add test for issue 2199 (#2200)
* fix: add test for issue 2199 * added ubuntu 24 workflow + silencing a warning
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
name: Ubuntu 24.04 CI
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
ubuntu-build:
|
||||
if: >-
|
||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
shared: [ON, OFF]
|
||||
cxx: [g++-13, clang++-16]
|
||||
sanitizer: [ON, OFF]
|
||||
steps:
|
||||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
||||
- name: Prepare
|
||||
run: cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_SANITIZE=${{matrix.sanitizer}} -DBUILD_SHARED_LIBS=${{matrix.shared}} -B build
|
||||
env:
|
||||
CXX: ${{matrix.cxx}}
|
||||
- name: Build
|
||||
run: cmake --build build -j=2
|
||||
- name: Test
|
||||
run: ctest --output-on-failure --test-dir build
|
||||
@@ -5,6 +5,22 @@ using namespace simdjson;
|
||||
|
||||
namespace misc_tests {
|
||||
using namespace std;
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
// user reported an asan error:
|
||||
bool issue2199() {
|
||||
TEST_START();
|
||||
static constexpr std::string_view kJsonString = R"( { "name": "name", "version": 100, } )";
|
||||
try {
|
||||
simdjson::padded_string buffer{kJsonString};
|
||||
simdjson::ondemand::parser parser;
|
||||
simdjson::ondemand::document document = parser.iterate(buffer);
|
||||
(void)document;
|
||||
} catch (simdjson::simdjson_error& /*error*/) {
|
||||
std::cerr << "Caught simdjson_error" << std::endl;
|
||||
}
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
#endif
|
||||
bool issue1981_success() {
|
||||
auto error_phrase = R"(false)"_padded;
|
||||
TEST_START();
|
||||
@@ -532,7 +548,7 @@ namespace misc_tests {
|
||||
string_view token;
|
||||
ASSERT_SUCCESS(o["value"].raw_json_token().get(token));
|
||||
ASSERT_EQUAL(token, "12321323213213213213213213213211223");
|
||||
return true;
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
simdjson_warn_unused bool big_integer_in_string() {
|
||||
TEST_START();
|
||||
@@ -545,7 +561,7 @@ namespace misc_tests {
|
||||
string_view token;
|
||||
ASSERT_SUCCESS(o["value"].raw_json_token().get(token));
|
||||
ASSERT_EQUAL(token, "\"12321323213213213213213213213211223\"");
|
||||
return true;
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
simdjson_warn_unused bool test_raw_json_token(string_view json, string_view expected_token, int expected_start_index = 0) {
|
||||
string title("'");
|
||||
@@ -558,7 +574,7 @@ namespace misc_tests {
|
||||
ASSERT_EQUAL( token, expected_token );
|
||||
// Validate the text is inside the original buffer
|
||||
ASSERT_EQUAL( reinterpret_cast<const void*>(token.data()), reinterpret_cast<const void*>(&json_padded.data()[expected_start_index]));
|
||||
return true;
|
||||
TEST_SUCCEED();
|
||||
}));
|
||||
|
||||
// Test values
|
||||
@@ -576,10 +592,9 @@ namespace misc_tests {
|
||||
// Validate the text is inside the original buffer
|
||||
// Adjust for the {"a":
|
||||
ASSERT_EQUAL( reinterpret_cast<const void*>(token.data()), reinterpret_cast<const void*>(&json_padded.data()[5+expected_start_index]));
|
||||
return true;
|
||||
TEST_SUCCEED();
|
||||
}));
|
||||
|
||||
return true;
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
bool raw_json_token() {
|
||||
@@ -605,6 +620,9 @@ namespace misc_tests {
|
||||
|
||||
bool run() {
|
||||
return
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
issue2199() &&
|
||||
#endif
|
||||
skipbom() &&
|
||||
issue1981_success() &&
|
||||
issue1981_failure() &&
|
||||
|
||||
Reference in New Issue
Block a user