mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-23 08:57:34 +09:00
Replace NSS with Pale Moon's
This commit is contained in:
parent
ff1e5e48bf
commit
8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions
|
|
@ -37,6 +37,7 @@
|
|||
# include <algorithm>
|
||||
# include <iostream>
|
||||
# include <list>
|
||||
# include <set>
|
||||
# include <sstream>
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
|
@ -49,19 +50,13 @@ using ::std::sort;
|
|||
|
||||
using ::testing::AddGlobalTestEnvironment;
|
||||
using ::testing::Bool;
|
||||
using ::testing::Combine;
|
||||
using ::testing::Message;
|
||||
using ::testing::Range;
|
||||
using ::testing::TestWithParam;
|
||||
using ::testing::Values;
|
||||
using ::testing::ValuesIn;
|
||||
|
||||
# if GTEST_HAS_COMBINE
|
||||
using ::testing::Combine;
|
||||
using ::testing::get;
|
||||
using ::testing::make_tuple;
|
||||
using ::testing::tuple;
|
||||
# endif // GTEST_HAS_COMBINE
|
||||
|
||||
using ::testing::internal::ParamGenerator;
|
||||
using ::testing::internal::UnitTestOptions;
|
||||
|
||||
|
|
@ -73,49 +68,9 @@ using ::testing::internal::UnitTestOptions;
|
|||
// EXPECT_THAT() and the matchers know how to print tuples.
|
||||
template <typename T>
|
||||
::std::string PrintValue(const T& value) {
|
||||
::std::stringstream stream;
|
||||
stream << value;
|
||||
return stream.str();
|
||||
return testing::PrintToString(value);
|
||||
}
|
||||
|
||||
# if GTEST_HAS_COMBINE
|
||||
|
||||
// These overloads allow printing tuples in our tests. We cannot
|
||||
// define an operator<< for tuples, as that definition needs to be in
|
||||
// the std namespace in order to be picked up by Google Test via
|
||||
// Argument-Dependent Lookup, yet defining anything in the std
|
||||
// namespace in non-STL code is undefined behavior.
|
||||
|
||||
template <typename T1, typename T2>
|
||||
::std::string PrintValue(const tuple<T1, T2>& value) {
|
||||
::std::stringstream stream;
|
||||
stream << "(" << get<0>(value) << ", " << get<1>(value) << ")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
::std::string PrintValue(const tuple<T1, T2, T3>& value) {
|
||||
::std::stringstream stream;
|
||||
stream << "(" << get<0>(value) << ", " << get<1>(value)
|
||||
<< ", "<< get<2>(value) << ")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8, typename T9, typename T10>
|
||||
::std::string PrintValue(
|
||||
const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {
|
||||
::std::stringstream stream;
|
||||
stream << "(" << get<0>(value) << ", " << get<1>(value)
|
||||
<< ", "<< get<2>(value) << ", " << get<3>(value)
|
||||
<< ", "<< get<4>(value) << ", " << get<5>(value)
|
||||
<< ", "<< get<6>(value) << ", " << get<7>(value)
|
||||
<< ", "<< get<8>(value) << ", " << get<9>(value) << ")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
# endif // GTEST_HAS_COMBINE
|
||||
|
||||
// Verifies that a sequence generated by the generator and accessed
|
||||
// via the iterator object matches the expected one using Google Test
|
||||
// assertions.
|
||||
|
|
@ -450,31 +405,28 @@ TEST(BoolTest, BoolWorks) {
|
|||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
# if GTEST_HAS_COMBINE
|
||||
|
||||
// Tests that Combine() with two parameters generates the expected sequence.
|
||||
TEST(CombineTest, CombineWithTwoParameters) {
|
||||
const char* foo = "foo";
|
||||
const char* bar = "bar";
|
||||
const ParamGenerator<tuple<const char*, int> > gen =
|
||||
const ParamGenerator<std::tuple<const char*, int> > gen =
|
||||
Combine(Values(foo, bar), Values(3, 4));
|
||||
|
||||
tuple<const char*, int> expected_values[] = {
|
||||
make_tuple(foo, 3), make_tuple(foo, 4),
|
||||
make_tuple(bar, 3), make_tuple(bar, 4)};
|
||||
std::tuple<const char*, int> expected_values[] = {
|
||||
std::make_tuple(foo, 3), std::make_tuple(foo, 4), std::make_tuple(bar, 3),
|
||||
std::make_tuple(bar, 4)};
|
||||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
// Tests that Combine() with three parameters generates the expected sequence.
|
||||
TEST(CombineTest, CombineWithThreeParameters) {
|
||||
const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),
|
||||
Values(3, 4),
|
||||
Values(5, 6));
|
||||
tuple<int, int, int> expected_values[] = {
|
||||
make_tuple(0, 3, 5), make_tuple(0, 3, 6),
|
||||
make_tuple(0, 4, 5), make_tuple(0, 4, 6),
|
||||
make_tuple(1, 3, 5), make_tuple(1, 3, 6),
|
||||
make_tuple(1, 4, 5), make_tuple(1, 4, 6)};
|
||||
const ParamGenerator<std::tuple<int, int, int> > gen =
|
||||
Combine(Values(0, 1), Values(3, 4), Values(5, 6));
|
||||
std::tuple<int, int, int> expected_values[] = {
|
||||
std::make_tuple(0, 3, 5), std::make_tuple(0, 3, 6),
|
||||
std::make_tuple(0, 4, 5), std::make_tuple(0, 4, 6),
|
||||
std::make_tuple(1, 3, 5), std::make_tuple(1, 3, 6),
|
||||
std::make_tuple(1, 4, 5), std::make_tuple(1, 4, 6)};
|
||||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
|
|
@ -482,10 +434,11 @@ TEST(CombineTest, CombineWithThreeParameters) {
|
|||
// sequence generates a sequence with the number of elements equal to the
|
||||
// number of elements in the sequence generated by the second parameter.
|
||||
TEST(CombineTest, CombineWithFirstParameterSingleValue) {
|
||||
const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),
|
||||
Values(0, 1));
|
||||
const ParamGenerator<std::tuple<int, int> > gen =
|
||||
Combine(Values(42), Values(0, 1));
|
||||
|
||||
tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};
|
||||
std::tuple<int, int> expected_values[] = {std::make_tuple(42, 0),
|
||||
std::make_tuple(42, 1)};
|
||||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
|
|
@ -493,26 +446,27 @@ TEST(CombineTest, CombineWithFirstParameterSingleValue) {
|
|||
// sequence generates a sequence with the number of elements equal to the
|
||||
// number of elements in the sequence generated by the first parameter.
|
||||
TEST(CombineTest, CombineWithSecondParameterSingleValue) {
|
||||
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
|
||||
Values(42));
|
||||
const ParamGenerator<std::tuple<int, int> > gen =
|
||||
Combine(Values(0, 1), Values(42));
|
||||
|
||||
tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};
|
||||
std::tuple<int, int> expected_values[] = {std::make_tuple(0, 42),
|
||||
std::make_tuple(1, 42)};
|
||||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
// Tests that when the first parameter produces an empty sequence,
|
||||
// Combine() produces an empty sequence, too.
|
||||
TEST(CombineTest, CombineWithFirstParameterEmptyRange) {
|
||||
const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),
|
||||
Values(0, 1));
|
||||
const ParamGenerator<std::tuple<int, int> > gen =
|
||||
Combine(Range(0, 0), Values(0, 1));
|
||||
VerifyGeneratorIsEmpty(gen);
|
||||
}
|
||||
|
||||
// Tests that when the second parameter produces an empty sequence,
|
||||
// Combine() produces an empty sequence, too.
|
||||
TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
|
||||
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
|
||||
Range(1, 1));
|
||||
const ParamGenerator<std::tuple<int, int> > gen =
|
||||
Combine(Values(0, 1), Range(1, 1));
|
||||
VerifyGeneratorIsEmpty(gen);
|
||||
}
|
||||
|
||||
|
|
@ -521,44 +475,41 @@ TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
|
|||
TEST(CombineTest, CombineWithMaxNumberOfParameters) {
|
||||
const char* foo = "foo";
|
||||
const char* bar = "bar";
|
||||
const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,
|
||||
int, int> > gen = Combine(Values(foo, bar),
|
||||
Values(1), Values(2),
|
||||
Values(3), Values(4),
|
||||
Values(5), Values(6),
|
||||
Values(7), Values(8),
|
||||
Values(9));
|
||||
const ParamGenerator<
|
||||
std::tuple<const char*, int, int, int, int, int, int, int, int, int> >
|
||||
gen =
|
||||
Combine(Values(foo, bar), Values(1), Values(2), Values(3), Values(4),
|
||||
Values(5), Values(6), Values(7), Values(8), Values(9));
|
||||
|
||||
tuple<const char*, int, int, int, int, int, int, int, int, int>
|
||||
expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
|
||||
std::tuple<const char*, int, int, int, int, int, int, int, int, int>
|
||||
expected_values[] = {std::make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
|
||||
std::make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
|
||||
VerifyGenerator(gen, expected_values);
|
||||
}
|
||||
|
||||
#if GTEST_LANG_CXX11
|
||||
|
||||
class NonDefaultConstructAssignString {
|
||||
public:
|
||||
NonDefaultConstructAssignString(const std::string& s) : str_(s) {}
|
||||
NonDefaultConstructAssignString() = delete;
|
||||
NonDefaultConstructAssignString(const NonDefaultConstructAssignString&) =
|
||||
default;
|
||||
NonDefaultConstructAssignString& operator=(
|
||||
const NonDefaultConstructAssignString&) = delete;
|
||||
~NonDefaultConstructAssignString() = default;
|
||||
|
||||
const std::string& str() const { return str_; }
|
||||
|
||||
private:
|
||||
std::string str_;
|
||||
|
||||
// Not default constructible
|
||||
NonDefaultConstructAssignString();
|
||||
// Not assignable
|
||||
void operator=(const NonDefaultConstructAssignString&);
|
||||
};
|
||||
|
||||
TEST(CombineTest, NonDefaultConstructAssign) {
|
||||
const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen =
|
||||
const ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> > gen =
|
||||
Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
|
||||
NonDefaultConstructAssignString("B")));
|
||||
|
||||
ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it =
|
||||
gen.begin();
|
||||
ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> >::iterator
|
||||
it = gen.begin();
|
||||
|
||||
EXPECT_EQ(0, std::get<0>(*it));
|
||||
EXPECT_EQ("A", std::get<1>(*it).str());
|
||||
|
|
@ -579,8 +530,6 @@ TEST(CombineTest, NonDefaultConstructAssign) {
|
|||
EXPECT_TRUE(it == gen.end());
|
||||
}
|
||||
|
||||
#endif // GTEST_LANG_CXX11
|
||||
# endif // GTEST_HAS_COMBINE
|
||||
|
||||
// Tests that an generator produces correct sequence after being
|
||||
// assigned from another generator.
|
||||
|
|
@ -595,12 +544,12 @@ TEST(ParamGeneratorTest, AssignmentWorks) {
|
|||
|
||||
// This test verifies that the tests are expanded and run as specified:
|
||||
// one test per element from the sequence produced by the generator
|
||||
// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's
|
||||
// specified in INSTANTIATE_TEST_SUITE_P. It also verifies that the test's
|
||||
// fixture constructor, SetUp(), and TearDown() have run and have been
|
||||
// supplied with the correct parameters.
|
||||
|
||||
// The use of environment object allows detection of the case where no test
|
||||
// case functionality is run at all. In this case TestCaseTearDown will not
|
||||
// case functionality is run at all. In this case TearDownTestSuite will not
|
||||
// be able to detect missing tests, naturally.
|
||||
template <int kExpectedCalls>
|
||||
class TestGenerationEnvironment : public ::testing::Environment {
|
||||
|
|
@ -615,7 +564,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
|
|||
void TearDownExecuted() { tear_down_count_++; }
|
||||
void TestBodyExecuted() { test_body_count_++; }
|
||||
|
||||
virtual void TearDown() {
|
||||
void TearDown() override {
|
||||
// If all MultipleTestGenerationTest tests have been de-selected
|
||||
// by the filter flag, the following checks make no sense.
|
||||
bool perform_check = false;
|
||||
|
|
@ -672,16 +621,16 @@ class TestGenerationTest : public TestWithParam<int> {
|
|||
Environment::Instance()->FixtureConstructorExecuted();
|
||||
current_parameter_ = GetParam();
|
||||
}
|
||||
virtual void SetUp() {
|
||||
void SetUp() override {
|
||||
Environment::Instance()->SetUpExecuted();
|
||||
EXPECT_EQ(current_parameter_, GetParam());
|
||||
}
|
||||
virtual void TearDown() {
|
||||
void TearDown() override {
|
||||
Environment::Instance()->TearDownExecuted();
|
||||
EXPECT_EQ(current_parameter_, GetParam());
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
static void SetUpTestSuite() {
|
||||
bool all_tests_in_test_case_selected = true;
|
||||
|
||||
for (int i = 0; i < PARAMETER_COUNT; ++i) {
|
||||
|
|
@ -702,7 +651,7 @@ class TestGenerationTest : public TestWithParam<int> {
|
|||
collected_parameters_.clear();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
static void TearDownTestSuite() {
|
||||
vector<int> expected_values(test_generation_params,
|
||||
test_generation_params + PARAMETER_COUNT);
|
||||
// Test execution order is not guaranteed by Google Test,
|
||||
|
|
@ -728,17 +677,17 @@ TEST_P(TestGenerationTest, TestsExpandedAndRun) {
|
|||
EXPECT_EQ(current_parameter_, GetParam());
|
||||
collected_parameters_.push_back(GetParam());
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,
|
||||
ValuesIn(test_generation_params));
|
||||
INSTANTIATE_TEST_SUITE_P(TestExpansionModule, TestGenerationTest,
|
||||
ValuesIn(test_generation_params));
|
||||
|
||||
// This test verifies that the element sequence (third parameter of
|
||||
// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at
|
||||
// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS(). For
|
||||
// INSTANTIATE_TEST_SUITE_P) is evaluated in InitGoogleTest() and neither at
|
||||
// the call site of INSTANTIATE_TEST_SUITE_P nor in RUN_ALL_TESTS(). For
|
||||
// that, we declare param_value_ to be a static member of
|
||||
// GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
|
||||
// main(), just before invocation of InitGoogleTest(). After calling
|
||||
// InitGoogleTest(), we set the value to 2. If the sequence is evaluated
|
||||
// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a
|
||||
// before or after InitGoogleTest, INSTANTIATE_TEST_SUITE_P will create a
|
||||
// test with parameter other than 1, and the test body will fail the
|
||||
// assertion.
|
||||
class GeneratorEvaluationTest : public TestWithParam<int> {
|
||||
|
|
@ -754,9 +703,8 @@ int GeneratorEvaluationTest::param_value_ = 0;
|
|||
TEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
|
||||
EXPECT_EQ(1, GetParam());
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(GenEvalModule,
|
||||
GeneratorEvaluationTest,
|
||||
Values(GeneratorEvaluationTest::param_value()));
|
||||
INSTANTIATE_TEST_SUITE_P(GenEvalModule, GeneratorEvaluationTest,
|
||||
Values(GeneratorEvaluationTest::param_value()));
|
||||
|
||||
// Tests that generators defined in a different translation unit are
|
||||
// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
|
||||
|
|
@ -767,9 +715,8 @@ TEST_P(ExternalGeneratorTest, ExternalGenerator) {
|
|||
// which we verify here.
|
||||
EXPECT_EQ(GetParam(), 33);
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,
|
||||
ExternalGeneratorTest,
|
||||
extern_gen);
|
||||
INSTANTIATE_TEST_SUITE_P(ExternalGeneratorModule, ExternalGeneratorTest,
|
||||
extern_gen);
|
||||
|
||||
// Tests that a parameterized test case can be defined in one translation
|
||||
// unit and instantiated in another. This test will be instantiated in
|
||||
|
|
@ -784,20 +731,19 @@ TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
|
|||
class MultipleInstantiationTest : public TestWithParam<int> {};
|
||||
TEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
|
||||
INSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
|
||||
INSTANTIATE_TEST_SUITE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
|
||||
INSTANTIATE_TEST_SUITE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
|
||||
|
||||
// Tests that a parameterized test case can be instantiated
|
||||
// in multiple translation units. This test will be instantiated
|
||||
// here and in gtest-param-test_test2.cc.
|
||||
// InstantiationInMultipleTranslationUnitsTest fixture class
|
||||
// is defined in gtest-param-test_test.h.
|
||||
TEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {
|
||||
TEST_P(InstantiationInMultipleTranslationUnitsTest, IsMultipleOf42) {
|
||||
EXPECT_EQ(0, GetParam() % 42);
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(Sequence1,
|
||||
InstantiationInMultipleTranslaionUnitsTest,
|
||||
Values(42, 42*2));
|
||||
INSTANTIATE_TEST_SUITE_P(Sequence1, InstantiationInMultipleTranslationUnitsTest,
|
||||
Values(42, 42 * 2));
|
||||
|
||||
// Tests that each iteration of parameterized test runs in a separate test
|
||||
// object.
|
||||
|
|
@ -805,7 +751,7 @@ class SeparateInstanceTest : public TestWithParam<int> {
|
|||
public:
|
||||
SeparateInstanceTest() : count_(0) {}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
static void TearDownTestSuite() {
|
||||
EXPECT_GE(global_count_, 2)
|
||||
<< "If some (but not all) SeparateInstanceTest tests have been "
|
||||
<< "filtered out this test will fail. Make sure that all "
|
||||
|
|
@ -823,20 +769,20 @@ TEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
|
|||
EXPECT_EQ(0, count_++);
|
||||
global_count_++;
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
|
||||
INSTANTIATE_TEST_SUITE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
|
||||
|
||||
// Tests that all instantiations of a test have named appropriately. Test
|
||||
// defined with TEST_P(TestCaseName, TestName) and instantiated with
|
||||
// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named
|
||||
// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the
|
||||
// sequence element used to instantiate the test.
|
||||
// defined with TEST_P(TestSuiteName, TestName) and instantiated with
|
||||
// INSTANTIATE_TEST_SUITE_P(SequenceName, TestSuiteName, generator) must be
|
||||
// named SequenceName/TestSuiteName.TestName/i, where i is the 0-based index of
|
||||
// the sequence element used to instantiate the test.
|
||||
class NamingTest : public TestWithParam<int> {};
|
||||
|
||||
TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
|
||||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
|
||||
EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_case_name());
|
||||
EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_suite_name());
|
||||
|
||||
Message index_stream;
|
||||
index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
|
||||
|
|
@ -845,7 +791,7 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
|
|||
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
|
||||
INSTANTIATE_TEST_SUITE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
|
||||
|
||||
// Tests that macros in test names are expanded correctly.
|
||||
class MacroNamingTest : public TestWithParam<int> {};
|
||||
|
|
@ -857,11 +803,11 @@ TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) {
|
|||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
|
||||
EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name());
|
||||
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
||||
EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_suite_name());
|
||||
EXPECT_STREQ("FooSomeTestName/0", test_info->name());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42));
|
||||
INSTANTIATE_TEST_SUITE_P(FortyTwo, MacroNamingTest, Values(42));
|
||||
|
||||
// Tests the same thing for non-parametrized tests.
|
||||
class MacroNamingTestNonParametrized : public ::testing::Test {};
|
||||
|
|
@ -871,10 +817,40 @@ TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized),
|
|||
const ::testing::TestInfo* const test_info =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
|
||||
EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name());
|
||||
EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_suite_name());
|
||||
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
||||
}
|
||||
|
||||
TEST(MacroNameing, LookupNames) {
|
||||
std::set<std::string> know_suite_names, know_test_names;
|
||||
|
||||
auto ins = testing::UnitTest::GetInstance();
|
||||
int ts = 0;
|
||||
while (const testing::TestSuite* suite = ins->GetTestSuite(ts++)) {
|
||||
know_suite_names.insert(suite->name());
|
||||
|
||||
int ti = 0;
|
||||
while (const testing::TestInfo* info = suite->GetTestInfo(ti++)) {
|
||||
know_test_names.insert(std::string(suite->name()) + "." + info->name());
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the expected form of the test suit name actually exists.
|
||||
EXPECT_NE( //
|
||||
know_suite_names.find("FortyTwo/MacroNamingTest"),
|
||||
know_suite_names.end());
|
||||
EXPECT_NE(
|
||||
know_suite_names.find("MacroNamingTestNonParametrized"),
|
||||
know_suite_names.end());
|
||||
// Check that the expected form of the test name actually exists.
|
||||
EXPECT_NE( //
|
||||
know_test_names.find("FortyTwo/MacroNamingTest.FooSomeTestName/0"),
|
||||
know_test_names.end());
|
||||
EXPECT_NE(
|
||||
know_test_names.find("MacroNamingTestNonParametrized.FooSomeTestName"),
|
||||
know_test_names.end());
|
||||
}
|
||||
|
||||
// Tests that user supplied custom parameter names are working correctly.
|
||||
// Runs the test with a builtin helper method which uses PrintToString,
|
||||
// as well as a custom function and custom functor to ensure all possible
|
||||
|
|
@ -888,17 +864,14 @@ struct CustomParamNameFunctor {
|
|||
}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CustomParamNameFunctor,
|
||||
CustomFunctorNamingTest,
|
||||
Values(std::string("FunctorName")),
|
||||
CustomParamNameFunctor());
|
||||
INSTANTIATE_TEST_SUITE_P(CustomParamNameFunctor, CustomFunctorNamingTest,
|
||||
Values(std::string("FunctorName")),
|
||||
CustomParamNameFunctor());
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
|
||||
CustomFunctorNamingTest,
|
||||
Values("abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"01234567890_"),
|
||||
CustomParamNameFunctor());
|
||||
INSTANTIATE_TEST_SUITE_P(AllAllowedCharacters, CustomFunctorNamingTest,
|
||||
Values("abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "01234567890_"),
|
||||
CustomParamNameFunctor());
|
||||
|
||||
inline std::string CustomParamNameFunction(
|
||||
const ::testing::TestParamInfo<std::string>& inf) {
|
||||
|
|
@ -908,45 +881,41 @@ inline std::string CustomParamNameFunction(
|
|||
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
|
||||
TEST_P(CustomFunctionNamingTest, CustomTestNames) {}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
|
||||
CustomFunctionNamingTest,
|
||||
Values(std::string("FunctionName")),
|
||||
CustomParamNameFunction);
|
||||
INSTANTIATE_TEST_SUITE_P(CustomParamNameFunction, CustomFunctionNamingTest,
|
||||
Values(std::string("FunctionName")),
|
||||
CustomParamNameFunction);
|
||||
|
||||
#if GTEST_LANG_CXX11
|
||||
INSTANTIATE_TEST_SUITE_P(CustomParamNameFunctionP, CustomFunctionNamingTest,
|
||||
Values(std::string("FunctionNameP")),
|
||||
&CustomParamNameFunction);
|
||||
|
||||
// Test custom naming with a lambda
|
||||
|
||||
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
|
||||
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest,
|
||||
Values(std::string("LambdaName")),
|
||||
[](const ::testing::TestParamInfo<std::string>& inf) {
|
||||
return inf.param;
|
||||
});
|
||||
|
||||
#endif // GTEST_LANG_CXX11
|
||||
INSTANTIATE_TEST_SUITE_P(CustomParamNameLambda, CustomLambdaNamingTest,
|
||||
Values(std::string("LambdaName")),
|
||||
[](const ::testing::TestParamInfo<std::string>& inf) {
|
||||
return inf.param;
|
||||
});
|
||||
|
||||
TEST(CustomNamingTest, CheckNameRegistry) {
|
||||
::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance();
|
||||
std::set<std::string> test_names;
|
||||
for (int case_num = 0;
|
||||
case_num < unit_test->total_test_case_count();
|
||||
++case_num) {
|
||||
const ::testing::TestCase* test_case = unit_test->GetTestCase(case_num);
|
||||
for (int test_num = 0;
|
||||
test_num < test_case->total_test_count();
|
||||
for (int suite_num = 0; suite_num < unit_test->total_test_suite_count();
|
||||
++suite_num) {
|
||||
const ::testing::TestSuite* test_suite = unit_test->GetTestSuite(suite_num);
|
||||
for (int test_num = 0; test_num < test_suite->total_test_count();
|
||||
++test_num) {
|
||||
const ::testing::TestInfo* test_info = test_case->GetTestInfo(test_num);
|
||||
const ::testing::TestInfo* test_info = test_suite->GetTestInfo(test_num);
|
||||
test_names.insert(std::string(test_info->name()));
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctorName"));
|
||||
EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctionName"));
|
||||
#if GTEST_LANG_CXX11
|
||||
EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctionNameP"));
|
||||
EXPECT_EQ(1u, test_names.count("CustomTestNames/LambdaName"));
|
||||
#endif // GTEST_LANG_CXX11
|
||||
}
|
||||
|
||||
// Test a numeric name to ensure PrintToStringParamName works correctly.
|
||||
|
|
@ -961,10 +930,8 @@ TEST_P(CustomIntegerNamingTest, TestsReportCorrectNames) {
|
|||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PrintToString,
|
||||
CustomIntegerNamingTest,
|
||||
Range(0, 5),
|
||||
::testing::PrintToStringParamName());
|
||||
INSTANTIATE_TEST_SUITE_P(PrintToString, CustomIntegerNamingTest, Range(0, 5),
|
||||
::testing::PrintToStringParamName());
|
||||
|
||||
// Test a custom struct with PrintToString.
|
||||
|
||||
|
|
@ -988,10 +955,9 @@ TEST_P(CustomStructNamingTest, TestsReportCorrectNames) {
|
|||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PrintToString,
|
||||
CustomStructNamingTest,
|
||||
Values(CustomStruct(0), CustomStruct(1)),
|
||||
::testing::PrintToStringParamName());
|
||||
INSTANTIATE_TEST_SUITE_P(PrintToString, CustomStructNamingTest,
|
||||
Values(CustomStruct(0), CustomStruct(1)),
|
||||
::testing::PrintToStringParamName());
|
||||
|
||||
// Test that using a stateful parameter naming function works as expected.
|
||||
|
||||
|
|
@ -1020,10 +986,8 @@ TEST_P(StatefulNamingTest, TestsReportCorrectNames) {
|
|||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(StatefulNamingFunctor,
|
||||
StatefulNamingTest,
|
||||
Range(0, 5),
|
||||
StatefulNamingFunctor());
|
||||
INSTANTIATE_TEST_SUITE_P(StatefulNamingFunctor, StatefulNamingTest, Range(0, 5),
|
||||
StatefulNamingFunctor());
|
||||
|
||||
// Class that cannot be streamed into an ostream. It needs to be copyable
|
||||
// (and, in case of MSVC, also assignable) in order to be a test parameter
|
||||
|
|
@ -1032,6 +996,8 @@ INSTANTIATE_TEST_CASE_P(StatefulNamingFunctor,
|
|||
class Unstreamable {
|
||||
public:
|
||||
explicit Unstreamable(int value) : value_(value) {}
|
||||
// -Wunused-private-field: dummy accessor for `value_`.
|
||||
const int& dummy_value() const { return value_; }
|
||||
|
||||
private:
|
||||
int value_;
|
||||
|
|
@ -1046,9 +1012,8 @@ TEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
|
|||
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(InstantiationWithComments,
|
||||
CommentTest,
|
||||
Values(Unstreamable(1)));
|
||||
INSTANTIATE_TEST_SUITE_P(InstantiationWithComments, CommentTest,
|
||||
Values(Unstreamable(1)));
|
||||
|
||||
// Verify that we can create a hierarchy of test fixtures, where the base
|
||||
// class fixture is not parameterized and the derived class is. In this case
|
||||
|
|
@ -1088,19 +1053,64 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
|
|||
".* value-parameterized test .*");
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
|
||||
INSTANTIATE_TEST_SUITE_P(RangeZeroToFive, ParameterizedDerivedTest,
|
||||
Range(0, 5));
|
||||
|
||||
// Tests param generator working with Enums
|
||||
enum MyEnums {
|
||||
ENUM1 = 1,
|
||||
ENUM2 = 3,
|
||||
ENUM3 = 8,
|
||||
};
|
||||
|
||||
class MyEnumTest : public testing::TestWithParam<MyEnums> {};
|
||||
|
||||
TEST_P(MyEnumTest, ChecksParamMoreThanZero) { EXPECT_GE(10, GetParam()); }
|
||||
INSTANTIATE_TEST_SUITE_P(MyEnumTests, MyEnumTest,
|
||||
::testing::Values(ENUM1, ENUM2, 0));
|
||||
|
||||
namespace works_here {
|
||||
// Never used not instantiated, this should work.
|
||||
class NotUsedTest : public testing::TestWithParam<int> {};
|
||||
|
||||
///////
|
||||
// Never used not instantiated, this should work.
|
||||
template <typename T>
|
||||
class NotUsedTypeTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(NotUsedTypeTest);
|
||||
|
||||
// Used but not instantiated, this would fail. but...
|
||||
class NotInstantiatedTest : public testing::TestWithParam<int> {};
|
||||
// ... we mark is as allowed.
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(NotInstantiatedTest);
|
||||
|
||||
TEST_P(NotInstantiatedTest, Used) { }
|
||||
|
||||
using OtherName = NotInstantiatedTest;
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(OtherName);
|
||||
TEST_P(OtherName, Used) { }
|
||||
|
||||
// Used but not instantiated, this would fail. but...
|
||||
template <typename T>
|
||||
class NotInstantiatedTypeTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(NotInstantiatedTypeTest);
|
||||
// ... we mark is as allowed.
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(NotInstantiatedTypeTest);
|
||||
|
||||
TYPED_TEST_P(NotInstantiatedTypeTest, Used) { }
|
||||
REGISTER_TYPED_TEST_SUITE_P(NotInstantiatedTypeTest, Used);
|
||||
} // namespace works_here
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Used in TestGenerationTest test case.
|
||||
// Used in TestGenerationTest test suite.
|
||||
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
|
||||
// Used in GeneratorEvaluationTest test case. Tests that the updated value
|
||||
// Used in GeneratorEvaluationTest test suite. Tests that the updated value
|
||||
// will be picked up for instantiating tests in GeneratorEvaluationTest.
|
||||
GeneratorEvaluationTest::set_param_value(1);
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
// Used in GeneratorEvaluationTest test case. Tests that value updated
|
||||
// Used in GeneratorEvaluationTest test suite. Tests that value updated
|
||||
// here will NOT be used for instantiating tests in
|
||||
// GeneratorEvaluationTest.
|
||||
GeneratorEvaluationTest::set_param_value(2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue