-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathGoogleFixtureNamerCustomizationTests.cpp
75 lines (62 loc) · 2.14 KB
/
GoogleFixtureNamerCustomizationTests.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "gtest/gtest.h"
#include "ApprovalTests/namers/ApprovalTestNamer.h"
#include "ApprovalTests/integrations/google/GoogleConfiguration.h"
using namespace ApprovalTests;
// begin-snippet: googletest_customize_suffix
// main.cpp
auto customization =
GoogleConfiguration::addIgnorableTestCaseNameSuffix("Fixture");
// end-snippet
// begin-snippet: googletest_name_parts
TEST(TestCaseName, TestName)
// end-snippet
{
ApprovalTestNamer namer;
EXPECT_EQ(namer.getOutputFileBaseName(),
"GoogleFixtureNamerCustomizationTests.TestCaseName.TestName");
}
TEST(GoogleFixtureNamerCustomizationTests, EliminatesDuplicatedClassName)
{
ApprovalTestNamer namer;
EXPECT_EQ(
namer.getOutputFileBaseName(),
"GoogleFixtureNamerCustomizationTests.EliminatesDuplicatedClassName");
}
class GoogleFixtureNamerCustomizationTestsFixture : public ::testing::Test
{
};
TEST_F(GoogleFixtureNamerCustomizationTestsFixture, OnlyMatchesFixtureAtEnd)
{
ApprovalTestNamer namer;
EXPECT_EQ(namer.getOutputFileBaseName(),
"GoogleFixtureNamerCustomizationTests.OnlyMatchesFixtureAtEnd");
}
// begin-snippet: googletest_customize_function
// main.cpp
bool dropTestCaseNamesWithIgnoreThis(
const std::string& /*testFileNameWithExtension*/,
const std::string& testCaseName)
{
return StringUtils::contains(testCaseName, "IgnoreThis");
}
auto ignoreNames = GoogleConfiguration::addTestCaseNameRedundancyCheck(
dropTestCaseNamesWithIgnoreThis);
// end-snippet
// begin-snippet: googletest_customize_lambda
// main.cpp
auto ignoreNamesLambda = GoogleConfiguration::addTestCaseNameRedundancyCheck(
[](const std::string& /*testFileNameWithExtension*/,
const std::string& testCaseName) {
return StringUtils::contains(testCaseName, "IgnoreThis");
});
// end-snippet
// begin-snippet: googletest_customize_test
TEST(TestCaseName_IgnoreThis, TestName)
// end-snippet
{
ApprovalTestNamer namer;
// begin-snippet: googletest_customize_test_name
auto outputFileBaseName = "GoogleFixtureNamerCustomizationTests.TestName";
// end-snippet
EXPECT_EQ(namer.getOutputFileBaseName(), outputFileBaseName);
}