unit tests: coverage, settings
This commit is contained in:
36
tests/trim_test.cpp
Normal file
36
tests/trim_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#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{"", ""}
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user