wcmp.cpp 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  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'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
  16. }
  17. if (ans.seekEof() && ouf.seekEof())
  18. {
  19. if (n == 1)
  20. quitf(_ok, "\"%s\"", compress(j).c_str());
  21. else
  22. quitf(_ok, "%d tokens", n);
  23. }
  24. else
  25. {
  26. if (ans.seekEof())
  27. quitf(_wa, "Participant output contains extra tokens");
  28. else
  29. quitf(_wa, "Unexpected EOF in the participants output");
  30. }
  31. }