SmallTest.cpp
995 Bytes
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 "CLI.hpp"
#include "gtest/gtest.h"
TEST(Split, GoodStrings) {
std::vector<std::string> test_strings = {"a,boo", ",coo", "d,", "Q,this-is", "s", "single"};
std::string s, l;
std::tie(s, l) = CLI::split("a,boo");
EXPECT_EQ("a", s);
EXPECT_EQ("boo", l);
std::tie(s, l) = CLI::split(",coo");
EXPECT_EQ("", s);
EXPECT_EQ("coo", l);
std::tie(s, l) = CLI::split("d,");
EXPECT_EQ("d", s);
EXPECT_EQ("", l);
std::tie(s, l) = CLI::split("Q,this-is");
EXPECT_EQ("Q", s);
EXPECT_EQ("this-is", l);
std::tie(s, l) = CLI::split("s");
EXPECT_EQ("s", s);
EXPECT_EQ("", l);
std::tie(s, l) = CLI::split("single");
EXPECT_EQ("", s);
EXPECT_EQ("single", l);
}
TEST(Split, BadStrings) {
std::vector<std::string> test_fails= {"a,,boo", "a,b,c", "ssd,sfd", "-a", "", ",", "one two"};
for(std::string name : test_fails) {
EXPECT_THROW(CLI::split(name), CLI::BadNameString);
}
}