Mercurial > irccd
comparison tests/src/libirccd-daemon/dynlib-plugin/main.cpp @ 809:8460b4a34191
misc: reorganize namespaces, closes #952 @4h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 16 Nov 2018 12:25:00 +0100 |
parents | tests/src/libirccd/dynlib-plugin/main.cpp@8c44bbcbbab9 |
children | 49fa22f0b4b9 |
comparison
equal
deleted
inserted
replaced
808:80bccab4a093 | 809:8460b4a34191 |
---|---|
1 /* | |
2 * main.cpp -- test dynlib_plugin | |
3 * | |
4 * Copyright (c) 2013-2018 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 BOOST_TEST_MODULE "dynlib_plugin" | |
20 #include <boost/test/unit_test.hpp> | |
21 | |
22 /* | |
23 * For this test, we update internal plugin configuration each time a function | |
24 * is called and check if it has been called correctly using get_options. | |
25 */ | |
26 | |
27 #include <irccd/daemon/bot.hpp> | |
28 #include <irccd/daemon/dynlib_plugin.hpp> | |
29 #include <irccd/daemon/server.hpp> | |
30 | |
31 using irccd::daemon::bot; | |
32 using irccd::daemon::dynlib_plugin_loader; | |
33 using irccd::daemon::plugin; | |
34 | |
35 namespace irccd { | |
36 | |
37 namespace { | |
38 | |
39 class fixture { | |
40 protected: | |
41 boost::asio::io_service service_; | |
42 std::shared_ptr<plugin> plugin_; | |
43 bot bot_{service_}; | |
44 | |
45 fixture() | |
46 { | |
47 plugin_ = dynlib_plugin_loader({CMAKE_CURRENT_BINARY_DIR}).find("test-plugin"); | |
48 | |
49 if (!plugin_) | |
50 throw std::runtime_error("test plugin not found"); | |
51 } | |
52 }; | |
53 | |
54 BOOST_FIXTURE_TEST_SUITE(dynlib_plugin_suite, fixture) | |
55 | |
56 BOOST_AUTO_TEST_CASE(handle_command) | |
57 { | |
58 plugin_->handle_command(bot_, {}); | |
59 | |
60 BOOST_TEST(plugin_->get_options().size() == 1U); | |
61 BOOST_TEST(plugin_->get_options()["command"] == "true"); | |
62 } | |
63 | |
64 BOOST_AUTO_TEST_CASE(handle_connect) | |
65 { | |
66 plugin_->handle_connect(bot_, {}); | |
67 | |
68 BOOST_TEST(plugin_->get_options().size() == 1U); | |
69 BOOST_TEST(plugin_->get_options()["connect"] == "true"); | |
70 } | |
71 | |
72 BOOST_AUTO_TEST_CASE(handle_invite) | |
73 { | |
74 plugin_->handle_invite(bot_, {}); | |
75 | |
76 BOOST_TEST(plugin_->get_options().size() == 1U); | |
77 BOOST_TEST(plugin_->get_options()["invite"] == "true"); | |
78 } | |
79 | |
80 BOOST_AUTO_TEST_CASE(handle_join) | |
81 { | |
82 plugin_->handle_join(bot_, {}); | |
83 | |
84 BOOST_TEST(plugin_->get_options().size() == 1U); | |
85 BOOST_TEST(plugin_->get_options()["join"] == "true"); | |
86 } | |
87 | |
88 BOOST_AUTO_TEST_CASE(handle_kick) | |
89 { | |
90 plugin_->handle_kick(bot_, {}); | |
91 | |
92 BOOST_TEST(plugin_->get_options().size() == 1U); | |
93 BOOST_TEST(plugin_->get_options()["kick"] == "true"); | |
94 } | |
95 | |
96 BOOST_AUTO_TEST_CASE(handle_load) | |
97 { | |
98 plugin_->handle_load(bot_); | |
99 | |
100 BOOST_TEST(plugin_->get_options().size() == 1U); | |
101 BOOST_TEST(plugin_->get_options()["load"] == "true"); | |
102 } | |
103 | |
104 BOOST_AUTO_TEST_CASE(handle_message) | |
105 { | |
106 plugin_->handle_message(bot_, {}); | |
107 | |
108 BOOST_TEST(plugin_->get_options().size() == 1U); | |
109 BOOST_TEST(plugin_->get_options()["message"] == "true"); | |
110 } | |
111 | |
112 BOOST_AUTO_TEST_CASE(handle_me) | |
113 { | |
114 plugin_->handle_me(bot_, {}); | |
115 | |
116 BOOST_TEST(plugin_->get_options().size() == 1U); | |
117 BOOST_TEST(plugin_->get_options()["me"] == "true"); | |
118 } | |
119 | |
120 BOOST_AUTO_TEST_CASE(handle_mode) | |
121 { | |
122 plugin_->handle_mode(bot_, {}); | |
123 | |
124 BOOST_TEST(plugin_->get_options().size() == 1U); | |
125 BOOST_TEST(plugin_->get_options()["mode"] == "true"); | |
126 } | |
127 | |
128 BOOST_AUTO_TEST_CASE(handle_names) | |
129 { | |
130 plugin_->handle_names(bot_, {}); | |
131 | |
132 BOOST_TEST(plugin_->get_options().size() == 1U); | |
133 BOOST_TEST(plugin_->get_options()["names"] == "true"); | |
134 } | |
135 | |
136 BOOST_AUTO_TEST_CASE(handle_nick) | |
137 { | |
138 plugin_->handle_nick(bot_, {}); | |
139 | |
140 BOOST_TEST(plugin_->get_options().size() == 1U); | |
141 BOOST_TEST(plugin_->get_options()["nick"] == "true"); | |
142 } | |
143 | |
144 BOOST_AUTO_TEST_CASE(handle_notice) | |
145 { | |
146 plugin_->handle_notice(bot_, {}); | |
147 | |
148 BOOST_TEST(plugin_->get_options().size() == 1U); | |
149 BOOST_TEST(plugin_->get_options()["notice"] == "true"); | |
150 } | |
151 | |
152 BOOST_AUTO_TEST_CASE(handle_part) | |
153 { | |
154 plugin_->handle_part(bot_, {}); | |
155 | |
156 BOOST_TEST(plugin_->get_options().size() == 1U); | |
157 BOOST_TEST(plugin_->get_options()["part"] == "true"); | |
158 } | |
159 | |
160 BOOST_AUTO_TEST_CASE(handle_reload) | |
161 { | |
162 plugin_->handle_reload(bot_); | |
163 | |
164 BOOST_TEST(plugin_->get_options().size() == 1U); | |
165 BOOST_TEST(plugin_->get_options()["reload"] == "true"); | |
166 } | |
167 | |
168 BOOST_AUTO_TEST_CASE(handle_topic) | |
169 { | |
170 plugin_->handle_topic(bot_, {}); | |
171 | |
172 BOOST_TEST(plugin_->get_options().size() == 1U); | |
173 BOOST_TEST(plugin_->get_options()["topic"] == "true"); | |
174 } | |
175 | |
176 BOOST_AUTO_TEST_CASE(handle_unload) | |
177 { | |
178 plugin_->handle_unload(bot_); | |
179 | |
180 BOOST_TEST(plugin_->get_options().size() == 1U); | |
181 BOOST_TEST(plugin_->get_options()["unload"] == "true"); | |
182 } | |
183 | |
184 BOOST_AUTO_TEST_CASE(handle_whois) | |
185 { | |
186 plugin_->handle_whois(bot_, {}); | |
187 | |
188 BOOST_TEST(plugin_->get_options().size() == 1U); | |
189 BOOST_TEST(plugin_->get_options()["whois"] == "true"); | |
190 } | |
191 | |
192 BOOST_AUTO_TEST_SUITE_END() | |
193 | |
194 } // !namespace | |
195 | |
196 } // !irccd |