googletest-list-tests-unittest_.cc (googletest-release-1.11.0) | : | googletest-list-tests-unittest_.cc (googletest-release-1.12.0) | ||
---|---|---|---|---|
skipping to change at line 42 | skipping to change at line 42 | |||
// A user can ask Google Test to list all tests that will run | // A user can ask Google Test to list all tests that will run | |||
// so that when using a filter, a user will know what | // so that when using a filter, a user will know what | |||
// tests to look for. The tests will not be run after listing. | // tests to look for. The tests will not be run after listing. | |||
// | // | |||
// This program will be invoked from a Python unit test. | // This program will be invoked from a Python unit test. | |||
// Don't run it directly. | // Don't run it directly. | |||
#include "gtest/gtest.h" | #include "gtest/gtest.h" | |||
// Several different test cases and tests that will be listed. | // Several different test cases and tests that will be listed. | |||
TEST(Foo, Bar1) { | TEST(Foo, Bar1) {} | |||
} | ||||
TEST(Foo, Bar2) { | TEST(Foo, Bar2) {} | |||
} | ||||
TEST(Foo, DISABLED_Bar3) { | TEST(Foo, DISABLED_Bar3) {} | |||
} | ||||
TEST(Abc, Xyz) { | TEST(Abc, Xyz) {} | |||
} | ||||
TEST(Abc, Def) { | TEST(Abc, Def) {} | |||
} | ||||
TEST(FooBar, Baz) { | TEST(FooBar, Baz) {} | |||
} | ||||
class FooTest : public testing::Test { | class FooTest : public testing::Test {}; | |||
}; | ||||
TEST_F(FooTest, Test1) { | TEST_F(FooTest, Test1) {} | |||
} | ||||
TEST_F(FooTest, DISABLED_Test2) { | TEST_F(FooTest, DISABLED_Test2) {} | |||
} | ||||
TEST_F(FooTest, Test3) { | TEST_F(FooTest, Test3) {} | |||
} | ||||
TEST(FooDeathTest, Test1) { | TEST(FooDeathTest, Test1) {} | |||
} | ||||
// A group of value-parameterized tests. | // A group of value-parameterized tests. | |||
class MyType { | class MyType { | |||
public: | public: | |||
explicit MyType(const std::string& a_value) : value_(a_value) {} | explicit MyType(const std::string& a_value) : value_(a_value) {} | |||
const std::string& value() const { return value_; } | const std::string& value() const { return value_; } | |||
private: | private: | |||
std::string value_; | std::string value_; | |||
}; | }; | |||
// Teaches Google Test how to print a MyType. | // Teaches Google Test how to print a MyType. | |||
void PrintTo(const MyType& x, std::ostream* os) { | void PrintTo(const MyType& x, std::ostream* os) { *os << x.value(); } | |||
*os << x.value(); | ||||
} | ||||
class ValueParamTest : public testing::TestWithParam<MyType> { | class ValueParamTest : public testing::TestWithParam<MyType> {}; | |||
}; | ||||
TEST_P(ValueParamTest, TestA) { | TEST_P(ValueParamTest, TestA) {} | |||
} | ||||
TEST_P(ValueParamTest, TestB) { | TEST_P(ValueParamTest, TestB) {} | |||
} | ||||
INSTANTIATE_TEST_SUITE_P( | INSTANTIATE_TEST_SUITE_P( | |||
MyInstantiation, ValueParamTest, | MyInstantiation, ValueParamTest, | |||
testing::Values(MyType("one line"), | testing::Values( | |||
MyType("two\nlines"), | MyType("one line"), MyType("two\nlines"), | |||
MyType("a very\nlooooooooooooooooooooooooooooooooooooooooooo | MyType("a " | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | "very\nloooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | |||
ooooooooooooooooooooooooooooooooooooooooooooooong line"))); // NOLINT | "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | |||
"ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | ||||
"ooooong line"))); // NOLINT | ||||
// A group of typed tests. | // A group of typed tests. | |||
// A deliberately long type name for testing the line-truncating | // A deliberately long type name for testing the line-truncating | |||
// behavior when printing a type parameter. | // behavior when printing a type parameter. | |||
class VeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | class | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | VeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
ooooooooooooooooooooogName { // NOLINT | oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
ooooooooooooooooooogName { // NOLINT | ||||
}; | }; | |||
template <typename T> | template <typename T> | |||
class TypedTest : public testing::Test { | class TypedTest : public testing::Test {}; | |||
}; | ||||
template <typename T, int kSize> | template <typename T, int kSize> | |||
class MyArray { | class MyArray {}; | |||
}; | ||||
typedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooo | typedef testing::Types< | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | VeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
oooooooooooooooooooooooooooooooooooooogName, // NOLINT | oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | |||
int*, MyArray<bool, 42> > MyTypes; | ooooooooooooooooooogName, // NOLINT | |||
int*, MyArray<bool, 42> > | ||||
MyTypes; | ||||
TYPED_TEST_SUITE(TypedTest, MyTypes); | TYPED_TEST_SUITE(TypedTest, MyTypes); | |||
TYPED_TEST(TypedTest, TestA) { | TYPED_TEST(TypedTest, TestA) {} | |||
} | ||||
TYPED_TEST(TypedTest, TestB) { | TYPED_TEST(TypedTest, TestB) {} | |||
} | ||||
// A group of type-parameterized tests. | // A group of type-parameterized tests. | |||
template <typename T> | template <typename T> | |||
class TypeParamTest : public testing::Test { | class TypeParamTest : public testing::Test {}; | |||
}; | ||||
TYPED_TEST_SUITE_P(TypeParamTest); | TYPED_TEST_SUITE_P(TypeParamTest); | |||
TYPED_TEST_P(TypeParamTest, TestA) { | TYPED_TEST_P(TypeParamTest, TestA) {} | |||
} | ||||
TYPED_TEST_P(TypeParamTest, TestB) { | TYPED_TEST_P(TypeParamTest, TestB) {} | |||
} | ||||
REGISTER_TYPED_TEST_SUITE_P(TypeParamTest, TestA, TestB); | REGISTER_TYPED_TEST_SUITE_P(TypeParamTest, TestA, TestB); | |||
INSTANTIATE_TYPED_TEST_SUITE_P(My, TypeParamTest, MyTypes); | INSTANTIATE_TYPED_TEST_SUITE_P(My, TypeParamTest, MyTypes); | |||
int main(int argc, char **argv) { | int main(int argc, char** argv) { | |||
::testing::InitGoogleTest(&argc, argv); | ::testing::InitGoogleTest(&argc, argv); | |||
return RUN_ALL_TESTS(); | return RUN_ALL_TESTS(); | |||
} | } | |||
End of changes. 26 change blocks. | ||||
61 lines changed or deleted | 43 lines changed or added |