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:
Daniel Lemire
2024-06-11 13:55:55 -04:00
committed by GitHub
parent 2a4ff73468
commit eb8f2bce14
2 changed files with 48 additions and 6 deletions
+24
View File
@@ -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
+24 -6
View File
@@ -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() &&