Mercurial > irccd
comparison tests/test-event.c @ 953:ab43ba409f9d
irccd: add SSL, and cleanup events
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 20 Jan 2021 12:32:59 +0100 |
parents | |
children | bbb3d3075ec2 |
comparison
equal
deleted
inserted
replaced
952:2899474aefd7 | 953:ab43ba409f9d |
---|---|
1 /* | |
2 * test-event.c -- test event.h functions | |
3 * | |
4 * Copyright (c) 2013-2021 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #define GREATEST_USE_ABBREVS 0 | |
20 #include <greatest.h> | |
21 | |
22 #include <irccd/event.h> | |
23 #include <irccd/server.h> | |
24 | |
25 GREATEST_TEST | |
26 basics_parse_simple(void) | |
27 { | |
28 /* This is a TOPIC message. */ | |
29 char str[] = ":malikania.fr 332 boris #test :Welcome to #test :: a testing channel"; | |
30 struct irc_event_msg msg; | |
31 | |
32 irc_event_parse(&msg, str); | |
33 | |
34 GREATEST_ASSERT_STR_EQ("malikania.fr", msg.prefix); | |
35 GREATEST_ASSERT_STR_EQ("332", msg.cmd); | |
36 GREATEST_ASSERT_STR_EQ("boris", msg.args[0]); | |
37 GREATEST_ASSERT_STR_EQ("#test", msg.args[1]); | |
38 GREATEST_ASSERT_STR_EQ("Welcome to #test :: a testing channel", msg.args[2]); | |
39 | |
40 GREATEST_PASS(); | |
41 } | |
42 | |
43 GREATEST_TEST | |
44 basics_parse_noprefix(void) | |
45 { | |
46 /* Ping messages usually don't have a prefix. */ | |
47 char str[] = "PING :malikania.fr"; | |
48 struct irc_event_msg msg; | |
49 | |
50 irc_event_parse(&msg, str); | |
51 | |
52 GREATEST_ASSERT(!msg.prefix); | |
53 GREATEST_ASSERT_STR_EQ("PING", msg.cmd); | |
54 GREATEST_ASSERT_STR_EQ("malikania.fr", msg.args[0]); | |
55 | |
56 GREATEST_PASS(); | |
57 } | |
58 | |
59 GREATEST_SUITE(suite_basics) | |
60 { | |
61 GREATEST_RUN_TEST(basics_parse_simple); | |
62 GREATEST_RUN_TEST(basics_parse_noprefix); | |
63 } | |
64 | |
65 GREATEST_MAIN_DEFS(); | |
66 | |
67 int | |
68 main(int argc, char **argv) | |
69 { | |
70 GREATEST_MAIN_BEGIN(); | |
71 GREATEST_RUN_SUITE(suite_basics); | |
72 GREATEST_MAIN_END(); | |
73 | |
74 return 0; | |
75 } |