1818#include " test_macros.h"
1919
2020const size_t AMAZON_CELLPHONES_NDJSON_DOC_COUNT = 793 ;
21+ #define SIMDJSON_SHOW_DEFINE (x ) printf(" %s=%s\n " , #x, STRINGIFY (x))
2122
2223namespace number_tests {
2324
@@ -68,7 +69,9 @@ namespace number_tests {
6869 uint64_t ulp = f64_ulp_dist (actual,expected);
6970 if (ulp > maxulp) maxulp = ulp;
7071 if (ulp > 0 ) {
71- std::cerr << " JSON '" << buf << " parsed to " << actual << " instead of " << expected << std::endl;
72+ std::cerr << " JSON '" << buf << " parsed to " ;
73+ fprintf ( stderr," %18.18g instead of %18.18g\n " , actual, expected); // formatting numbers is easier with printf
74+ SIMDJSON_SHOW_DEFINE (FLT_EVAL_METHOD );
7275 return false ;
7376 }
7477 }
@@ -152,18 +155,25 @@ namespace number_tests {
152155 std::cout << __func__ << std::endl;
153156 char buf[1024 ];
154157 simdjson::dom::parser parser;
155- for (int i = -1000000 ; i <= 308 ; ++i) {// large negative values should be zero.
158+
159+ bool is_pow_correct{1e-308 == std::pow (10 ,-308 )};
160+ int start_point = is_pow_correct ? -10000 : -307 ;
161+ if (!is_pow_correct) {
162+ std::cout << " On your system, the pow function is busted. Sorry about that. " << std::endl;
163+ }
164+ for (int i = start_point; i <= 308 ; ++i) {// large negative values should be zero.
156165 size_t n = snprintf (buf, sizeof (buf), " 1e%d" , i);
157166 if (n >= sizeof (buf)) { abort (); }
158167 fflush (NULL );
159-
160168 double actual;
161169 auto error = parser.parse (buf, n).get (actual);
162170 if (error) { std::cerr << error << std::endl; return false ; }
163171 double expected = ((i >= -307 ) ? testing_power_of_ten[i + 307 ]: std::pow (10 , i));
164172 int ulp = (int ) f64_ulp_dist (actual, expected);
165173 if (ulp > 0 ) {
166- std::cerr << " JSON '" << buf << " parsed to " << actual << " instead of " << expected << std::endl;
174+ std::cerr << " JSON '" << buf << " parsed to " ;
175+ fprintf ( stderr," %18.18g instead of %18.18g\n " , actual, expected); // formatting numbers is easier with printf
176+ SIMDJSON_SHOW_DEFINE (FLT_EVAL_METHOD );
167177 return false ;
168178 }
169179 }
@@ -1924,6 +1934,7 @@ namespace format_tests {
19241934 }
19251935}
19261936
1937+
19271938int main (int argc, char *argv[]) {
19281939 std::cout << std::unitbuf;
19291940 int c;
@@ -1949,6 +1960,11 @@ int main(int argc, char *argv[]) {
19491960 if (simdjson::active_implementation->name () == " unsupported" ) {
19501961 printf (" unsupported CPU\n " );
19511962 }
1963+ // We want to know what we are testing.
1964+ std::cout << " Running tests against this implementation: " << simdjson::active_implementation->name ();
1965+ std::cout << " (" << simdjson::active_implementation->description () << " )" << std::endl;
1966+ std::cout << " ------------------------------------------------------------" << std::endl;
1967+
19521968 std::cout << " Running basic tests." << std::endl;
19531969 if (validate_tests::run () &&
19541970 minify_tests::run () &&
0 commit comments