Fri, 06 Oct 2023 00:35:28 -0500
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Testing Done:
Ran the unit tests under valgrind
Reviewed at https://reviews.imfreedom.org/r/2585/
|
42336
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib.h> |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <purple.h> |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "../purpleircv3source.h" |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | /****************************************************************************** |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | * Tests |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | static void |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | test_ircv3_source_parse_return_address_required(void) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | if(g_test_subprocess()) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | purple_ircv3_source_parse("pidgy", NULL, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | g_test_trap_subprocess(NULL, 0, G_TEST_SUBPROCESS_DEFAULT); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | g_test_trap_assert_stderr("*nick != NULL || user != NULL || host != NULL' failed*"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | static void |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | test_ircv3_source_parse_nick(void) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | char *nick = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | char *user = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | char *host = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | /* Once to make sure that user and host are null. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | purple_ircv3_source_parse("pidgy", &nick, &user, &host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | g_assert_cmpstr(nick, ==, "pidgy"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | g_clear_pointer(&nick, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | g_assert_null(user); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | g_assert_null(host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | /* Again to make sure it works without user and host. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | purple_ircv3_source_parse("pidgy", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | g_assert_cmpstr(nick, ==, "pidgy"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | g_clear_pointer(&nick, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | static void |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | test_ircv3_source_parse_user(void) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | char *nick = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | char *user = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | char *host = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | /* Once to make sure host is null. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | purple_ircv3_source_parse("pidgy!~u", &nick, &user, &host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | g_assert_cmpstr(nick, ==, "pidgy"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | g_clear_pointer(&nick, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | g_assert_cmpstr(user, ==, "~u"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | g_clear_pointer(&user, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | g_assert_null(host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | /* Again to make sure nick and host aren't required. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | purple_ircv3_source_parse("pidgy!~u", NULL, &user, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | g_assert_cmpstr(user, ==, "~u"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | g_clear_pointer(&user, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | static void |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | test_ircv3_source_parse_host(void) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | char *nick = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | char *user = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | char *host = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | /* Once to make sure everything works. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | purple_ircv3_source_parse("pidgy!~u@53unc8n42i868.irc", &nick, &user, |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | &host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | g_assert_cmpstr(nick, ==, "pidgy"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | g_clear_pointer(&nick, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | g_assert_cmpstr(user, ==, "~u"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | g_clear_pointer(&user, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | g_assert_cmpstr(host, ==, "53unc8n42i868.irc"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | g_clear_pointer(&host, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | /* Again to make sure nick and host aren't required. */ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | purple_ircv3_source_parse("pidgy!~u@53unc8n42i868.irc", NULL, NULL, &host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | g_assert_cmpstr(host, ==, "53unc8n42i868.irc"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | g_clear_pointer(&host, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | static void |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | test_ircv3_source_parse_baddies(void) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | char *nick = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | char *user = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | char *server = NULL; |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | purple_ircv3_source_parse("\n", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | purple_ircv3_source_parse("a\nb", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | purple_ircv3_source_parse("\r", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | purple_ircv3_source_parse("c\rd", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | purple_ircv3_source_parse(" ", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | purple_ircv3_source_parse("e f", &nick, NULL, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | g_assert_null(nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | purple_ircv3_source_parse("nick@foo!user@server", &nick, &user, &server); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | g_assert_cmpstr(nick, ==, "nick@foo"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | g_clear_pointer(&nick, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | g_assert_cmpstr(user, ==, "user"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | g_clear_pointer(&user, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | g_assert_cmpstr(server, ==, "server"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | g_clear_pointer(&server, g_free); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | purple_ircv3_source_parse("nick!user@server!foo", &nick, &user, &server); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | g_assert_cmpstr(nick, ==, "nick!user@server!foo"); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | g_assert_null(user); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | g_assert_null(server); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | } |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | /****************************************************************************** |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | * Main |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | *****************************************************************************/ |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | int |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | main(int argc, char *argv[]) { |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | g_test_init(&argc, &argv, NULL); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | g_test_add_func("/ircv3/source/parse/return-address-required", |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | test_ircv3_source_parse_return_address_required); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | g_test_add_func("/ircv3/source/parse/nick", test_ircv3_source_parse_nick); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | g_test_add_func("/ircv3/source/parse/user", test_ircv3_source_parse_user); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | g_test_add_func("/ircv3/source/parse/host", test_ircv3_source_parse_host); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | g_test_add_func("/ircv3/source/parse/baddies", |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | test_ircv3_source_parse_baddies); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | return g_test_run(); |
|
14c850aeee79
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | } |