fcmp.cpp 808 B

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