1
0

rcmp4.cpp 819 B

123456789101112131415161718192021222324252627282930313233
  1. #include "testlib.h"
  2. #include <cmath>
  3. using namespace std;
  4. const double EPS = 1E-4;
  5. int main(int argc, char * argv[])
  6. {
  7. setName("compare two sequences of doubles, max absolute or relative error = %.5lf", EPS);
  8. registerTestlibCmd(argc, argv);
  9. int n = 0;
  10. double j, p;
  11. while (!ans.seekEof())
  12. {
  13. n++;
  14. j = ans.readDouble();
  15. p = ouf.readDouble();
  16. if (!doubleCompare(j, p, EPS))
  17. {
  18. quitf(_wa, "%d%s numbers differ - expected: '%.5lf', found: '%.5lf', error = '%.5lf'",
  19. n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
  20. }
  21. }
  22. quitif(n == 1,
  23. _ok, "found '%.5lf', expected '%.5lf', error '%.5lf'",
  24. p, j, doubleDelta(j, p));
  25. quitf(_ok, "%d numbers", n);
  26. }