allow string reuse (#2454)

* allow string reuse

* portability fix

* using data and not begin
This commit is contained in:
Daniel Lemire
2025-09-18 15:16:38 -06:00
committed by GitHub
parent 2526068e2f
commit 703ef54bd9
4 changed files with 59 additions and 7 deletions
@@ -519,6 +519,20 @@ namespace builder_tests {
ASSERT_EQUAL(s, "[[1.0,2.0],[3.0,4.0]]");
TEST_SUCCEED();
}
bool double_double_test_to_string() {
TEST_START();
std::vector<std::vector<double>> c = {{1.0, 2.0}, {3.0, 4.0}};
simdjson::builder::string_builder sb;
sb.append(c);
std::string_view p;
auto result = sb.view().get(p);
ASSERT_SUCCESS(result);
ASSERT_EQUAL(p, "[[1.0,2.0],[3.0,4.0]]");
std::string s;
simdjson::simdjson_error ec = simdjson::to_json(c,s);
ASSERT_EQUAL(s, "[[1.0,2.0],[3.0,4.0]]");
TEST_SUCCEED();
}
#if SIMDJSON_EXCEPTIONS
bool car_test_simple_complete_exceptions() {
TEST_START();
@@ -567,6 +581,7 @@ namespace builder_tests {
#if SIMDJSON_SUPPORTS_RANGES && SIMDJSON_SUPPORTS_CONCEPTS
map_test() &&
double_double_test() &&
double_double_test_to_string() &&
car_test_simple() &&
car_test_simple_complete() &&
#if SIMDJSON_EXCEPTIONS