source: tests/check_irc.c @ 664bac3

Last change on this file since 664bac3 was 25c4c78, checked in by dequis <dx@…>, at 2015-01-16T19:50:24Z

Fix compiler warnings on Cygwin and Mac OS X.

  • Don't use PIE/PIC on Cygwin/Darwin unless specified as these platforms don't support it.
  • Cleanup warnings for 'make check' build.
  • Fix the type issue for getsockopt calls.
  • Fix enum warnings in Yahoo libs on Mac OS X.
  • 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)
11        GIOChannel *ch1, *ch2;
12        irc_t *irc;
13        char *raw;
14        fail_unless(g_io_channel_pair(&ch1, &ch2));
15
16        irc = irc_new(g_io_channel_unix_get_fd(ch1));
17
18        irc_free(irc);
19
20        fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
21       
22        fail_if(strcmp(raw, "") != 0);
23
24        g_free(raw);
25END_TEST
26
27START_TEST(test_login)
28        GIOChannel *ch1, *ch2;
29        irc_t *irc;
30        char *raw;
31        fail_unless(g_io_channel_pair(&ch1, &ch2));
32
33        g_io_channel_set_flags(ch1, G_IO_FLAG_NONBLOCK, NULL);
34        g_io_channel_set_flags(ch2, G_IO_FLAG_NONBLOCK, NULL);
35
36        irc = irc_new(g_io_channel_unix_get_fd(ch1));
37
[18ff38f]38        fail_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);
[7bcdde3]40        fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL);
41
42        g_main_iteration(FALSE);
43        irc_free(irc);
44
45        fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL);
46       
47        fail_unless(strstr(raw, "001") != NULL);
48        fail_unless(strstr(raw, "002") != NULL);
49        fail_unless(strstr(raw, "003") != NULL);
50        fail_unless(strstr(raw, "004") != NULL);
51        fail_unless(strstr(raw, "005") != NULL);
52
53        g_free(raw);
54END_TEST
55
56Suite *irc_suite (void)
57{
58        Suite *s = suite_create("IRC");
59        TCase *tc_core = tcase_create("Core");
60        suite_add_tcase (s, tc_core);
61        tcase_add_test (tc_core, test_connect);
62        tcase_add_test (tc_core, test_login);
63        return s;
64}
Note: See TracBrowser for help on using the repository browser.