diff --git a/tests/allparserscheckfile.cpp b/tests/allparserscheckfile.cpp index 99d06a41..1e7d83ca 100644 --- a/tests/allparserscheckfile.cpp +++ b/tests/allparserscheckfile.cpp @@ -105,8 +105,10 @@ int main(int argc, char *argv[]) { rapid_correct_checkencoding ? "correct" : "invalid"); printf("sajson : %s \n", sajson_correct ? "correct" : "invalid"); - if(oursreturn == simdjson::DEPTH_ERROR) { - printf("simdjson encountered a DEPTH_ERROR, it was parametrized to reject documents with depth exceeding %zu.\n", maxdepth); + if (oursreturn == simdjson::DEPTH_ERROR) { + printf("simdjson encountered a DEPTH_ERROR, it was parametrized to " + "reject documents with depth exceeding %zu.\n", + maxdepth); } if ((ours_correct != rapid_correct_checkencoding) || (rapid_correct_checkencoding != sajson_correct) || diff --git a/tests/basictests.cpp b/tests/basictests.cpp index dbea44b9..fd2eff5e 100644 --- a/tests/basictests.cpp +++ b/tests/basictests.cpp @@ -15,10 +15,10 @@ bool skyprophet_test() { std::vector data; char buf[1024]; for (size_t i = 0; i < n_records; ++i) { - auto n = sprintf(buf, - "{\"id\": %zu, \"name\": \"name%zu\", \"gender\": \"%s\", " + auto n = + sprintf(buf, "{\"id\": %zu, \"name\": \"name%zu\", \"gender\": \"%s\", " "\"school\": {\"id\": %zu, \"name\": \"school%zu\"}}", - i, i, (i % 2) ? "male" : "female", i % 10, i % 10); + i, i, (i % 2) ? "male" : "female", i % 10, i % 10); data.emplace_back(std::string(buf, n)); } for (size_t i = 0; i < n_records; ++i) { diff --git a/tests/jsoncheck.cpp b/tests/jsoncheck.cpp index 5c51d692..d3d1dfaa 100644 --- a/tests/jsoncheck.cpp +++ b/tests/jsoncheck.cpp @@ -31,7 +31,6 @@ bool contains(const char *pre, const char *str) { return (strstr(str, pre) != nullptr); } - bool validate(const char *dirname) { bool everythingfine = true; const char *extension = ".json"; @@ -46,9 +45,10 @@ bool validate(const char *dirname) { printf("nothing in dir %s \n", dirname); return false; } - bool * isfileasexpected = new bool[c]; - for(int i = 0; i < c; i++) { isfileasexpected[i] = true; -} + bool *isfileasexpected = new bool[c]; + for (int i = 0; i < c; i++) { + isfileasexpected[i] = true; + } size_t howmany = 0; bool needsep = (strlen(dirname) > 1) && (dirname[strlen(dirname) - 1] != '/'); for (int i = 0; i < c; i++) { @@ -68,47 +68,50 @@ bool validate(const char *dirname) { padded_string p; try { get_corpus(fullpath).swap(p); - } catch (const std::exception& e) { + } catch (const std::exception &e) { std::cerr << "Could not load the file " << fullpath << std::endl; return EXIT_FAILURE; } ParsedJson pj; bool allocok = pj.allocateCapacity(p.size(), 1024); - if(!allocok) { - std::cerr << "can't allocate memory"<d_name); -} + fprintf(stderr, + "There were problems! Consider reviewing the following files:\n"); + for (int i = 0; i < c; i++) { + if (!isfileasexpected[i]) { + fprintf(stderr, "%s \n", entry_list[i]->d_name); + } } } for (int i = 0; i < c; ++i) { free(entry_list[i]); -} + } free(entry_list); delete[] isfileasexpected; return everythingfine; @@ -124,9 +127,8 @@ int main(int argc, char *argv[]) { << std::endl; return validate("jsonchecker/") ? EXIT_SUCCESS : EXIT_FAILURE; #else - std::cout - << "We are going to assume you mean to use the '"<< SIMDJSON_TEST_DATA_DIR <<"' directory." - << std::endl; + std::cout << "We are going to assume you mean to use the '" + << SIMDJSON_TEST_DATA_DIR << "' directory." << std::endl; return validate(SIMDJSON_TEST_DATA_DIR) ? EXIT_SUCCESS : EXIT_FAILURE; #endif } diff --git a/tests/numberparsingcheck.cpp b/tests/numberparsingcheck.cpp index 885cd142..3fcc22f0 100644 --- a/tests/numberparsingcheck.cpp +++ b/tests/numberparsingcheck.cpp @@ -30,7 +30,8 @@ bool startsWith(const char *pre, const char *str) { } bool is_in_bad_list(const char *buf) { - if(buf[0] != '0') return false; + if (buf[0] != '0') + return false; for (size_t i = 0; i < sizeof(really_bad) / sizeof(really_bad[0]); i++) if (startsWith(really_bad[i], buf)) return true; @@ -68,19 +69,22 @@ inline void foundFloat(double result, const uint8_t *buf) { float_count++; double expected = strtod((const char *)buf, &endptr); if (endptr == (const char *)buf) { - fprintf(stderr, "parsed %f from %.32s whereas strtod refuses to parse a float, ", - result, buf); + fprintf(stderr, + "parsed %f from %.32s whereas strtod refuses to parse a float, ", + result, buf); fprintf(stderr, " while parsing %s \n", fullpath); parse_error |= PARSE_ERROR; } - if( fpclassify(expected) != fpclassify(result) ) { - fprintf(stderr, "floats not in the same category expected: %f observed: %f \n", expected, result); + if (fpclassify(expected) != fpclassify(result)) { + fprintf(stderr, + "floats not in the same category expected: %f observed: %f \n", + expected, result); fprintf(stderr, "%.32s\n", buf); parse_error |= PARSE_ERROR; } // we want to get some reasonable relative accuracy - else if (fabs(expected - result) > - 1e-14 * fmin(fabs(expected), fabs(result))) { + else if (fabs(expected - result) > + 1e-14 * fmin(fabs(expected), fabs(result))) { fprintf(stderr, "parsed %.128e from \n", result); fprintf(stderr, " %.32s whereas strtod gives\n", buf); fprintf(stderr, " %.128e,", expected); @@ -131,7 +135,7 @@ bool validate(const char *dirname) { padded_string p; try { get_corpus(fullpath).swap(p); - } catch (const std::exception& e) { + } catch (const std::exception &e) { std::cout << "Could not load the file " << fullpath << std::endl; return EXIT_FAILURE; } @@ -172,12 +176,14 @@ int main(int argc, char *argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " " << std::endl; -#if defined(SIMDJSON_TEST_DATA_DIR) && defined(SIMDJSON_BENCHMARK_DATA_DIR) - std::cout - << "We are going to assume you mean to use the '"<< SIMDJSON_TEST_DATA_DIR <<"' and '"<< SIMDJSON_BENCHMARK_DATA_DIR <<"'directories." - << std::endl; - return validate(SIMDJSON_TEST_DATA_DIR) && validate(SIMDJSON_BENCHMARK_DATA_DIR) ? EXIT_SUCCESS - : EXIT_FAILURE; +#if defined(SIMDJSON_TEST_DATA_DIR) && defined(SIMDJSON_BENCHMARK_DATA_DIR) + std::cout << "We are going to assume you mean to use the '" + << SIMDJSON_TEST_DATA_DIR << "' and '" + << SIMDJSON_BENCHMARK_DATA_DIR << "'directories." << std::endl; + return validate(SIMDJSON_TEST_DATA_DIR) && + validate(SIMDJSON_BENCHMARK_DATA_DIR) + ? EXIT_SUCCESS + : EXIT_FAILURE; #else std::cout << "We are going to assume you mean to use the 'jsonchecker' and " "'jsonexamples' directories." diff --git a/tests/singleheadertest.cpp b/tests/singleheadertest.cpp index 76f1ee16..87e93369 100644 --- a/tests/singleheadertest.cpp +++ b/tests/singleheadertest.cpp @@ -1,14 +1,14 @@ -#include #include "../singleheader/simdjson.h" +#include int main() { - const char * filename = JSON_TEST_PATH; + const char *filename = JSON_TEST_PATH; padded_string p = get_corpus(filename); ParsedJson pj = build_parsed_json(p); // do the parsing - if( ! pj.isValid() ) { + if (!pj.isValid()) { return EXIT_FAILURE; } - if( ! pj.allocateCapacity(p.size()) ) { + if (!pj.allocateCapacity(p.size())) { return EXIT_FAILURE; } const int res = json_parse(p, pj); diff --git a/tests/stringparsingcheck.cpp b/tests/stringparsingcheck.cpp index 38ea57e9..88e3521d 100644 --- a/tests/stringparsingcheck.cpp +++ b/tests/stringparsingcheck.cpp @@ -2,11 +2,11 @@ #include #include #include +#include #include #include #include #include -#include #ifndef JSON_TEST_STRINGS #define JSON_TEST_STRINGS @@ -201,7 +201,7 @@ static bool parse_string(const char *p, char *output, char **end) { } } // end of borrowed code -char * bigbuffer; // global variable +char *bigbuffer; // global variable inline void foundBadString(const uint8_t *buf) { bad_string++; @@ -328,18 +328,18 @@ bool validate(const char *dirname) { padded_string p; try { get_corpus(fullpath).swap(p); - } catch (const std::exception& e) { + } catch (const std::exception &e) { std::cout << "Could not load the file " << fullpath << std::endl; return EXIT_FAILURE; - } + } ParsedJson pj; bool allocok = pj.allocateCapacity(p.size(), 1024); if (!allocok) { std::cerr << "can't allocate memory" << std::endl; return false; } - bigbuffer = (char *) malloc(p.size()); - if(bigbuffer == NULL) { + bigbuffer = (char *)malloc(p.size()); + if (bigbuffer == NULL) { std::cerr << "can't allocate memory" << std::endl; return false; } @@ -380,12 +380,14 @@ int main(int argc, char *argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " " << std::endl; -#if defined(SIMDJSON_TEST_DATA_DIR) && defined(SIMDJSON_BENCHMARK_DATA_DIR) - std::cout - << "We are going to assume you mean to use the '"<< SIMDJSON_TEST_DATA_DIR <<"' and '"<< SIMDJSON_BENCHMARK_DATA_DIR <<"'directories." - << std::endl; - return validate(SIMDJSON_TEST_DATA_DIR) && validate(SIMDJSON_BENCHMARK_DATA_DIR) ? EXIT_SUCCESS - : EXIT_FAILURE; +#if defined(SIMDJSON_TEST_DATA_DIR) && defined(SIMDJSON_BENCHMARK_DATA_DIR) + std::cout << "We are going to assume you mean to use the '" + << SIMDJSON_TEST_DATA_DIR << "' and '" + << SIMDJSON_BENCHMARK_DATA_DIR << "'directories." << std::endl; + return validate(SIMDJSON_TEST_DATA_DIR) && + validate(SIMDJSON_BENCHMARK_DATA_DIR) + ? EXIT_SUCCESS + : EXIT_FAILURE; #else std::cout << "We are going to assume you mean to use the 'jsonchecker' and " "'jsonexamples' directories."