Implement string functions

Summary:
Added missing string functions.
I also cleaned up error messages a bit in effort to make them uniform.

Reviewers: teon.banek, buda

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1458
This commit is contained in:
Marin Tomic
2018-06-29 14:58:10 +02:00
parent 843aa4f92a
commit 18d8129b99
9 changed files with 524 additions and 79 deletions

View File

@@ -8,6 +8,20 @@ using vec = std::vector<std::string>;
using namespace utils;
TEST(String, LTrim) {
EXPECT_EQ(LTrim(" \t\n\r ab\r\n\t ab \r\t "), "ab\r\n\t ab \r\t ");
EXPECT_EQ(LTrim(" \t\n\r"), "");
EXPECT_EQ(LTrim("run()"), "run()");
EXPECT_EQ(LTrim(""), "");
}
TEST(String, RTrim) {
EXPECT_EQ(RTrim(" \t\n\r ab\r\n\t ab \r\t "), " \t\n\r ab\r\n\t ab");
EXPECT_EQ(RTrim(" \t\n\r"), "");
EXPECT_EQ(RTrim("run()"), "run()");
EXPECT_EQ(RTrim(""), "");
}
TEST(String, Trim) {
EXPECT_EQ(Trim(" \t\n\r ab\r\n\t ab \r\t "), "ab\r\n\t ab");
EXPECT_EQ(Trim(" \t\n\r"), "");
@@ -118,8 +132,7 @@ TEST(String, RandomString) {
EXPECT_EQ(RandomString(42).size(), 42);
std::set<std::string> string_set;
for (int i = 0 ; i < 20 ; ++i)
string_set.emplace(RandomString(256));
for (int i = 0; i < 20; ++i) string_set.emplace(RandomString(256));
EXPECT_EQ(string_set.size(), 20);
}