source: tests/check_irc.c @ 8bcd160

Last change on this file since 8bcd160 was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include <stdlib.h>
2#include <glib.h>
3#include <gmodule.h>
4#include <check.h>
5#include <string.h>
6#include <stdio.h>
7#include "irc.h"
8#include "testsuite.h"
9
10START_TEST(test_connect)
11GIOChannel * ch1, *ch2;
12irc_t *irc;
13char *raw;
14fail_unless(g_io_channel_pair(&ch1, &ch2));
15
16irc = irc_new(g_io_channel_unix_get_fd(ch1));
17
18irc_free(irc);
19
20fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
21
22fail_if(strcmp(raw, "") != 0);
23
24g_free(raw);
25END_TEST
26
27START_TEST(test_login)
28GIOChannel * ch1, *ch2;
29irc_t *irc;
30char *raw;
31fail_unless(g_io_channel_pair(&ch1, &ch2));
32
33g_io_channel_set_flags(ch1, G_IO_FLAG_NONBLOCK, NULL);
34g_io_channel_set_flags(ch2, G_IO_FLAG_NONBLOCK, NULL);
35
36irc = irc_new(g_io_channel_unix_get_fd(ch1));
37
38fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\r\n"
39                                     "USER a a a a\n", -1, NULL, NULL) == G_IO_STATUS_NORMAL);
40fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL);
41
42g_main_iteration(FALSE);
43irc_free(irc);
44
45fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
46
47fail_unless(strstr(raw, "001") != NULL);
48fail_unless(strstr(raw, "002") != NULL);
49fail_unless(strstr(raw, "003") != NULL);
50fail_unless(strstr(raw, "004") != NULL);
51fail_unless(strstr(raw, "005") != NULL);
52
53g_free(raw);
54END_TEST
55
56Suite *irc_suite(void)
57{
58        Suite *s = suite_create("IRC");
59        TCase *tc_core = tcase_create("Core");
60
61        suite_add_tcase(s, tc_core);
62        tcase_add_test(tc_core, test_connect);
63        tcase_add_test(tc_core, test_login);
64        return s;
65}
Note: See TracBrowser for help on using the repository browser.