summaryrefslogtreecommitdiff
path: root/test/str.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-28 22:50:56 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-28 22:52:31 +0200
commit0ca22c7d6d650c80906bd1217fccf32066cc2502 (patch)
tree518c864de533308dd491d72b24338ad6bd596a1c /test/str.cc
parentfb776823ec3174354f14866495ce11d38cbe5701 (diff)
str: Add trim()
Diffstat (limited to 'test/str.cc')
-rw-r--r--test/str.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/str.cc b/test/str.cc
index 1339bb0..6d7edf2 100644
--- a/test/str.cc
+++ b/test/str.cc
@@ -36,3 +36,32 @@ TEST(str, split) {
EXPECT_EQ("a", ret[1]);
EXPECT_EQ("b", ret[2]);
}
+
+TEST(str, trim) {
+ auto ret = str::trim("");
+ EXPECT_EQ("", ret);
+
+ ret = str::trim(" ");
+ EXPECT_EQ("", ret);
+
+ ret = str::trim(" ");
+ EXPECT_EQ("", ret);
+
+ ret = str::trim("foo");
+ EXPECT_EQ("foo", ret);
+
+ ret = str::trim(" foo");
+ EXPECT_EQ("foo", ret);
+
+ ret = str::trim(" foo ");
+ EXPECT_EQ("foo", ret);
+
+ ret = str::trim("foo ");
+ EXPECT_EQ("foo", ret);
+
+ ret = str::trim(" foo bar ");
+ EXPECT_EQ("foo bar", ret);
+
+ ret = str::trim("\tfoo bar\r\n");
+ EXPECT_EQ("foo bar", ret);
+}