Changeset 1fc2958 for tests


Ignore:
Timestamp:
2006-06-16T12:07:51Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
125b35d
Parents:
c2fa827
Message:

Add checks for nick functions as well, fix bug where nick lengths weren't
being honored.

Location:
tests
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • tests/Makefile

    rc2fa827 r1fc2958  
    66        ./check
    77
    8 check: check.o check_util.o ../util.o
     8main_objs = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o
     9
     10check: check.o check_util.o check_nick.o $(addprefix ../, $(main_objs)) ../protocols/protocols.o
    911        @echo '*' Linking $@
    1012        @$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS)
  • tests/check.c

    rc2fa827 r1fc2958  
    33#include <gmodule.h>
    44#include <check.h>
     5#include "bitlbee.h"
     6
     7global_t global;        /* Against global namespace pollution */
     8
     9double gettime()
     10{
     11        struct timeval time[1];
     12
     13        gettimeofday( time, 0 );
     14        return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
     15}
    516
    617/* From check_util.c */
    718Suite *util_suite(void);
     19
     20/* From check_nick.c */
     21Suite *nick_suite(void);
    822
    923int main (void)
     
    1125        int nf;
    1226        SRunner *sr = srunner_create(util_suite());
     27        srunner_add_suite(sr, nick_suite());
    1328        srunner_run_all (sr, CK_NORMAL);
    1429        nf = srunner_ntests_failed(sr);
  • tests/check_util.c

    rc2fa827 r1fc2958  
    2525END_TEST
    2626
     27START_TEST(test_strip_newlines)
     28{
     29        int i;
     30        const char *get[] = { "Test", "Test\r\n", "Test\nX\n", NULL };
     31        const char *expected[] = { "Test", "Test  ", "Test X ", NULL };
     32
     33        for (i = 0; get[i]; i++) {
     34                char copy[20], *ret;
     35                strcpy(copy, get[i]);
     36                ret = strip_newlines(copy);
     37                fail_unless (strcmp(copy, expected[i]) == 0,
     38                                         "(%d) strip_newlines broken: %s -> %s (expected: %s)",
     39                                         i, get[i], copy, expected[i]);
     40                fail_unless (copy == ret, "Original string not returned");
     41        }
     42}
     43END_TEST
     44
    2745Suite *util_suite (void)
    2846{
     
    3149        suite_add_tcase (s, tc_core);
    3250        tcase_add_test (tc_core, test_strip_linefeed);
     51        tcase_add_test (tc_core, test_strip_newlines);
    3352        return s;
    3453}
Note: See TracChangeset for help on using the changeset viewer.