Skip to content

Commit 3c86220

Browse files
committed
tests: add more strings tests + catched bug in strip()
just made me realize that adding tests is important
1 parent d230340 commit 3c86220

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_util.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ std::string tmp;
66

77
TEST_CASE( "util.cpp test suitcase", "[Util]" ) {
88
SECTION( "String asserts" ) {
9+
std::string strip_str{" strip_\tthis_\nstring"};
10+
strip(strip_str);
11+
std::string replace_str_str{"replace foo and foo with bar"};
12+
replace_str(replace_str_str, "foo", "bar");
913
std::string env = std::getenv("HOME");
1014
std::string path = "~/.config/rule34";
15+
1116
REQUIRE(hasEnding("I want the end", "end"));
1217
REQUIRE(hasStart("And now the begin, then I want the end", "And"));
1318
REQUIRE(expandVar(path) == env + "/.config/rule34");
1419
REQUIRE(read_shell_exec("echo hello") == "hello");
20+
REQUIRE(split("this;should;be;a;vector", ';') == std::vector<std::string>{"this", "should", "be", "a", "vector"});
21+
REQUIRE(strip_str == "strip_this_string");
22+
REQUIRE(replace_str_str == "replace bar and bar with bar");
23+
REQUIRE(str_tolower("ThIS SHouLD Be LOWER") == "this should be lower");
24+
REQUIRE(str_toupper("ThIS SHouLD Be UPPER") == "THIS SHOULD BE UPPER");
1525
}
1626
}

0 commit comments

Comments
 (0)