]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | #include "include/types.h" | |
3 | #include "include/str_list.h" | |
4 | ||
5 | #include <list> | |
6 | #include <vector> | |
7 | #include <string> | |
8 | ||
9 | #include "gtest/gtest.h" | |
10 | ||
11 | ||
12 | const char *tests[][10] = { | |
13 | { "foo,bar", "foo", "bar", 0 }, | |
14 | { "foo", "foo", 0 }, | |
15 | { "foo;bar", "foo", "bar", 0 }, | |
16 | { "foo bar", "foo", "bar", 0 }, | |
17 | { " foo bar", "foo", "bar", 0 }, | |
18 | { " foo bar ", "foo", "bar", 0 }, | |
19 | { "a,b,c", "a", "b", "c", 0 }, | |
20 | { " a\tb\tc\t", "a", "b", "c", 0 }, | |
21 | { "a, b, c", "a", "b", "c", 0 }, | |
22 | { "a b c", "a", "b", "c", 0 }, | |
23 | { "a=b=c", "a", "b", "c", 0 }, | |
24 | { 0 }, | |
25 | }; | |
26 | ||
27 | TEST(StrList, get_str_list) | |
28 | { | |
29 | for (unsigned i=0; tests[i][0]; ++i) { | |
30 | std::string src = tests[i][0]; | |
31 | std::list<std::string> expected; | |
32 | for (unsigned j=1; tests[i][j]; ++j) | |
33 | expected.push_back(tests[i][j]); | |
34 | std::list<std::string> actual; | |
35 | get_str_list(src, actual); | |
36 | std::cout << "'" << src << "' -> " << actual << std::endl; | |
37 | ASSERT_EQ(actual, expected); | |
38 | } | |
39 | } | |
40 | ||
41 | TEST(StrList, get_str_vec) | |
42 | { | |
43 | for (unsigned i=0; tests[i][0]; ++i) { | |
44 | std::string src = tests[i][0]; | |
45 | std::vector<std::string> expected; | |
46 | for (unsigned j=1; tests[i][j]; ++j) | |
47 | expected.push_back(tests[i][j]); | |
48 | std::vector<std::string> actual; | |
49 | get_str_vec (src, actual); | |
50 | std::cout << "'" << src << "' -> " << actual << std::endl; | |
51 | ASSERT_EQ(actual, expected); | |
52 | } | |
53 | ||
54 | } |