summaryrefslogtreecommitdiffstatshomepage
path: root/tests/lib/util/corestr.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-11-08 16:06:28 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2015-11-08 16:06:28 +0100
commitcf66ec55638af1a74df09193b226b46f37653079 (patch)
tree734dc3f8ddd0c3c86bb863d52a6ec540ffb59334 /tests/lib/util/corestr.cpp
parent7418d14468e909b86922281f690fca7999114f21 (diff)
c -> cpp for test (nw)
Diffstat (limited to 'tests/lib/util/corestr.cpp')
-rw-r--r--tests/lib/util/corestr.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/lib/util/corestr.cpp b/tests/lib/util/corestr.cpp
new file mode 100644
index 00000000000..fa2dcabf48b
--- /dev/null
+++ b/tests/lib/util/corestr.cpp
@@ -0,0 +1,54 @@
+// license:BSD-3-Clause
+// copyright-holders:Miodrag Milanovic
+
+#include "gtest/gtest.h"
+#include "corestr.h"
+
+TEST(corestr,strmakeupper)
+{
+ std::string value = "test";
+ EXPECT_STREQ("TEST", strmakeupper(value).c_str());
+}
+
+TEST(corestr,strmakelower)
+{
+ std::string value = "ValUE";
+ EXPECT_STREQ("value", strmakelower(value).c_str());
+}
+
+TEST(corestr,strreplace)
+{
+ std::string value = "Main string";
+ EXPECT_EQ(1, strreplace(value,"str","aaa"));
+ EXPECT_STREQ("Main aaaing", value.c_str());
+ EXPECT_EQ(4, strreplace(value,"a","b"));
+}
+
+TEST(corestr,strtrimspace)
+{
+ std::string value = " a value for test ";
+ EXPECT_STREQ("a value for test", strtrimspace(value).c_str());
+ value = "\r\n\ta value for test\r\n\n\r";
+ EXPECT_STREQ("a value for test", strtrimspace(value).c_str());
+}
+
+TEST(corestr,strreplacechr)
+{
+ std::string value = "String for doing replaces";
+ strreplacechr(value,'a','A');
+ strreplacechr(value,'e','E');
+ strreplacechr(value,'i','I');
+ strreplacechr(value,'o','O');
+ EXPECT_STREQ("StrIng fOr dOIng rEplAcEs", value.c_str());
+}
+
+TEST(corestr,strdelchr)
+{
+ std::string value = "String for doing deletes";
+ strdelchr(value,'a');
+ strdelchr(value,'e');
+ strdelchr(value,'i');
+ strdelchr(value,'o');
+ EXPECT_STREQ("Strng fr dng dlts", value.c_str());
+}
+