aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/misc/parsed_request_ut.cpp
blob: 095c7e59c8b6a0e091770d6d1ff65d1c8a7fa300 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "parsed_request.h"

#include <library/cpp/testing/unittest/registar.h>

Y_UNIT_TEST_SUITE(THttpParse) { 
    Y_UNIT_TEST(TestParse) { 
        TParsedHttpFull h("GET /yandsearch?text=nokia HTTP/1.1");

        UNIT_ASSERT_EQUAL(h.Method, "GET");
        UNIT_ASSERT_EQUAL(h.Request, "/yandsearch?text=nokia");
        UNIT_ASSERT_EQUAL(h.Proto, "HTTP/1.1");

        UNIT_ASSERT_EQUAL(h.Path, "/yandsearch");
        UNIT_ASSERT_EQUAL(h.Cgi, "text=nokia");
    }

    Y_UNIT_TEST(TestError) { 
        bool wasError = false;

        try {
            TParsedHttpFull("GET /yandsearch?text=nokiaHTTP/1.1");
        } catch (...) {
            wasError = true;
        }

        UNIT_ASSERT(wasError);
    }
}