gtest_list_tests_unittest_.cc
Go to the documentation of this file.
00001 // Copyright 2006, Google Inc.
00002 // All rights reserved.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are
00006 // met:
00007 //
00008 //     * Redistributions of source code must retain the above copyright
00009 // notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above
00011 // copyright notice, this list of conditions and the following disclaimer
00012 // in the documentation and/or other materials provided with the
00013 // distribution.
00014 //     * Neither the name of Google Inc. nor the names of its
00015 // contributors may be used to endorse or promote products derived from
00016 // this software without specific prior written permission.
00017 //
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // Author: phanna@google.com (Patrick Hanna)
00031 
00032 // Unit test for Google Test's --gtest_list_tests flag.
00033 //
00034 // A user can ask Google Test to list all tests that will run
00035 // so that when using a filter, a user will know what
00036 // tests to look for. The tests will not be run after listing.
00037 //
00038 // This program will be invoked from a Python unit test.
00039 // Don't run it directly.
00040 
00041 #include "gtest/gtest.h"
00042 
00043 // Several different test cases and tests that will be listed.
00044 TEST(Foo, Bar1) {
00045 }
00046 
00047 TEST(Foo, Bar2) {
00048 }
00049 
00050 TEST(Foo, DISABLED_Bar3) {
00051 }
00052 
00053 TEST(Abc, Xyz) {
00054 }
00055 
00056 TEST(Abc, Def) {
00057 }
00058 
00059 TEST(FooBar, Baz) {
00060 }
00061 
00062 class FooTest : public testing::Test {
00063 };
00064 
00065 TEST_F(FooTest, Test1) {
00066 }
00067 
00068 TEST_F(FooTest, DISABLED_Test2) {
00069 }
00070 
00071 TEST_F(FooTest, Test3) {
00072 }
00073 
00074 TEST(FooDeathTest, Test1) {
00075 }
00076 
00077 // A group of value-parameterized tests.
00078 
00079 class MyType {
00080  public:
00081   explicit MyType(const std::string& a_value) : value_(a_value) {}
00082 
00083   const std::string& value() const { return value_; }
00084 
00085  private:
00086   std::string value_;
00087 };
00088 
00089 // Teaches Google Test how to print a MyType.
00090 void PrintTo(const MyType& x, std::ostream* os) {
00091   *os << x.value();
00092 }
00093 
00094 class ValueParamTest : public testing::TestWithParam<MyType> {
00095 };
00096 
00097 TEST_P(ValueParamTest, TestA) {
00098 }
00099 
00100 TEST_P(ValueParamTest, TestB) {
00101 }
00102 
00103 INSTANTIATE_TEST_CASE_P(
00104     MyInstantiation, ValueParamTest,
00105     testing::Values(MyType("one line"),
00106                     MyType("two\nlines"),
00107                     MyType("a very\nloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line")));  // NOLINT
00108 
00109 // A group of typed tests.
00110 
00111 // A deliberately long type name for testing the line-truncating
00112 // behavior when printing a type parameter.
00113 class VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName {  // NOLINT
00114 };
00115 
00116 template <typename T>
00117 class TypedTest : public testing::Test {
00118 };
00119 
00120 template <typename T, int kSize>
00121 class MyArray {
00122 };
00123 
00124 typedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName,  // NOLINT
00125                        int*, MyArray<bool, 42> > MyTypes;
00126 
00127 TYPED_TEST_CASE(TypedTest, MyTypes);
00128 
00129 TYPED_TEST(TypedTest, TestA) {
00130 }
00131 
00132 TYPED_TEST(TypedTest, TestB) {
00133 }
00134 
00135 // A group of type-parameterized tests.
00136 
00137 template <typename T>
00138 class TypeParamTest : public testing::Test {
00139 };
00140 
00141 TYPED_TEST_CASE_P(TypeParamTest);
00142 
00143 TYPED_TEST_P(TypeParamTest, TestA) {
00144 }
00145 
00146 TYPED_TEST_P(TypeParamTest, TestB) {
00147 }
00148 
00149 REGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB);
00150 
00151 INSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes);
00152 
00153 int main(int argc, char **argv) {
00154   ::testing::InitGoogleTest(&argc, argv);
00155 
00156   return RUN_ALL_TESTS();
00157 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:04