rcmp9.cpp 784 B

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