wcmp.cpp 902 B

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