Changeset 7bee5af


Ignore:
Timestamp:
2006-12-24T21:47:18Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
ed5df81
Parents:
c227706
Message:

Add tests for set_url(). Fixed a bug where the default port wasn't
set when socks5 was used.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/url.c

    rc227706 r7bee5af  
    100100                else if( url->proto == PROTO_HTTPS )
    101101                        url->port = 443;
    102                 else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS4 )
     102                else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS5 )
    103103                        url->port = 1080;
    104104        }
  • set.h

    rc227706 r7bee5af  
    2323  Suite 330, Boston, MA  02111-1307  USA
    2424*/
     25
     26#ifndef __SET_H__
     27#define __SET_H__
    2528
    2629/* This used to be specific to irc_t structures, but it's more generic now
     
    8891char *set_eval_ops( set_t *set, char *value );
    8992char *set_eval_charset( set_t *set, char *value );
     93
     94#endif /* __SET_H__ */
  • tests/check_util.c

    rc227706 r7bee5af  
    77#include "set.h"
    88#include "misc.h"
     9#include "url.h"
    910
    1011START_TEST(test_strip_linefeed)
     
    4344END_TEST
    4445
     46START_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);
     56END_TEST
     57
     58START_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);
     68END_TEST
     69
     70START_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);
     80END_TEST
     81
     82START_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);
     92END_TEST
     93
     94START_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);
     104END_TEST
     105
    45106Suite *util_suite (void)
    46107{
     
    50111        tcase_add_test (tc_core, test_strip_linefeed);
    51112        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);
    52118        return s;
    53119}
Note: See TracChangeset for help on using the changeset viewer.