summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-14 21:48:38 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-14 21:48:38 +0200
commit712b7bdfdfe5d77001669dd1d11a860437dc3849 (patch)
treee21c66d59d35197ff6ec3fcdd6369760b07386f1 /src/test.cpp
parent634e7cf125a8870f49b3c99364d710b0da98decf (diff)
downloadbiboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.gz
biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.bz2
biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.xz
biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.zip
Correctly handle the usage of ! as a IRC user mode indicator
Since “!” is also the separator between the nickname and the user hostname, having “!” as the user mode (e.g. !nick!~some@host.bla) would cause the nick to be empty. Now we skip it if it is a valid user mode indicator.
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp
index 1056926..f624bc2 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -9,6 +9,7 @@
#include <config/config.hpp>
#include <bridge/colors.hpp>
#include <utils/tolower.hpp>
+#include <irc/irc_user.hpp>
#include <utils/split.hpp>
#include <xmpp/jid.hpp>
#include <irc/iid.hpp>
@@ -123,6 +124,22 @@ int main()
assert(xml_unescape(xml_escape(unescaped)) == unescaped);
/**
+ * Irc user parsing
+ */
+ const std::map<char, char> prefixes{{'!', 'a'}, {'@', 'o'}};
+
+ IrcUser user1("!nick!~some@host.bla", prefixes);
+ assert(user1.nick == "nick");
+ assert(user1.host == "~some@host.bla");
+ assert(user1.modes.size() == 1);
+ assert(user1.modes.find('a') != user1.modes.end());
+ IrcUser user2("coucou!~other@host.bla", prefixes);
+ assert(user2.nick == "coucou");
+ assert(user2.host == "~other@host.bla");
+ assert(user2.modes.size() == 0);
+ assert(user2.modes.find('a') == user2.modes.end());
+
+ /**
* Colors conversion
*/
std::cout << color << "Testing IRC colors conversion…" << reset << std::endl;