5 unsigned test_count = 100;
6 float error_thresh = (test_max - test_min)/1e1;
7 int main(int argc, char ** argv)
9 Debug("TEST STARTING - Comparing Float(Real(test)) for %u trials between %.20f and %.20f", test_count, test_min, test_max);
11 for (unsigned i = 0; i < test_count; ++i)
13 float test = test_min + (test_max-test_min)*((float)(rand() % (int)1e6)/1e6);
15 float thiserror = abs(test - Float(real));
17 Debug("#%u: |test %.20f - real %.20f| = %.20f [mean %f]", i, test, Float(real), thiserror, error/(i+1));
20 if (error/test_count > error_thresh)
22 Fatal("TEST FAILED - Average error %.20f exceeds threshold %.20f", error/test_count, error_thresh);
24 Debug("TEST SUCCEEDED - Average error %.20f is %f percent of range", error/test_count, 1e2*(error/test_count) / (test_max - test_min));