Bezier bounds rectangles are calculated correctly
[ipdf/code.git] / src / tests / realtofloat.cpp
1 #include "main.h"
2 #include <cmath>
3 float test_min = 0;
4 float test_max = 1e-6;
5 unsigned test_count = 100;
6 float error_thresh = (test_max - test_min)/1e1;
7 int main(int argc, char ** argv)
8 {
9         Debug("TEST STARTING - Comparing Float(Real(test)) for %u trials between %.20f and %.20f", test_count, test_min, test_max);
10         float error;
11         for (unsigned i = 0; i < test_count; ++i)
12         {
13                 float test = test_min + (test_max-test_min)*((float)(rand() % (int)1e6)/1e6);
14                 Real real(test);
15                 float thiserror = abs(test - Float(real));
16                 error += thiserror;
17                 Debug("#%u: |test %.20f - real %.20f| = %.20f [mean %f]", i, test, Float(real), thiserror, error/(i+1));
18         }
19
20         if (error/test_count > error_thresh)
21         {
22                 Fatal("TEST FAILED - Average error %.20f exceeds threshold %.20f", error/test_count, error_thresh);
23         }
24         Debug("TEST SUCCEEDED - Average error %.20f is %f percent of range", error/test_count, 1e2*(error/test_count) / (test_max - test_min));
25         return 0;
26 }

UCC git Repository :: git.ucc.asn.au