X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Ftests%2Fstresstest.cpp;fp=src%2Ftests%2Fstresstest.cpp;h=4f757ca70b477c4f64bdade9253ec39256accb17;hb=03cc1b0a0d0705e0b1d92e13fdb18608c7a00272;hp=0000000000000000000000000000000000000000;hpb=ea748154f1bc7dbc81cb52611a52865e63109439;p=ipdf%2Fcode.git diff --git a/src/tests/stresstest.cpp b/src/tests/stresstest.cpp new file mode 100644 index 0000000..4f757ca --- /dev/null +++ b/src/tests/stresstest.cpp @@ -0,0 +1,38 @@ +#include "stresstest.h" +#include "real.h" +#include "progressbar.h" + +using namespace std; +using namespace IPDF; + +int main(int argc, char ** argv) +{ + Debug("Repeated Adds and Subtracts - Should give zero"); + + for (int i = 1; i < 100; ++i) + { + for (int j = 1; j < 100; ++j) + { + Real result = AddSub(0, i, Real(1)/Real(j)); + if (result != Real(0)) + Warn("Result of %lf != %lf (zero)", Double(result), 0.0); + + printf("%d\t%lf\t%lf", i, Real(1)/Real(j), Double(result)); + } + } + + Debug("Repeated Multiplications and Divisions - Should give one"); + for (int i = 1; i < 100; ++i) + { + for (int j = 1; j < 100; ++j) + { + Real result = MulDiv(1, i, Real(1)/Real(j)); + if (result != Real(1)) + Warn("Result of %lf != %lf (one)", Double(result), 1.0); + + printf("%d\t%lf\t%lf", i, Real(1)/Real(j), Double(result)); + } + } + +} +