Mercurial > irccd
annotate tests/src/plugins/tictactoe/main.cpp @ 633:c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
As an example of use, delete games in plugin tictactoe that belong to a specific
server.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 14 Mar 2018 13:12:36 +0100 |
parents | e5d0f4289e04 |
children | 06f5486bfdcb |
rev | line source |
---|---|
632
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
1 /* |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
2 * main.cpp -- test plugin plugin |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
3 * |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
4 * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
5 * |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
6 * Permission to use, copy, modify, and/or distribute this software for any |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
7 * purpose with or without fee is hereby granted, provided that the above |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
8 * copyright notice and this permission notice appear in all copies. |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
9 * |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
17 */ |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
18 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
19 #define BOOST_TEST_MODULE "Plugin tictactoe" |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
20 #include <boost/test/unit_test.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
21 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
22 #include <irccd/string_util.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
23 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
24 #include <irccd/daemon/irccd.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
25 #include <irccd/daemon/server.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
26 #include <irccd/daemon/service/plugin_service.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
27 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
28 #include <irccd/test/plugin_test.hpp> |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
29 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
30 namespace irccd { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
31 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
32 class test_fixture : public plugin_test { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
33 public: |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
34 test_fixture() |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
35 : plugin_test(PLUGIN_NAME, PLUGIN_PATH) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
36 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
37 plugin_->set_formats({ |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
38 { "draw", "draw=#{channel}:#{command}:#{nickname}:#{plugin}:#{server}" }, |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
39 { "invalid", "invalid=#{channel}:#{command}:#{nickname}:#{origin}:#{plugin}:#{server}" }, |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
40 { "running", "running=#{channel}:#{command}:#{nickname}:#{origin}:#{plugin}:#{server}" }, |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
41 { "turn", "turn=#{channel}:#{command}:#{nickname}:#{plugin}:#{server}" }, |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
42 { "used", "used=#{channel}:#{command}:#{nickname}:#{origin}:#{plugin}:#{server}" }, |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
43 { "win", "win=#{channel}:#{command}:#{nickname}:#{plugin}:#{server}" } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
44 }); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
45 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
46 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
47 auto next_players() const |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
48 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
49 if (server_->cqueue().size() == 0) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
50 throw std::runtime_error("no message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
51 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
52 const auto cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
53 const auto list = string_util::split(cmd["message"].get<std::string>(), ":"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
54 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
55 BOOST_TEST(list.size() == 5U); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
56 BOOST_TEST(list[0] == "turn=#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
57 BOOST_TEST(list[1] == "!tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
58 BOOST_TEST(list[3] == "tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
59 BOOST_TEST(list[4] == "test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
60 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
61 return list[2] == "a" ? std::make_pair("a", "b") : std::make_pair("b", "a"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
62 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
63 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
64 auto start() |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
65 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
66 plugin_->on_command(irccd_, {server_, "a!a@localhost", "#tictactoe", "b"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
67 plugin_->on_names(irccd_, {server_, "#tictactoe", {"a", "b"}}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
68 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
69 return next_players(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
70 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
71 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
72 /** |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
73 * Helper to place several tokens on the board and automatically toggling |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
74 * players. |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
75 * |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
76 * This will start the game from "a" with target opponent "b". |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
77 * |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
78 */ |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
79 void run(const std::initializer_list<std::string>& points) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
80 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
81 auto players = start(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
82 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
83 for (const auto& p : points) { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
84 server_->cqueue().clear(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
85 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", p}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
86 players = next_players(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
87 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
88 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
89 }; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
90 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
91 BOOST_FIXTURE_TEST_SUITE(test_fixture_suite, test_fixture) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
92 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
93 BOOST_AUTO_TEST_CASE(win) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
94 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
95 run({"a 1", "b 1", "a 2", "b 2"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
96 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
97 const auto players = next_players(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
98 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
99 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 3"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
100 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
101 const auto cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
102 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
103 BOOST_TEST(cmd.is_object()); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
104 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
105 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
106 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
107 const auto parts = string_util::split(cmd["message"].get<std::string>(), ":"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
108 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
109 BOOST_TEST(parts.size() == 5U); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
110 BOOST_TEST(parts[0] == "win=#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
111 BOOST_TEST(parts[1] == "!tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
112 BOOST_TEST(parts[2] == players.first); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
113 BOOST_TEST(parts[3] == "tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
114 BOOST_TEST(parts[4] == "test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
115 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
116 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
117 BOOST_AUTO_TEST_CASE(draw) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
118 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
119 /* |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
120 * a b c |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
121 * 1 o x o |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
122 * 2 o x x |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
123 * 3 x o x |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
124 */ |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
125 run({ "b 2", "c 1", "c 3", "b 3", "c 2", "a 2", "a 3", "a 1" }); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
126 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
127 const auto players = next_players(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
128 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
129 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "b 1"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
130 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
131 const auto cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
132 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
133 BOOST_TEST(cmd.is_object()); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
134 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
135 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
136 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
137 const auto parts = string_util::split(cmd["message"].get<std::string>(), ":"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
138 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
139 BOOST_TEST(parts.size() == 5U); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
140 BOOST_TEST(parts[0] == "draw=#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
141 BOOST_TEST(parts[1] == "!tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
142 BOOST_TEST(parts[2] == players.first); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
143 BOOST_TEST(parts[3] == "tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
144 BOOST_TEST(parts[4] == "test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
145 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
146 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
147 BOOST_AUTO_TEST_CASE(used) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
148 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
149 auto players = start(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
150 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
151 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 1"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
152 plugin_->on_message(irccd_, {server_, players.second, "#tictactoe", "a 1"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
153 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
154 const auto cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
155 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
156 BOOST_TEST(cmd.is_object()); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
157 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
158 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
159 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
160 const auto parts = string_util::split(cmd["message"].get<std::string>(), ":"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
161 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
162 BOOST_TEST(parts[0] == "used=#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
163 BOOST_TEST(parts[1] == "!tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
164 BOOST_TEST(parts[2] == players.second); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
165 BOOST_TEST(parts[3] == players.second); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
166 BOOST_TEST(parts[4] == "tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
167 BOOST_TEST(parts[5] == "test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
168 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
169 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
170 BOOST_AUTO_TEST_CASE(invalid) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
171 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
172 nlohmann::json cmd; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
173 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
174 // empty name (no names) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
175 plugin_->on_command(irccd_, {server_, "jean", "#tictactoe", ""}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
176 cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
177 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
178 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
179 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
180 BOOST_TEST(cmd["message"].get<std::string>() == "invalid=#tictactoe:!tictactoe:jean:jean:tictactoe:test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
181 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
182 // bot name (no names) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
183 plugin_->on_command(irccd_, {server_, "jean", "#tictactoe", "irccd"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
184 cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
185 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
186 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
187 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
188 BOOST_TEST(cmd["message"].get<std::string>() == "invalid=#tictactoe:!tictactoe:jean:jean:tictactoe:test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
189 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
190 // target is origin (no names) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
191 plugin_->on_command(irccd_, {server_, server_->nickname(), "#tictactoe", server_->nickname()}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
192 cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
193 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
194 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
195 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
196 BOOST_TEST(cmd["message"].get<std::string>() == "invalid=#tictactoe:!tictactoe:irccd:irccd:tictactoe:test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
197 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
198 // not existing (names) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
199 plugin_->on_command(irccd_, {server_, server_->nickname(), "#tictactoe", server_->nickname()}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
200 plugin_->on_names(irccd_, {server_, "#tictactoe", {"a", "b", "c"}}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
201 cmd = server_->cqueue().back(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
202 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
203 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
204 BOOST_TEST(cmd["target"].get<std::string>() == "#tictactoe"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
205 BOOST_TEST(cmd["message"].get<std::string>() == "invalid=#tictactoe:!tictactoe:irccd:irccd:tictactoe:test"); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
206 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
207 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
208 BOOST_AUTO_TEST_CASE(random) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
209 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
210 /* |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
211 * Ensure that the first player is not always the originator, start the game |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
212 * for at most 1'000'000 times to avoid forever loop. |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
213 */ |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
214 unsigned count = 0; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
215 bool a = false; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
216 bool b = false; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
217 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
218 // Last player turn is the winner. |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
219 while (!a && !b && count++ < 1000000U) { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
220 run({"a 1", "b 1", "a 2", "b 2"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
221 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
222 const auto players = next_players(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
223 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
224 if (players.first == std::string("a")) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
225 a = true; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
226 else |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
227 b = true; |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
228 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
229 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 3"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
230 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
231 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
232 |
633
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
233 BOOST_AUTO_TEST_CASE(disconnect) |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
234 { |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
235 auto players = start(); |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
236 |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
237 server_->disconnect(); |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
238 server_->cqueue().clear(); |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
239 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 1"}); |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
240 |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
241 BOOST_TEST(server_->cqueue().empty()); |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
242 } |
c07819d1d306
Irccd: add onDisconnect event, closes #767 @1h
David Demelier <markand@malikania.fr>
parents:
632
diff
changeset
|
243 |
632
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
244 BOOST_AUTO_TEST_CASE(kick) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
245 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
246 auto players = start(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
247 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
248 server_->cqueue().clear(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
249 plugin_->on_kick(irccd_, {server_, "kefka", "#tictactoe", players.first, ""}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
250 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 1"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
251 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
252 BOOST_TEST(server_->cqueue().empty()); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
253 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
254 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
255 BOOST_AUTO_TEST_CASE(part) |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
256 { |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
257 auto players = start(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
258 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
259 server_->cqueue().clear(); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
260 plugin_->on_part(irccd_, {server_, players.first, "#tictactoe", ""}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
261 plugin_->on_message(irccd_, {server_, players.first, "#tictactoe", "a 1"}); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
262 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
263 BOOST_TEST(server_->cqueue().empty()); |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
264 } |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
265 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
266 BOOST_AUTO_TEST_SUITE_END() |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
267 |
e5d0f4289e04
Plugin tictactoe: brand new plugin, closes #393 @6h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
268 } // !irccd |