forked from mrtazz/restclient-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_helpers.cc
More file actions
62 lines (51 loc) · 1.94 KB
/
Copy pathtest_helpers.cc
File metadata and controls
62 lines (51 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "restclient-cpp/helpers.h"
#include <gtest/gtest.h>
#include <string>
class HelpersTest : public ::testing::Test
{
protected:
HelpersTest()
{
}
virtual ~HelpersTest()
{
}
virtual void SetUp()
{
}
virtual void TearDown()
{
}
};
TEST_F(HelpersTest, TrimLeft) {
auto can_trim_left = std::string(" a set of characters");
auto cant_trim_left = std::string("a set of characters");
auto right_trim_ignored = std::string("a set of characters ");
EXPECT_EQ(RestClient::Helpers::ltrim(can_trim_left),
std::string("a set of characters"));
EXPECT_EQ(RestClient::Helpers::ltrim(cant_trim_left),
std::string("a set of characters"));
EXPECT_EQ(RestClient::Helpers::ltrim(right_trim_ignored),
std::string("a set of characters "));
}
TEST_F(HelpersTest, TrimRight) {
auto left_trim_ignored = std::string(" a set of characters");
auto cant_trim_right = std::string("a set of characters");
auto can_trim_right = std::string("a set of characters ");
EXPECT_EQ(RestClient::Helpers::rtrim(left_trim_ignored),
std::string(" a set of characters"));
EXPECT_EQ(RestClient::Helpers::rtrim(cant_trim_right),
std::string("a set of characters"));
EXPECT_EQ(RestClient::Helpers::rtrim(can_trim_right),
std::string("a set of characters"));
}
TEST_F(HelpersTest, TrimBoth) {
auto can_trim_both = std::string(" a set of characters ");
auto can_trim_left = std::string(" a set of characters");
auto can_trim_right = std::string("a set of characters ");
auto cant_trim = std::string("a set of characters");
EXPECT_EQ(RestClient::Helpers::trim(can_trim_both), "a set of characters");
EXPECT_EQ(RestClient::Helpers::trim(can_trim_left), "a set of characters");
EXPECT_EQ(RestClient::Helpers::trim(can_trim_right), "a set of characters");
EXPECT_EQ(RestClient::Helpers::trim(cant_trim), "a set of characters");
}