wcmp.cpp 932 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. int n = 0;
  8. string j, p;
  9. while (!ans.seekEof() && !ouf.seekEof())
  10. {
  11. n++;
  12. ans.readWordTo(j);
  13. ouf.readWordTo(p);
  14. if (j != p)
  15. quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'",
  16. n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
  17. }
  18. if (ans.seekEof() && ouf.seekEof())
  19. {
  20. if (n == 1)
  21. quitf(_ok, "\"%s\"", compress(j).c_str());
  22. else
  23. quitf(_ok, "%d words", n);
  24. }
  25. else
  26. {
  27. if (ans.seekEof())
  28. quitf(_wa, "Participant output contains extra tokens");
  29. else
  30. quitf(_wa, "Unexpected EOF in the participants output");
  31. }
  32. }