rcmp6.cpp 803 B

1234567891011121314151617181920212223242526272829303132
  1. #include "testlib.h"
  2. #include <cmath>
  3. using namespace std;
  4. const double EPS = 1E-6;
  5. int main(int argc, char * argv[])
  6. {
  7. setName("compare two sequences of doubles, max absolute or relative error = %.7f", 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: '%.7f', found: '%.7f', error = '%.7f'",
  19. n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
  20. }
  21. }
  22. if (n == 1)
  23. quitf(_ok, "found '%.7f', expected '%.7f', error '%.7f'", p, j, doubleDelta(j, p));
  24. quitf(_ok, "%d numbers", n);
  25. }