Changeset ae3c4fa for tests


Ignore:
Timestamp:
2007-07-01T14:52:45Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
19a8088
Parents:
f7b44f2 (diff), 348c11b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from Jelmer (mainly unit testing things).

Location:
tests
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • tests/Makefile

    rf7b44f2 rae3c4fa  
    1313main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o
    1414
    15 test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o
     15test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o
    1616
    1717check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o
  • tests/check.c

    rf7b44f2 rae3c4fa  
    2121}
    2222
     23irc_t *torture_irc(void)
     24{
     25        irc_t *irc;
     26        GIOChannel *ch1, *ch2;
     27        if (!g_io_channel_pair(&ch1, &ch2))
     28                return NULL;
     29        irc = irc_new(g_io_channel_unix_get_fd(ch1));
     30        return irc;
     31}
     32
    2333double gettime()
    2434{
     
    4050/* From check_irc.c */
    4151Suite *irc_suite(void);
     52
     53/* From check_help.c */
     54Suite *help_suite(void);
     55
     56/* From check_user.c */
     57Suite *user_suite(void);
     58
     59/* From check_crypting.c */
     60Suite *crypting_suite(void);
     61
     62/* From check_set.c */
     63Suite *set_suite(void);
    4264
    4365int main (int argc, char **argv)
     
    6789        if (verbose) {
    6890                log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );
     91#ifdef DEBUG
    6992                log_link( LOGLVL_DEBUG, LOGOUTPUT_CONSOLE );
     93#endif
    7094                log_link( LOGLVL_INFO, LOGOUTPUT_CONSOLE );
    7195                log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );
     
    79103        srunner_add_suite(sr, md5_suite());
    80104        srunner_add_suite(sr, irc_suite());
     105        srunner_add_suite(sr, help_suite());
     106        srunner_add_suite(sr, user_suite());
     107        srunner_add_suite(sr, crypting_suite());
     108        srunner_add_suite(sr, set_suite());
    81109        if (no_fork)
    82110                srunner_set_fork_status(sr, CK_NOFORK);
  • tests/check_util.c

    rf7b44f2 rae3c4fa  
    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}
  • tests/testsuite.h

    rf7b44f2 rae3c4fa  
    22#define __BITLBEE_CHECK_H__
    33
     4#include "irc.h"
     5
     6irc_t *torture_irc(void);
    47gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2);
    58
Note: See TracChangeset for help on using the changeset viewer.