Merge branch 'master' of git.ucc.asn.au:/ipdf/code
[ipdf/code.git] / src / tests / realops.cpp
index 8076a14..83a5241 100644 (file)
@@ -4,11 +4,15 @@
 using namespace std;
 using namespace IPDF;
 
-#define TEST_CASES 100
+#define TEST_CASES 1000
 
-bool NotEqual(double a, double b, double threshold=1e-2)
+static double g_totalerror = 0;
+
+bool NotEqual(double a, double b, double threshold=1e-1)
 {
-       return (fabs(a-b) > threshold);
+       double error = (fabs(a-b) > threshold);
+       g_totalerror += error;
+       return (error > threshold);
 }
 
 int main(int argc, char ** argv)
@@ -18,8 +22,9 @@ int main(int argc, char ** argv)
        unsigned failures = 0;
        for (unsigned i = 0; i < TEST_CASES; ++i)
        {
-               double da = (double)(rand()%100 + 1) / (double)(rand()%100 + 1);
-               double db = (double)(rand()%100 + 1) / (double)(rand()%100 + 1);
+               //Debug("Test %u of %u", i, TEST_CASES);
+               double da = (double)(rand() + 1) / (double)(rand() + 1);
+               double db = (double)(rand() + 1) / (double)(rand() + 1);
                
                if (rand() % 2 == 0)
                        da = -da;
@@ -117,5 +122,6 @@ int main(int argc, char ** argv)
                }
        }
        Debug("Completed %u test cases with total of %u operations, %u failures", TEST_CASES, 12*TEST_CASES, failures);
+       Debug("Total accumulated difference between Real and Double operations was %f", g_totalerror);
 
 }

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