~singpolyma/biboumi

biboumi/tests/irc.cpp -rw-r--r-- 1.0 KiB
12223354Stephen Paul Weber Fix caps hash 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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] == "");
}