diff --git a/tests/numberparsingcheck.cpp b/tests/numberparsingcheck.cpp index 95c3aeae..d9af9967 100644 --- a/tests/numberparsingcheck.cpp +++ b/tests/numberparsingcheck.cpp @@ -10,7 +10,7 @@ #ifndef JSON_TEST_NUMBERS #define JSON_TEST_NUMBERS -#endif +#endif #include "jsonparser/common_defs.h" @@ -18,7 +18,12 @@ int parse_error; char *fullpath; enum{PARSE_WARNING, PARSE_ERROR}; +size_t float_count; +size_t int_count; +size_t invalid_count; + inline void foundInvalidNumber(const u8 * buf) { + invalid_count++; char * endptr; double expected = strtod((char *)buf, &endptr); if(endptr != (char *)buf) { @@ -29,6 +34,7 @@ inline void foundInvalidNumber(const u8 * buf) { } inline void foundInteger(int64_t result, const u8 * buf) { + int_count++; char * endptr; long long expected = strtoll((char *)buf, & endptr, 10); if((endptr == (char *)buf) || (expected != result)) { @@ -40,9 +46,10 @@ inline void foundInteger(int64_t result, const u8 * buf) { inline void foundFloat(double result, const u8 * buf) { char * endptr; + float_count++; double expected = strtod((char *)buf, &endptr); if(endptr == (char *)buf) { - printf("parsed %f from %.32s whereas strtod refuses to parse a float, ", result, buf); + printf("parsed %f from %.32s whereas strtod refuses to parse a float, ", result, buf); printf(" while parsing %s \n", fullpath); parse_error |= PARSE_ERROR; } @@ -107,11 +114,17 @@ bool validate(const char *dirname) { std::cerr<< "can't allocate memory"< 0) { + printf("File %40s %s --- integers: %10zu floats: %10zu invalid: %10zu total numbers: %10zu \n", name, + isok ? " is valid " : + " is not valid ",int_count, float_count, invalid_count, int_count+float_count+invalid_count); + } free(p.first); free(fullpath); deallocate_ParsedJson(pj_ptr);