-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtest_trim_str.cpp
42 lines (35 loc) · 1.1 KB
/
gtest_trim_str.cpp
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
/*****************************************************************//**
* \file gtest_trim_str.cpp
* \brief
*
* \author Xuhua Huang
* \date November 2022
*********************************************************************/
#include <iostream>
#include <gtest/gtest.h>
#include "trimstr.hpp"
#define STDTEST std::cout << "\033[32m[---TEST---]\033[m "
class TrimStrTest : public ::testing::Test
{
public:
void SetUp(void) override {}
void TearDown(void) override {}
TrimStrTest() {}
virtual ~TrimStrTest() {}
};
TEST_F(TrimStrTest, TrimFront_Test)
{
EXPECT_EQ(std::string((std::ranges::to<std::string>(std::string_view{ " test" } | trim_front)).c_str()), "test");
}
TEST_F(TrimStrTest, TrimBack_Test)
{
EXPECT_EQ(std::string((std::ranges::to<std::string>(std::string_view{ "test " } | trim_back)).c_str()), "test");
}
TEST_F(TrimStrTest, TrimFrontAndBack_Test)
{
EXPECT_EQ(std::string((std::ranges::to<std::string>(std::string_view{ " test "} | trim_spaces)).c_str()), "test");
}
TEST_F(TrimStrTest, TrimStrFn_Test)
{
EXPECT_EQ(trim_str(" test "), "test");
}