X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Ftests%2Frealops.cpp;h=dd45aa8dbd58a36f27bdaae9ff6bdc100144808b;hp=b9ce4414c0213842d67b9a849bdde3107a3731e4;hb=1d179b93f6a1b2a4fe3823c26fba862c24bc5d6e;hpb=8c88a35a1fb0dfc9e542bb1a1c13c5f3e36eb3e5 diff --git a/src/tests/realops.cpp b/src/tests/realops.cpp index b9ce441..dd45aa8 100644 --- a/src/tests/realops.cpp +++ b/src/tests/realops.cpp @@ -1,3 +1,7 @@ +/** + * Test mathematical operations on the Real type and consistency with double + */ + #include "main.h" #include "real.h" @@ -8,7 +12,7 @@ using namespace IPDF; static double g_totalerror = 0; -bool NotEqual(double a, double b, double threshold=1e-1) +bool NotEqual(double a, double b, double threshold=1e-4) { double error = fabs(a-b); g_totalerror += error; @@ -18,6 +22,7 @@ bool NotEqual(double a, double b, double threshold=1e-1) int main(int argc, char ** argv) { srand(time(NULL)); + DebugRealInfo(); unsigned failures = 0; for (unsigned i = 0; i < TEST_CASES; ++i) @@ -111,7 +116,18 @@ int main(int argc, char ** argv) { failures++; Warn("a /= b = %f should be %f, a before op was %f", Double(a), da, Double(abeforeop)); + } + if (NotEqual(Double(a*0.0 + 1.0), da*0.0 + 1.0)) + { + failures++; + Warn("a * 0 = %f should be %f, a before op was %f", Double(a), da, Double(abeforeop)); } + + if (NotEqual(Double(a=b), da=db)) + { + failures++; + Warn("a = b = %f should be %f, a before op was %f", Double(a), da, Double(abeforeop)); + } if (failures > old_failures) {