fcmp.cpp 776 B

123456789101112131415161718192021222324252627282930313233
  1. #include "testlib.h"
  2. #include <string>
  3. using namespace std;
  4. int main(int argc, char *argv[]) {
  5. setName("compare files as sequence of lines");
  6. registerTestlibCmd(argc, argv);
  7. std::string strAnswer;
  8. int n = 0;
  9. while (!ans.eof()) {
  10. std::string j = ans.readString();
  11. if (j.empty() && ans.eof())
  12. break;
  13. strAnswer = j;
  14. std::string p = ouf.readString();
  15. n++;
  16. if (j != p)
  17. quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
  18. compress(j).c_str(), compress(p).c_str());
  19. }
  20. if (n == 1)
  21. quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
  22. quitf(_ok, "%d lines", n);
  23. }