source: tests/check_irc.c @ 666722e

Last change on this file since 666722e 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
RevLine 
[7bcdde3]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)
[5ebff60]11GIOChannel * ch1, *ch2;
12irc_t *irc;
13char *raw;
14fail_unless(g_io_channel_pair(&ch1, &ch2));
[7bcdde3]15
[5ebff60]16irc = irc_new(g_io_channel_unix_get_fd(ch1));
[7bcdde3]17
[5ebff60]18irc_free(irc);
[7bcdde3]19
[5ebff60]20fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
[7bcdde3]21
[5ebff60]22fail_if(strcmp(raw, "") != 0);
23
24g_free(raw);
[7bcdde3]25END_TEST
26
27START_TEST(test_login)
[5ebff60]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);
[7bcdde3]35
[5ebff60]36irc = irc_new(g_io_channel_unix_get_fd(ch1));
[7bcdde3]37
[5ebff60]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);
[7bcdde3]41
[5ebff60]42g_main_iteration(FALSE);
43irc_free(irc);
[7bcdde3]44
[5ebff60]45fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
[7bcdde3]46
[5ebff60]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);
[7bcdde3]52
[5ebff60]53g_free(raw);
[7bcdde3]54END_TEST
55
[5ebff60]56Suite *irc_suite(void)
[7bcdde3]57{
58        Suite *s = suite_create("IRC");
59        TCase *tc_core = tcase_create("Core");
[5ebff60]60
61        suite_add_tcase(s, tc_core);
62        tcase_add_test(tc_core, test_connect);
63        tcase_add_test(tc_core, test_login);
[7bcdde3]64        return s;
65}
Note: See TracBrowser for help on using the repository browser.