parsed_request_ut.cpp 716 B

12345678910111213141516171819202122232425262728
  1. #include "parsed_request.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(THttpParse) {
  4. Y_UNIT_TEST(TestParse) {
  5. TParsedHttpFull h("GET /yandsearch?text=nokia HTTP/1.1");
  6. UNIT_ASSERT_EQUAL(h.Method, "GET");
  7. UNIT_ASSERT_EQUAL(h.Request, "/yandsearch?text=nokia");
  8. UNIT_ASSERT_EQUAL(h.Proto, "HTTP/1.1");
  9. UNIT_ASSERT_EQUAL(h.Path, "/yandsearch");
  10. UNIT_ASSERT_EQUAL(h.Cgi, "text=nokia");
  11. }
  12. Y_UNIT_TEST(TestError) {
  13. bool wasError = false;
  14. try {
  15. TParsedHttpFull("GET /yandsearch?text=nokiaHTTP/1.1");
  16. } catch (...) {
  17. wasError = true;
  18. }
  19. UNIT_ASSERT(wasError);
  20. }
  21. }