1 // Copyright 2013, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 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 13 // distribution. 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. 17 // 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. 29 30 // 31 // Each TEST() expands to some static registration logic. GCC puts all 32 // such static initialization logic for a translation unit in a common, 33 // internal function. Since Google's build system restricts how much 34 // stack space a function can use, there's a limit on how many TEST()s 35 // one can put in a single C++ test file. This test ensures that a large 36 // number of TEST()s can be defined in the same translation unit. 37 38 #include "gtest/gtest.h" 39 40 // This macro defines 10 dummy tests. 41 #define TEN_TESTS_(test_case_name) \ 42 TEST(test_case_name, T0) {} \ 43 TEST(test_case_name, T1) {} \ 44 TEST(test_case_name, T2) {} \ 45 TEST(test_case_name, T3) {} \ 46 TEST(test_case_name, T4) {} \ 47 TEST(test_case_name, T5) {} \ 48 TEST(test_case_name, T6) {} \ 49 TEST(test_case_name, T7) {} \ 50 TEST(test_case_name, T8) {} \ 51 TEST(test_case_name, T9) {} 52 53 // This macro defines 100 dummy tests. 54 #define HUNDRED_TESTS_(test_case_name_prefix) \ 55 TEN_TESTS_(test_case_name_prefix ## 0) \ 56 TEN_TESTS_(test_case_name_prefix ## 1) \ 57 TEN_TESTS_(test_case_name_prefix ## 2) \ 58 TEN_TESTS_(test_case_name_prefix ## 3) \ 59 TEN_TESTS_(test_case_name_prefix ## 4) \ 60 TEN_TESTS_(test_case_name_prefix ## 5) \ 61 TEN_TESTS_(test_case_name_prefix ## 6) \ 62 TEN_TESTS_(test_case_name_prefix ## 7) \ 63 TEN_TESTS_(test_case_name_prefix ## 8) \ 64 TEN_TESTS_(test_case_name_prefix ## 9) 65 66 // This macro defines 1000 dummy tests. 67 #define THOUSAND_TESTS_(test_case_name_prefix) \ 68 HUNDRED_TESTS_(test_case_name_prefix ## 0) \ 69 HUNDRED_TESTS_(test_case_name_prefix ## 1) \ 70 HUNDRED_TESTS_(test_case_name_prefix ## 2) \ 71 HUNDRED_TESTS_(test_case_name_prefix ## 3) \ 72 HUNDRED_TESTS_(test_case_name_prefix ## 4) \ 73 HUNDRED_TESTS_(test_case_name_prefix ## 5) \ 74 HUNDRED_TESTS_(test_case_name_prefix ## 6) \ 75 HUNDRED_TESTS_(test_case_name_prefix ## 7) \ 76 HUNDRED_TESTS_(test_case_name_prefix ## 8) \ 77 HUNDRED_TESTS_(test_case_name_prefix ## 9) 78 79 // Ensures that we can define 1000 TEST()s in the same translation 80 // unit. 81 THOUSAND_TESTS_(T) 82 83 int main(int argc, char **argv) { 84 testing::InitGoogleTest(&argc, argv); 85 86 // We don't actually need to run the dummy tests - the purpose is to 87 // ensure that they compile. 88 return 0; 89 } 90