yesno.cpp 814 B

1234567891011121314151617181920212223242526
  1. #include "testlib.h"
  2. #include <string>
  3. using namespace std;
  4. const string YES = "YES";
  5. const string NO = "NO";
  6. int main(int argc, char *argv[]) {
  7. setName("%s", (YES + " or " + NO + " (case insensitive)").c_str());
  8. registerTestlibCmd(argc, argv);
  9. std::string ja = upperCase(ans.readWord());
  10. std::string pa = upperCase(ouf.readWord());
  11. if (ja != YES && ja != NO)
  12. quitf(_fail, "%s or %s expected in answer, but %s found", YES.c_str(), NO.c_str(), compress(ja).c_str());
  13. if (pa != YES && pa != NO)
  14. quitf(_pe, "%s or %s expected, but %s found", YES.c_str(), NO.c_str(), compress(pa).c_str());
  15. if (ja != pa)
  16. quitf(_wa, "expected %s, found %s", compress(ja).c_str(), compress(pa).c_str());
  17. quitf(_ok, "answer is %s", ja.c_str());
  18. }