diff options
author | louiz’ <louiz@louiz.org> | 2020-08-16 16:09:13 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2020-08-16 16:09:13 +0200 |
commit | f548f63178508936e36ac42e39d7ca0f064dcfb1 (patch) | |
tree | 2f177e03a76ef05b0f279544d4196beb6f859da4 /tests | |
parent | d016010333c7c093235f8d2cb8005109d205b2e1 (diff) | |
parent | b98434b5d04d1ada9b24475e17ee8947d96ad1e3 (diff) | |
download | biboumi-f548f63178508936e36ac42e39d7ca0f064dcfb1.tar.gz biboumi-f548f63178508936e36ac42e39d7ca0f064dcfb1.tar.bz2 biboumi-f548f63178508936e36ac42e39d7ca0f064dcfb1.tar.xz biboumi-f548f63178508936e36ac42e39d7ca0f064dcfb1.zip |
Merge branch 'v9'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/end_to_end/scenarios/multiple_channels_join.py | 4 | ||||
-rw-r--r-- | tests/irc.cpp | 43 | ||||
-rw-r--r-- | tests/utils.cpp | 3 |
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/end_to_end/scenarios/multiple_channels_join.py b/tests/end_to_end/scenarios/multiple_channels_join.py index 839909f..281a902 100644 --- a/tests/end_to_end/scenarios/multiple_channels_join.py +++ b/tests/end_to_end/scenarios/multiple_channels_join.py @@ -14,5 +14,9 @@ scenario = ( expect_self_join_presence(jid='{jid_one}/{resource_one}', chan="#foo", nick="{nick_one}"), expect_self_join_presence(jid='{jid_one}/{resource_one}', chan="#bar", nick="{nick_one}"), expect_self_join_presence(jid='{jid_one}/{resource_one}', chan="#baz", nick="{nick_one}"), + + send_stanza("<message from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}' type='groupchat'><subject>Le topic</subject></message>"), + expect_stanza("/message"), + ) diff --git a/tests/irc.cpp b/tests/irc.cpp new file mode 100644 index 0000000..0f30f15 --- /dev/null +++ b/tests/irc.cpp @@ -0,0 +1,43 @@ +#include "catch.hpp" + +#include <irc/irc_message.hpp> + +TEST_CASE("Basic IRC message parsing") +{ + IrcMessage m(":prefix COMMAND un deux trois"); + CHECK(m.prefix == "prefix"); + CHECK(m.command == "COMMAND"); + CHECK(m.arguments.size() == 3); + CHECK(m.arguments[0] == "un"); + CHECK(m.arguments[1] == "deux"); + CHECK(m.arguments[2] == "trois"); +} + +TEST_CASE("Trailing space") +{ + IrcMessage m(":prefix COMMAND un deux trois "); + CHECK(m.prefix == "prefix"); + CHECK(m.arguments.size() == 3); + CHECK(m.arguments[0] == "un"); + CHECK(m.arguments[1] == "deux"); + CHECK(m.arguments[2] == "trois"); +} + +TEST_CASE("Message with :") +{ + IrcMessage m(":prefix COMMAND un :coucou les amis "); + CHECK(m.prefix == "prefix"); + CHECK(m.arguments.size() == 2); + CHECK(m.arguments[0] == "un"); + CHECK(m.arguments[1] == "coucou les amis "); +} + +TEST_CASE("Message with empty :") +{ + IrcMessage m("COMMAND un deux :"); + CHECK(m.prefix == ""); + CHECK(m.arguments.size() == 3); + CHECK(m.arguments[0] == "un"); + CHECK(m.arguments[1] == "deux"); + CHECK(m.arguments[2] == ""); +} diff --git a/tests/utils.cpp b/tests/utils.cpp index 6de19f0..6151733 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -28,6 +28,9 @@ TEST_CASE("String split") CHECK(splitted.size() == 2); CHECK(splitted[0] == ""); CHECK(splitted[1] == "a"); + splitted = utils::split("multi-prefix ", ' '); + CHECK(splitted[0] == "multi-prefix"); + CHECK(splitted.size() == 1); } TEST_CASE("tolower") |