37 lines
844 B
C++
37 lines
844 B
C++
#include <string>
|
|
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "trim.hpp"
|
|
|
|
namespace {
|
|
using ::testing::StrEq;
|
|
|
|
struct TrimCase {
|
|
const char *source;
|
|
const char *expected;
|
|
};
|
|
|
|
class TrimTest : public ::testing::TestWithParam<TrimCase> {
|
|
};
|
|
|
|
TEST_P(TrimTest, ReturnsTrimmedString) {
|
|
const auto ¶m = GetParam();
|
|
std::string_view result = wavefront::trim(param.source);
|
|
EXPECT_THAT(std::string(result), StrEq(param.expected));
|
|
}
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
|
TrimCases,
|
|
TrimTest,
|
|
::testing::Values(
|
|
TrimCase{" hello world ", "hello world"},
|
|
TrimCase{"\t\n spaced\t\n", "spaced"},
|
|
TrimCase{"trimmed", "trimmed"},
|
|
TrimCase{" ", ""},
|
|
TrimCase{"", ""}
|
|
)
|
|
);
|
|
}
|