aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/uri/location_ut.cpp
blob: 26a0f644711f6a1843081b2e2c4af5afb173c98e (plain) (tree)
1
2
3
4
5
6
7
8
9
                     
                                                  
 
                                          
                          
                                                                                                                                 
     
                                  
                          
                                                                                                                                             
                          
                                                                                                                                              
     
                      
                          
                                                                                                   
     
                                  
                          
                                                                                                               
                          
                                                                                                                
     
                                
                          
                                                                         
     
                            
                          
                                                                         
     
                                           
                          
                                                                                                                                               
                          
                                                                                                                                                
     
#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");
    }
}