1
0

wcmp.cpp 977 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "testlib.h"
  2. using namespace std;
  3. int main(int argc, char * argv[])
  4. {
  5. setName("compare sequences of tokens");
  6. registerTestlibCmd(argc, argv);
  7. std::string strAnswer;
  8. int n = 0;
  9. while (!ans.seekEof() && !ouf.seekEof())
  10. {
  11. n++;
  12. std::string j = ans.readWord();
  13. std::string p = ouf.readWord();
  14. strAnswer = p;
  15. quitif(j != p,
  16. _wa, "%d%s words differ - expected: '%s', found: '%s'",
  17. n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
  18. }
  19. if (ans.seekEof() && ouf.seekEof())
  20. {
  21. if (n == 1)
  22. quitf(_ok, "%s", compress(strAnswer).c_str());
  23. else
  24. quitf(_ok, "%d words", n);
  25. }
  26. else
  27. {
  28. if (ans.seekEof())
  29. quitf(_wa, "Participant output contains extra tokens");
  30. else
  31. quitf(_wa, "Unexpected EOF in the participants output");
  32. }
  33. }