Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/check_util.c

    r7bee5af r2c7df62  
    77#include "set.h"
    88#include "misc.h"
    9 #include "url.h"
    109
    1110START_TEST(test_strip_linefeed)
     
    4443END_TEST
    4544
    46 START_TEST(test_set_url_http)
    47         url_t url;
    48        
    49         fail_if (0 == url_set(&url, "http://host/"));
    50         fail_unless (!strcmp(url.host, "host"));
    51         fail_unless (!strcmp(url.file, "/"));
    52         fail_unless (!strcmp(url.user, ""));
    53         fail_unless (!strcmp(url.pass, ""));
    54         fail_unless (url.proto == PROTO_HTTP);
    55         fail_unless (url.port == 80);
    56 END_TEST
    57 
    58 START_TEST(test_set_url_https)
    59         url_t url;
    60        
    61         fail_if (0 == url_set(&url, "https://ahost/AimeeMann"));
    62         fail_unless (!strcmp(url.host, "ahost"));
    63         fail_unless (!strcmp(url.file, "/AimeeMann"));
    64         fail_unless (!strcmp(url.user, ""));
    65         fail_unless (!strcmp(url.pass, ""));
    66         fail_unless (url.proto == PROTO_HTTPS);
    67         fail_unless (url.port == 443);
    68 END_TEST
    69 
    70 START_TEST(test_set_url_port)
    71         url_t url;
    72        
    73         fail_if (0 == url_set(&url, "https://ahost:200/Lost/In/Space"));
    74         fail_unless (!strcmp(url.host, "ahost"));
    75         fail_unless (!strcmp(url.file, "/Lost/In/Space"));
    76         fail_unless (!strcmp(url.user, ""));
    77         fail_unless (!strcmp(url.pass, ""));
    78         fail_unless (url.proto == PROTO_HTTPS);
    79         fail_unless (url.port == 200);
    80 END_TEST
    81 
    82 START_TEST(test_set_url_username)
    83         url_t url;
    84        
    85         fail_if (0 == url_set(&url, "socks4://user@ahost/Space"));
    86         fail_unless (!strcmp(url.host, "ahost"));
    87         fail_unless (!strcmp(url.file, "/Space"));
    88         fail_unless (!strcmp(url.user, "user"));
    89         fail_unless (!strcmp(url.pass, ""));
    90         fail_unless (url.proto == PROTO_SOCKS4);
    91         fail_unless (url.port == 1080);
    92 END_TEST
    93 
    94 START_TEST(test_set_url_username_pwd)
    95         url_t url;
    96        
    97         fail_if (0 == url_set(&url, "socks5://user:pass@ahost/"));
    98         fail_unless (!strcmp(url.host, "ahost"));
    99         fail_unless (!strcmp(url.file, "/"));
    100         fail_unless (!strcmp(url.user, "user"));
    101         fail_unless (!strcmp(url.pass, "pass"));
    102         fail_unless (url.proto == PROTO_SOCKS5);
    103         fail_unless (url.port == 1080);
    104 END_TEST
    105 
    10645Suite *util_suite (void)
    10746{
     
    11150        tcase_add_test (tc_core, test_strip_linefeed);
    11251        tcase_add_test (tc_core, test_strip_newlines);
    113         tcase_add_test (tc_core, test_set_url_http);
    114         tcase_add_test (tc_core, test_set_url_https);
    115         tcase_add_test (tc_core, test_set_url_port);
    116         tcase_add_test (tc_core, test_set_url_username);
    117         tcase_add_test (tc_core, test_set_url_username_pwd);
    11852        return s;
    11953}
Note: See TracChangeset for help on using the changeset viewer.