aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/uri/location_ut.cpp
blob: 26a0f644711f6a1843081b2e2c4af5afb173c98e (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
29
30
31
32
33
34
35
36
37
38
39
40
#include "location.h"

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

Y_UNIT_TEST_SUITE(TResolveRedirectTests) {
    Y_UNIT_TEST(Absolute) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub"), "http://redir-example.com/sub");
    }
    Y_UNIT_TEST(AbsWithFragment) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#Hello"), "http://redir-example.com/sub#Hello");
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com/#Hello", "http://redir-example.com/sub"), "http://redir-example.com/sub#Hello");
    }
    Y_UNIT_TEST(Rel) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", "/sub"), "http://example.com/sub");
    }
    Y_UNIT_TEST(RelWithFragment) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", "/sub#Hello"), "http://example.com/sub#Hello");
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com/#Hello", "/sub"), "http://example.com/sub#Hello");
    }
    Y_UNIT_TEST(WrongLocation) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", ""), "");
    }
    Y_UNIT_TEST(WrongBase) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("", "http://example.com"), "");
    }
    Y_UNIT_TEST(HashBangIsNothingSpecial) {
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com", "http://redir-example.com/sub#!Hello"), "http://redir-example.com/sub#!Hello");
        UNIT_ASSERT_EQUAL(
            NUri::ResolveRedirectLocation("http://example.com/#!Hello", "http://redir-example.com/sub"), "http://redir-example.com/sub#!Hello");
    }
}