This should make issue 1370 easier to track. (#1429)

* This should make issue 1370 easier to track.

* Avoiding exceptions.
This commit is contained in:
Daniel Lemire 2021-02-02 16:12:16 -05:00 committed by GitHub
parent 96536239c2
commit 5449365658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 17 deletions

View File

@ -497,7 +497,7 @@ namespace document_stream_tests {
return true; return true;
} }
bool threaded_disabled() { bool window_too_small_issue1370() {
std::cout << "Running " << __func__ << std::endl; std::cout << "Running " << __func__ << std::endl;
char input[2049]; char input[2049];
input[0] = '['; input[0] = '[';
@ -506,22 +506,34 @@ namespace document_stream_tests {
input[2*i+2]= i < 1023 ? ',' : ']'; input[2*i+2]= i < 1023 ? ',' : ']';
} }
auto json = simdjson::padded_string(input,2049); auto json = simdjson::padded_string(input,2049);
simdjson::dom::parser parser; // We are going to repeat this test 1000 times so
size_t count = 0; // that if there is an issue, we are more likely to
size_t window_size = 1024; // deliberately too small // trigger it systematically.
simdjson::dom::document_stream stream; for(size_t trial = 0; trial < 1000; trial++) {
ASSERT_SUCCESS( parser.parse_many(json, window_size).get(stream) ); std::cout << ".";
for (auto doc : stream) { std::cout.flush();
if (!doc.error()) { simdjson::dom::parser parser;
std::cerr << "Expected a capacity error " << doc.error() << std::endl; size_t count = 0;
size_t window_size = 1024; // deliberately too small
simdjson::dom::document_stream stream;
ASSERT_SUCCESS( parser.parse_many(json, window_size).get(stream) );
for (auto doc : stream) {
if (!doc.error()) {
std::cerr << "Expected a capacity error but got: " << doc.error() << std::endl;
std::cerr << "The input was: " << json << std::endl;
simdjson::dom::element this_document;
ASSERT_SUCCESS(doc.get(this_document));
std::cerr << "We parsed the document: " << this_document << std::endl;
return false; return false;
}
count++;
}
if(count == 2) {
std::cerr << "Expected a single document " << std::endl;
return false;
} }
count++;
}
if(count == 2) {
std::cerr << "Expected a single document " << std::endl;
return false;
} }
std::cout << std::endl;
return true; return true;
} }
@ -673,9 +685,7 @@ namespace document_stream_tests {
issue1133() && issue1133() &&
single_document_exceptions() && single_document_exceptions() &&
#endif #endif
#ifdef SIMDJSON_THREADS_ENABLED window_too_small_issue1370() &&
threaded_disabled() &&
#endif
small_window() && small_window() &&
large_window() && large_window() &&
json_issue467() && json_issue467() &&