Fixing issue 1579. (#1580)
This commit is contained in:
parent
0b75de12ef
commit
efe9761f80
|
@ -201,4 +201,26 @@ inline simdjson::simdjson_result<std::string> to_string(simdjson::SIMDJSON_IMPLE
|
||||||
return std::string(answer.data(), answer.size());
|
return std::string(answer.data(), answer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
inline std::string to_string(simdjson_result<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::document> x) {
|
||||||
|
if (x.error()) { throw simdjson_error(x.error()); }
|
||||||
|
return to_string(x.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string to_string(simdjson_result<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value> x) {
|
||||||
|
if (x.error()) { throw simdjson_error(x.error()); }
|
||||||
|
return to_string(x.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string to_string(simdjson_result<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::object> x) {
|
||||||
|
if (x.error()) { throw simdjson_error(x.error()); }
|
||||||
|
return to_string(x.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string to_string(simdjson_result<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::array> x) {
|
||||||
|
if (x.error()) { throw simdjson_error(x.error()); }
|
||||||
|
return to_string(x.value());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
} // namespace simdjson
|
} // namespace simdjson
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
#include "test_ondemand.h"
|
#include "test_ondemand.h"
|
||||||
namespace tostring_tests {
|
namespace tostring_tests {
|
||||||
const char *test_files[] = {
|
const char *test_files[] = {
|
||||||
|
@ -22,6 +24,16 @@ const char *test_files[] = {
|
||||||
#if SIMDJSON_EXCEPTIONS
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
bool minify_demo() {
|
||||||
|
TEST_START();
|
||||||
|
ondemand::parser parser;
|
||||||
|
auto cars_json = R"( { "test": "result" } )"_padded;
|
||||||
|
ondemand::document doc;
|
||||||
|
ASSERT_SUCCESS( parser.iterate(cars_json).get(doc) );
|
||||||
|
std::cout << simdjson::to_string(doc["test"]) << std::endl;
|
||||||
|
TEST_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The general idea of these tests if that if you take a JSON file,
|
* The general idea of these tests if that if you take a JSON file,
|
||||||
* load it, then convert it into a string, then parse that, and
|
* load it, then convert it into a string, then parse that, and
|
||||||
|
@ -73,8 +85,9 @@ bool minify_test() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
TEST_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
bool load_to_string_exceptionless(const char *filename) {
|
bool load_to_string_exceptionless(const char *filename) {
|
||||||
|
@ -136,6 +149,7 @@ bool minify_exceptionless_test() {
|
||||||
bool run() {
|
bool run() {
|
||||||
return
|
return
|
||||||
#if SIMDJSON_EXCEPTIONS
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
minify_demo() &&
|
||||||
minify_test() &&
|
minify_test() &&
|
||||||
#endif // SIMDJSON_EXCEPTIONS
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
minify_exceptionless_test() &&
|
minify_exceptionless_test() &&
|
||||||
|
|
Loading…
Reference in New Issue