]>
git.proxmox.com Git - ceph.git/blob - ceph/src/c-ares/test/gmock-1.7.0/gtest/test/gtest_filter_unittest_.cc
1 // Copyright 2005, Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // Author: wan@google.com (Zhanyong Wan)
32 // Unit test for Google Test test filters.
34 // A user can specify which test(s) in a Google Test program to run via
35 // either the GTEST_FILTER environment variable or the --gtest_filter
36 // flag. This is used for testing such functionality.
38 // The program will be invoked from a Python unit test. Don't run it
41 #include "gtest/gtest.h"
47 class FooTest
: public testing::Test
{
50 TEST_F(FooTest
, Abc
) {
53 TEST_F(FooTest
, Xyz
) {
54 FAIL() << "Expected failure.";
59 TEST(BarTest
, TestOne
) {
62 TEST(BarTest
, TestTwo
) {
65 TEST(BarTest
, TestThree
) {
68 TEST(BarTest
, DISABLED_TestFour
) {
69 FAIL() << "Expected failure.";
72 TEST(BarTest
, DISABLED_TestFive
) {
73 FAIL() << "Expected failure.";
78 TEST(BazTest
, TestOne
) {
79 FAIL() << "Expected failure.";
82 TEST(BazTest
, TestA
) {
85 TEST(BazTest
, TestB
) {
88 TEST(BazTest
, DISABLED_TestC
) {
89 FAIL() << "Expected failure.";
92 // Test case HasDeathTest
94 TEST(HasDeathTest
, Test1
) {
95 EXPECT_DEATH_IF_SUPPORTED(exit(1), ".*");
98 // We need at least two death tests to make sure that the all death tests
99 // aren't on the first shard.
100 TEST(HasDeathTest
, Test2
) {
101 EXPECT_DEATH_IF_SUPPORTED(exit(1), ".*");
104 // Test case FoobarTest
106 TEST(DISABLED_FoobarTest
, Test1
) {
107 FAIL() << "Expected failure.";
110 TEST(DISABLED_FoobarTest
, DISABLED_Test2
) {
111 FAIL() << "Expected failure.";
114 // Test case FoobarbazTest
116 TEST(DISABLED_FoobarbazTest
, TestA
) {
117 FAIL() << "Expected failure.";
120 #if GTEST_HAS_PARAM_TEST
121 class ParamTest
: public testing::TestWithParam
<int> {
124 TEST_P(ParamTest
, TestX
) {
127 TEST_P(ParamTest
, TestY
) {
130 INSTANTIATE_TEST_CASE_P(SeqP
, ParamTest
, testing::Values(1, 2));
131 INSTANTIATE_TEST_CASE_P(SeqQ
, ParamTest
, testing::Values(5, 6));
132 #endif // GTEST_HAS_PARAM_TEST
136 int main(int argc
, char **argv
) {
137 ::testing::InitGoogleTest(&argc
, argv
);
139 return RUN_ALL_TESTS();