llvm.org GIT mirror llvm / 7ae6ff4
Import of Google Test 1.2.1, with the non-essential bits removed. Added a README.LLVM file to indicate which files and directories were removed from the original source tarball. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61526 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 10 years ago
30 changed file(s) with 22432 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6565 llvm/projects/ModuleMaker/autoconf
6666 llvm/projects/sample/autoconf
6767 CellSPU backend llvm/lib/Target/CellSPU/README.txt
68
69
68 Google Test llvm/utils/unittest/googletest/COPYING
0 Copyright 2008, Google Inc.
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions are
5 met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of Google Inc. nor the names of its
14 contributors may be used to endorse or promote products derived from
15 this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 LLVM notes
1 ----------
2
3 This directory contains Google Test 1.2.1, with all elements removed except for
4 the actual source code, to minimize the addition to the LLVM distribution.
5
6 Cleaned up as follows:
7 $ rm -f aclocal* configure* Makefile* CHANGES CONTRIBUTORS README
8 $ rm -rf build-aux m4 make msvc samples scons scripts test xcode
9
10 # Clean up source files used for generating headers
11 $ rm -f `find . -name \*\.pump`
12
13 For the license, see the file COPYING in this directory.
0 // Copyright 2005, Google Inc.
1 // All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: wan@google.com (Zhanyong Wan)
30 //
31 // The Google C++ Testing Framework (Google Test)
32 //
33 // This header file defines the public API for death tests. It is
34 // #included by gtest.h so a user doesn't need to include this
35 // directly.
36
37 #ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
38 #define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
39
40 #include
41
42 namespace testing {
43
44 // This flag controls the style of death tests. Valid values are "threadsafe",
45 // meaning that the death test child process will re-execute the test binary
46 // from the start, running only a single death test, or "fast",
47 // meaning that the child process will execute the test logic immediately
48 // after forking.
49 GTEST_DECLARE_string_(death_test_style);
50
51 #ifdef GTEST_HAS_DEATH_TEST
52
53 // The following macros are useful for writing death tests.
54
55 // Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
56 // executed:
57 //
58 // 1. It generates a warning if there is more than one active
59 // thread. This is because it's safe to fork() or clone() only
60 // when there is a single thread.
61 //
62 // 2. The parent process clone()s a sub-process and runs the death
63 // test in it; the sub-process exits with code 0 at the end of the
64 // death test, if it hasn't exited already.
65 //
66 // 3. The parent process waits for the sub-process to terminate.
67 //
68 // 4. The parent process checks the exit code and error message of
69 // the sub-process.
70 //
71 // Examples:
72 //
73 // ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
74 // for (int i = 0; i < 5; i++) {
75 // EXPECT_DEATH(server.ProcessRequest(i),
76 // "Invalid request .* in ProcessRequest()")
77 // << "Failed to die on request " << i);
78 // }
79 //
80 // ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
81 //
82 // bool KilledBySIGHUP(int exit_code) {
83 // return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
84 // }
85 //
86 // ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
87 //
88 // Known caveats:
89 //
90 // A "threadsafe" style death test obtains the path to the test
91 // program from argv[0] and re-executes it in the sub-process. For
92 // simplicity, the current implementation doesn't search the PATH
93 // when launching the sub-process. This means that the user must
94 // invoke the test program via a path that contains at least one
95 // path separator (e.g. path/to/foo_test and
96 // /absolute/path/to/bar_test are fine, but foo_test is not). This
97 // is rarely a problem as people usually don't put the test binary
98 // directory in PATH.
99 //
100 // TODO(wan@google.com): make thread-safe death tests search the PATH.
101
102 // Asserts that a given statement causes the program to exit, with an
103 // integer exit status that satisfies predicate, and emitting error output
104 // that matches regex.
105 #define ASSERT_EXIT(statement, predicate, regex) \
106 GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
107
108 // Like ASSERT_EXIT, but continues on to successive tests in the
109 // test case, if any:
110 #define EXPECT_EXIT(statement, predicate, regex) \
111 GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
112
113 // Asserts that a given statement causes the program to exit, either by
114 // explicitly exiting with a nonzero exit code or being killed by a
115 // signal, and emitting error output that matches regex.
116 #define ASSERT_DEATH(statement, regex) \
117 ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
118
119 // Like ASSERT_DEATH, but continues on to successive tests in the
120 // test case, if any:
121 #define EXPECT_DEATH(statement, regex) \
122 EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
123
124 // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
125
126 // Tests that an exit code describes a normal exit with a given exit code.
127 class ExitedWithCode {
128 public:
129 explicit ExitedWithCode(int exit_code);
130 bool operator()(int exit_status) const;
131 private:
132 const int exit_code_;
133 };
134
135 // Tests that an exit code describes an exit due to termination by a
136 // given signal.
137 class KilledBySignal {
138 public:
139 explicit KilledBySignal(int signum);
140 bool operator()(int exit_status) const;
141 private:
142 const int signum_;
143 };
144
145 // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
146 // The death testing framework causes this to have interesting semantics,
147 // since the sideeffects of the call are only visible in opt mode, and not
148 // in debug mode.
149 //
150 // In practice, this can be used to test functions that utilize the
151 // LOG(DFATAL) macro using the following style:
152 //
153 // int DieInDebugOr12(int* sideeffect) {
154 // if (sideeffect) {
155 // *sideeffect = 12;
156 // }
157 // LOG(DFATAL) << "death";
158 // return 12;
159 // }
160 //
161 // TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
162 // int sideeffect = 0;
163 // // Only asserts in dbg.
164 // EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
165 //
166 // #ifdef NDEBUG
167 // // opt-mode has sideeffect visible.
168 // EXPECT_EQ(12, sideeffect);
169 // #else
170 // // dbg-mode no visible sideeffect.
171 // EXPECT_EQ(0, sideeffect);
172 // #endif
173 // }
174 //
175 // This will assert that DieInDebugReturn12InOpt() crashes in debug
176 // mode, usually due to a DCHECK or LOG(DFATAL), but returns the
177 // appropriate fallback value (12 in this case) in opt mode. If you
178 // need to test that a function has appropriate side-effects in opt
179 // mode, include assertions against the side-effects. A general
180 // pattern for this is:
181 //
182 // EXPECT_DEBUG_DEATH({
183 // // Side-effects here will have an effect after this statement in
184 // // opt mode, but none in debug mode.
185 // EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
186 // }, "death");
187 //
188 #ifdef NDEBUG
189
190 #define EXPECT_DEBUG_DEATH(statement, regex) \
191 do { statement; } while (false)
192
193 #define ASSERT_DEBUG_DEATH(statement, regex) \
194 do { statement; } while (false)
195
196 #else
197
198 #define EXPECT_DEBUG_DEATH(statement, regex) \
199 EXPECT_DEATH(statement, regex)
200
201 #define ASSERT_DEBUG_DEATH(statement, regex) \
202 ASSERT_DEATH(statement, regex)
203
204 #endif // NDEBUG for EXPECT_DEBUG_DEATH
205 #endif // GTEST_HAS_DEATH_TEST
206 } // namespace testing
207
208 #endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
0 // Copyright 2005, Google Inc.
1 // All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: wan@google.com (Zhanyong Wan)
30 //
31 // The Google C++ Testing Framework (Google Test)
32 //
33 // This header file defines the Message class.
34 //
35 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
36 // leave some internal implementation details in this header file.
37 // They are clearly marked by comments like this:
38 //
39 // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
40 //
41 // Such code is NOT meant to be used by a user directly, and is subject
42 // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
43 // program!
44
45 #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
46 #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
47
48 #include
49 #include
50
51 namespace testing {
52
53 // The Message class works like an ostream repeater.
54 //
55 // Typical usage:
56 //
57 // 1. You stream a bunch of values to a Message object.
58 // It will remember the text in a StrStream.
59 // 2. Then you stream the Message object to an ostream.
60 // This causes the text in the Message to be streamed
61 // to the ostream.
62 //
63 // For example;
64 //
65 // testing::Message foo;
66 // foo << 1 << " != " << 2;
67 // std::cout << foo;
68 //
69 // will print "1 != 2".
70 //
71 // Message is not intended to be inherited from. In particular, its
72 // destructor is not virtual.
73 //
74 // Note that StrStream behaves differently in gcc and in MSVC. You
75 // can stream a NULL char pointer to it in the former, but not in the
76 // latter (it causes an access violation if you do). The Message
77 // class hides this difference by treating a NULL char pointer as
78 // "(null)".
79 class Message {
80 private:
81 // The type of basic IO manipulators (endl, ends, and flush) for
82 // narrow streams.
83 typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
84
85 public:
86 // Constructs an empty Message.
87 // We allocate the StrStream separately because it otherwise each use of
88 // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
89 // stack frame leading to huge stack frames in some cases; gcc does not reuse
90 // the stack space.
91 Message() : ss_(new internal::StrStream) {}
92
93 // Copy constructor.
94 Message(const Message& msg) : ss_(new internal::StrStream) { // NOLINT
95 *ss_ << msg.GetString();
96 }
97
98 // Constructs a Message from a C-string.
99 explicit Message(const char* str) : ss_(new internal::StrStream) {
100 *ss_ << str;
101 }
102
103 ~Message() { delete ss_; }
104 #ifdef GTEST_OS_SYMBIAN
105 // Streams a value (either a pointer or not) to this object.
106 template
107 inline Message& operator <<(const T& value) {
108 StreamHelper(typename internal::is_pointer::type(), value);
109 return *this;
110 }
111 #else
112 // Streams a non-pointer value to this object.
113 template
114 inline Message& operator <<(const T& val) {
115 ::GTestStreamToHelper(ss_, val);
116 return *this;
117 }
118
119 // Streams a pointer value to this object.
120 //
121 // This function is an overload of the previous one. When you
122 // stream a pointer to a Message, this definition will be used as it
123 // is more specialized. (The C++ Standard, section
124 // [temp.func.order].) If you stream a non-pointer, then the
125 // previous definition will be used.
126 //
127 // The reason for this overload is that streaming a NULL pointer to
128 // ostream is undefined behavior. Depending on the compiler, you
129 // may get "0", "(nil)", "(null)", or an access violation. To
130 // ensure consistent result across compilers, we always treat NULL
131 // as "(null)".
132 template
133 inline Message& operator <<(T* const& pointer) { // NOLINT
134 if (pointer == NULL) {
135 *ss_ << "(null)";
136 } else {
137 ::GTestStreamToHelper(ss_, pointer);
138 }
139 return *this;
140 }
141 #endif // GTEST_OS_SYMBIAN
142
143 // Since the basic IO manipulators are overloaded for both narrow
144 // and wide streams, we have to provide this specialized definition
145 // of operator <<, even though its body is the same as the
146 // templatized version above. Without this definition, streaming
147 // endl or other basic IO manipulators to Message will confuse the
148 // compiler.
149 Message& operator <<(BasicNarrowIoManip val) {
150 *ss_ << val;
151 return *this;
152 }
153
154 // Instead of 1/0, we want to see true/false for bool values.
155 Message& operator <<(bool b) {
156 return *this << (b ? "true" : "false");
157 }
158
159 // These two overloads allow streaming a wide C string to a Message
160 // using the UTF-8 encoding.
161 Message& operator <<(const wchar_t* wide_c_str) {
162 return *this << internal::String::ShowWideCString(wide_c_str);
163 }
164 Message& operator <<(wchar_t* wide_c_str) {
165 return *this << internal::String::ShowWideCString(wide_c_str);
166 }
167
168 #if GTEST_HAS_STD_WSTRING
169 // Converts the given wide string to a narrow string using the UTF-8
170 // encoding, and streams the result to this Message object.
171 Message& operator <<(const ::std::wstring& wstr);
172 #endif // GTEST_HAS_STD_WSTRING
173
174 #if GTEST_HAS_GLOBAL_WSTRING
175 // Converts the given wide string to a narrow string using the UTF-8
176 // encoding, and streams the result to this Message object.
177 Message& operator <<(const ::wstring& wstr);
178 #endif // GTEST_HAS_GLOBAL_WSTRING
179
180 // Gets the text streamed to this object so far as a String.
181 // Each '\0' character in the buffer is replaced with "\\0".
182 //
183 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
184 internal::String GetString() const {
185 return internal::StrStreamToString(ss_);
186 }
187
188 private:
189 #ifdef GTEST_OS_SYMBIAN
190 // These are needed as the Nokia Symbian Compiler cannot decide between
191 // const T& and const T* in a function template. The Nokia compiler _can_
192 // decide between class template specializations for T and T*, so a
193 // tr1::type_traits-like is_pointer works, and we can overload on that.
194 template
195 inline void StreamHelper(internal::true_type dummy, T* pointer) {
196 if (pointer == NULL) {
197 *ss_ << "(null)";
198 } else {
199 ::GTestStreamToHelper(ss_, pointer);
200 }
201 }
202 template
203 inline void StreamHelper(internal::false_type dummy, const T& value) {
204 ::GTestStreamToHelper(ss_, value);
205 }
206 #endif // GTEST_OS_SYMBIAN
207
208 // We'll hold the text streamed to this object here.
209 internal::StrStream* const ss_;
210
211 // We declare (but don't implement) this to prevent the compiler
212 // from implementing the assignment operator.
213 void operator=(const Message&);
214 };
215
216 // Streams a Message to an ostream.
217 inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
218 return os << sb.GetString();
219 }
220
221 } // namespace testing
222
223 #endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
0 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
1
2 // Copyright 2008, Google Inc.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //
31 // Authors: vladl@google.com (Vlad Losev)
32 //
33 // Macros and functions for implementing parameterized tests
34 // in Google C++ Testing Framework (Google Test)
35 //
36 // This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
37 //
38 #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
39 #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
40
41
42 // Value-parameterized tests allow you to test your code with different
43 // parameters without writing multiple copies of the same test.
44 //
45 // Here is how you use value-parameterized tests:
46
47 #if 0
48
49 // To write value-parameterized tests, first you should define a fixture
50 // class. It must be derived from testing::TestWithParam, where T is
51 // the type of your parameter values. TestWithParam is itself derived
52 // from testing::Test. T can be any copyable type. If it's a raw pointer,
53 // you are responsible for managing the lifespan of the pointed values.
54
55 class FooTest : public ::testing::TestWithParam {
56 // You can implement all the usual class fixture members here.
57 };
58
59 // Then, use the TEST_P macro to define as many parameterized tests
60 // for this fixture as you want. The _P suffix is for "parameterized"
61 // or "pattern", whichever you prefer to think.
62
63 TEST_P(FooTest, DoesBlah) {
64 // Inside a test, access the test parameter with the GetParam() method
65 // of the TestWithParam class:
66 EXPECT_TRUE(foo.Blah(GetParam()));
67 ...
68 }
69
70 TEST_P(FooTest, HasBlahBlah) {
71 ...
72 }
73
74 // Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
75 // case with any set of parameters you want. Google Test defines a number
76 // of functions for generating test parameters. They return what we call
77 // (surprise!) parameter generators. Here is a summary of them, which
78 // are all in the testing namespace:
79 //
80 //
81 // Range(begin, end [, step]) - Yields values {begin, begin+step,
82 // begin+step+step, ...}. The values do not
83 // include end. step defaults to 1.
84 // Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
85 // ValuesIn(container) - Yields values from a C-style array, an STL
86 // ValuesIn(begin,end) container, or an iterator range [begin, end).
87 // Bool() - Yields sequence {false, true}.
88 // Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
89 // for the math savvy) of the values generated
90 // by the N generators.
91 //
92 // For more details, see comments at the definitions of these functions below
93 // in this file.
94 //
95 // The following statement will instantiate tests from the FooTest test case
96 // each with parameter values "meeny", "miny", and "moe".
97
98 INSTANTIATE_TEST_CASE_P(InstantiationName,
99 FooTest,
100 Values("meeny", "miny", "moe"));
101
102 // To distinguish different instances of the pattern, (yes, you
103 // can instantiate it more then once) the first argument to the
104 // INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
105 // actual test case name. Remember to pick unique prefixes for different
106 // instantiations. The tests from the instantiation above will have
107 // these names:
108 //
109 // * InstantiationName/FooTest.DoesBlah/0 for "meeny"
110 // * InstantiationName/FooTest.DoesBlah/1 for "miny"
111 // * InstantiationName/FooTest.DoesBlah/2 for "moe"
112 // * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
113 // * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
114 // * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
115 //
116 // You can use these names in --gtest_filter.
117 //
118 // This statement will instantiate all tests from FooTest again, each
119 // with parameter values "cat" and "dog":
120
121 const char* pets[] = {"cat", "dog"};
122 INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
123
124 // The tests from the instantiation above will have these names:
125 //
126 // * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
127 // * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
128 // * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
129 // * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
130 //
131 // Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
132 // in the given test case, whether their definitions come before or
133 // AFTER the INSTANTIATE_TEST_CASE_P statement.
134 //
135 // Please also note that generator expressions are evaluated in
136 // RUN_ALL_TESTS(), after main() has started. This allows evaluation of
137 // parameter list based on command line parameters.
138 //
139 // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
140 // for more examples.
141 //
142 // In the future, we plan to publish the API for defining new parameter
143 // generators. But for now this interface remains part of the internal
144 // implementation and is subject to change.
145
146 #endif // 0
147
148
149 #include
150
151 #include
152
153 #ifdef GTEST_HAS_PARAM_TEST
154
155 #include
156 #include
157 #include
158
159 namespace testing {
160
161 // Functions producing parameter generators.
162 //
163 // Google Test uses these generators to produce parameters for value-
164 // parameterized tests. When a parameterized test case is instantiated
165 // with a particular generator, Google Test creates and runs tests
166 // for each element in the sequence produced by the generator.
167 //
168 // In the following sample, tests from test case FooTest are instantiated
169 // each three times with parameter values 3, 5, and 8:
170 //
171 // class FooTest : public TestWithParam { ... };
172 //
173 // TEST_P(FooTest, TestThis) {
174 // }
175 // TEST_P(FooTest, TestThat) {
176 // }
177 // INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
178 //
179
180 // Range() returns generators providing sequences of values in a range.
181 //
182 // Synopsis:
183 // Range(start, end)
184 // - returns a generator producing a sequence of values {start, start+1,
185 // start+2, ..., }.
186 // Range(start, end, step)
187 // - returns a generator producing a sequence of values {start, start+step,
188 // start+step+step, ..., }.
189 // Notes:
190 // * The generated sequences never include end. For example, Range(1, 5)
191 // returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
192 // returns a generator producing {1, 3, 5, 7}.
193 // * start and end must have the same type. That type may be any integral or
194 // floating-point type or a user defined type satisfying these conditions:
195 // * It must be assignable (have operator=() defined).
196 // * It must have operator+() (operator+(int-compatible type) for
197 // two-operand version).
198 // * It must have operator<() defined.
199 // Elements in the resulting sequences will also have that type.
200 // * Condition start < end must be satisfied in order for resulting sequences
201 // to contain any elements.
202 //
203 template
204 internal::ParamGenerator Range(T start, T end, IncrementT step) {
205 return internal::ParamGenerator(
206 new internal::RangeGenerator(start, end, step));
207 }
208
209 template
210 internal::ParamGenerator Range(T start, T end) {
211 return Range(start, end, 1);
212 }
213
214 // ValuesIn() function allows generation of tests with parameters coming from
215 // a container.
216 //
217 // Synopsis:
218 // ValuesIn(const T (&array)[N])
219 // - returns a generator producing sequences with elements from
220 // a C-style array.
221 // ValuesIn(const Container& container)
222 // - returns a generator producing sequences with elements from
223 // an STL-style container.
224 // ValuesIn(Iterator begin, Iterator end)
225 // - returns a generator producing sequences with elements from
226 // a range [begin, end) defined by a pair of STL-style iterators. These
227 // iterators can also be plain C pointers.
228 //
229 // Please note that ValuesIn copies the values from the containers
230 // passed in and keeps them to generate tests in RUN_ALL_TESTS().
231 //
232 // Examples:
233 //
234 // This instantiates tests from test case StringTest
235 // each with C-string values of "foo", "bar", and "baz":
236 //
237 // const char* strings[] = {"foo", "bar", "baz"};
238 // INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
239 //
240 // This instantiates tests from test case StlStringTest
241 // each with STL strings with values "a" and "b":
242 //
243 // ::std::vector< ::std::string> GetParameterStrings() {
244 // ::std::vector< ::std::string> v;
245 // v.push_back("a");
246 // v.push_back("b");
247 // return v;
248 // }
249 //
250 // INSTANTIATE_TEST_CASE_P(CharSequence,
251 // StlStringTest,
252 // ValuesIn(GetParameterStrings()));
253 //
254 //
255 // This will also instantiate tests from CharTest
256 // each with parameter values 'a' and 'b':
257 //
258 // ::std::list GetParameterChars() {
259 // ::std::list list;
260 // list.push_back('a');
261 // list.push_back('b');
262 // return list;
263 // }
264 // ::std::list l = GetParameterChars();
265 // INSTANTIATE_TEST_CASE_P(CharSequence2,
266 // CharTest,
267 // ValuesIn(l.begin(), l.end()));
268 //
269 template
270 internal::ParamGenerator<
271 typename ::std::iterator_traits::value_type> ValuesIn(
272 ForwardIterator begin,
273 ForwardIterator end) {
274 typedef typename ::std::iterator_traits::value_type
275 ParamType;
276 return internal::ParamGenerator(
277 new internal::ValuesInIteratorRangeGenerator(begin, end));
278 }
279
280 template
281 internal::ParamGenerator ValuesIn(const T (&array)[N]) {
282 return ValuesIn(array, array + N);
283 }
284
285 template
286 internal::ParamGenerator ValuesIn(
287 const Container& container) {
288 return ValuesIn(container.begin(), container.end());
289 }
290
291 // Values() allows generating tests from explicitly specified list of
292 // parameters.
293 //
294 // Synopsis:
295 // Values(T v1, T v2, ..., T vN)
296 // - returns a generator producing sequences with elements v1, v2, ..., vN.
297 //
298 // For example, this instantiates tests from test case BarTest each
299 // with values "one", "two", and "three":
300 //
301 // INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
302 //
303 // This instantiates tests from test case BazTest each with values 1, 2, 3.5.
304 // The exact type of values will depend on the type of parameter in BazTest.
305 //
306 // INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
307 //
308 // Currently, Values() supports from 1 to 50 parameters.
309 //
310 template
311 internal::ValueArray1 Values(T1 v1) {
312 return internal::ValueArray1(v1);
313 }
314
315 template
316 internal::ValueArray2 Values(T1 v1, T2 v2) {
317 return internal::ValueArray2(v1, v2);
318 }
319
320 template
321 internal::ValueArray3 Values(T1 v1, T2 v2, T3 v3) {
322 return internal::ValueArray3(v1, v2, v3);
323 }
324
325 template
326 internal::ValueArray4 Values(T1 v1, T2 v2, T3 v3, T4 v4) {
327 return internal::ValueArray4(v1, v2, v3, v4);
328 }
329
330 template
331 internal::ValueArray5 Values(T1 v1, T2 v2, T3 v3, T4 v4,
332 T5 v5) {
333 return internal::ValueArray5(v1, v2, v3, v4, v5);
334 }
335
336 template
337 typename T6>
338 internal::ValueArray6 Values(T1 v1, T2 v2, T3 v3,
339 T4 v4, T5 v5, T6 v6) {
340 return internal::ValueArray6(v1, v2, v3, v4, v5, v6);
341 }
342
343 template
344 typename T6, typename T7>
345 internal::ValueArray7 Values(T1 v1, T2 v2, T3 v3,
346 T4 v4, T5 v5, T6 v6, T7 v7) {
347 return internal::ValueArray7(v1, v2, v3, v4, v5,
348 v6, v7);
349 }
350
351 template
352 typename T6, typename T7, typename T8>
353 internal::ValueArray8 Values(T1 v1, T2 v2,
354 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
355 return internal::ValueArray8(v1, v2, v3, v4,
356 v5, v6, v7, v8);
357 }
358
359 template
360 typename T6, typename T7, typename T8, typename T9>
361 internal::ValueArray9 Values(T1 v1, T2 v2,
362 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {
363 return internal::ValueArray9(v1, v2, v3,
364 v4, v5, v6, v7, v8, v9);
365 }
366
367 template
368 typename T6, typename T7, typename T8, typename T9, typename T10>
369 internal::ValueArray10 Values(T1 v1,
370 T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {
371 return internal::ValueArray10(v1,
372 v2, v3, v4, v5, v6, v7, v8, v9, v10);
373 }
374
375 template
376 typename T6, typename T7, typename T8, typename T9, typename T10,
377 typename T11>
378 internal::ValueArray11
379 T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
380 T10 v10, T11 v11) {
381 return internal::ValueArray11
382 T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
383 }
384
385 template
386 typename T6, typename T7, typename T8, typename T9, typename T10,
387 typename T11, typename T12>
388 internal::ValueArray12
389 T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
390 T10 v10, T11 v11, T12 v12) {
391 return internal::ValueArray12
392 T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
393 }
394
395 template
396 typename T6, typename T7, typename T8, typename T9, typename T10,
397 typename T11, typename T12, typename T13>
398 internal::ValueArray13
399 T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
400 T10 v10, T11 v11, T12 v12, T13 v13) {
401 return internal::ValueArray13
402 T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
403 }
404
405 template
406 typename T6, typename T7, typename T8, typename T9, typename T10,
407 typename T11, typename T12, typename T13, typename T14>
408 internal::ValueArray14
409 T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
410 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {
411 return internal::ValueArray14
412 T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
413 v14);
414 }
415
416 template
417 typename T6, typename T7, typename T8, typename T9, typename T10,
418 typename T11, typename T12, typename T13, typename T14, typename T15>
419 internal::ValueArray15
420 T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
421 T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {
422 return internal::ValueArray15
423 T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
424 v13, v14, v15);
425 }
426
427 template
428 typename T6, typename T7, typename T8, typename T9, typename T10,
429 typename T11, typename T12, typename T13, typename T14, typename T15,
430 typename T16>
431 internal::ValueArray16
432 T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
433 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
434 T16 v16) {
435 return internal::ValueArray16
436 T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
437 v12, v13, v14, v15, v16);
438 }
439
440 template
441 typename T6, typename T7, typename T8, typename T9, typename T10,
442 typename T11, typename T12, typename T13, typename T14, typename T15,
443 typename T16, typename T17>
444 internal::ValueArray17
445 T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
446 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
447 T16 v16, T17 v17) {
448 return internal::ValueArray17
449 T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
450 v11, v12, v13, v14, v15, v16, v17);
451 }
452
453 template
454 typename T6, typename T7, typename T8, typename T9, typename T10,
455 typename T11, typename T12, typename T13, typename T14, typename T15,
456 typename T16, typename T17, typename T18>
457 internal::ValueArray18
458 T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
459 T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
460 T16 v16, T17 v17, T18 v18) {
461 return internal::ValueArray18
462 T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
463 v10, v11, v12, v13, v14, v15, v16, v17, v18);
464 }
465
466 template
467 typename T6, typename T7, typename T8, typename T9, typename T10,
468 typename T11, typename T12, typename T13, typename T14, typename T15,
469 typename T16, typename T17, typename T18, typename T19>
470 internal::ValueArray19
471 T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
472 T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
473 T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {
474 return internal::ValueArray19
475 T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,
476 v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);
477 }
478
479 template
480 typename T6, typename T7, typename T8, typename T9, typename T10,
481 typename T11, typename T12, typename T13, typename T14, typename T15,
482 typename T16, typename T17, typename T18, typename T19, typename T20>
483 internal::ValueArray20
484 T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,
485 T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
486 T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {
487 return internal::ValueArray20
488 T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,
489 v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);
490 }
491
492 template
493 typename T6, typename T7, typename T8, typename T9, typename T10,
494 typename T11, typename T12, typename T13, typename T14, typename T15,
495 typename T16, typename T17, typename T18, typename T19, typename T20,
496 typename T21>
497 internal::ValueArray21
498 T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,
499 T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
500 T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {
501 return internal::ValueArray21
502 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,
503 v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);
504 }
505
506 template
507 typename T6, typename T7, typename T8, typename T9, typename T10,
508 typename T11, typename T12, typename T13, typename T14, typename T15,
509 typename T16, typename T17, typename T18, typename T19, typename T20,
510 typename T21, typename T22>
511 internal::ValueArray22
512 T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,
513 T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
514 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
515 T21 v21, T22 v22) {
516 return internal::ValueArray22
517 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,
518 v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
519 v20, v21, v22);
520 }
521
522 template
523 typename T6, typename T7, typename T8, typename T9, typename T10,
524 typename T11, typename T12, typename T13, typename T14, typename T15,
525 typename T16, typename T17, typename T18, typename T19, typename T20,
526 typename T21, typename T22, typename T23>
527 internal::ValueArray23
528 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,
529 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
530 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
531 T21 v21, T22 v22, T23 v23) {
532 return internal::ValueArray23
533 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,
534 v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
535 v20, v21, v22, v23);
536 }
537
538 template
539 typename T6, typename T7, typename T8, typename T9, typename T10,
540 typename T11, typename T12, typename T13, typename T14, typename T15,
541 typename T16, typename T17, typename T18, typename T19, typename T20,
542 typename T21, typename T22, typename T23, typename T24>
543 internal::ValueArray24
544 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,
545 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
546 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
547 T21 v21, T22 v22, T23 v23, T24 v24) {
548 return internal::ValueArray24
549 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,
550 v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
551 v19, v20, v21, v22, v23, v24);
552 }
553
554 template
555 typename T6, typename T7, typename T8, typename T9, typename T10,
556 typename T11, typename T12, typename T13, typename T14, typename T15,
557 typename T16, typename T17, typename T18, typename T19, typename T20,
558 typename T21, typename T22, typename T23, typename T24, typename T25>
559 internal::ValueArray25
560 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,
561 T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
562 T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
563 T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {
564 return internal::ValueArray25
565 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,
566 v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
567 v18, v19, v20, v21, v22, v23, v24, v25);
568 }
569
570 template
571 typename T6, typename T7, typename T8, typename T9, typename T10,
572 typename T11, typename T12, typename T13, typename T14, typename T15,
573 typename T16, typename T17, typename T18, typename T19, typename T20,
574 typename T21, typename T22, typename T23, typename T24, typename T25,
575 typename T26>
576 internal::ValueArray26
577 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
578 T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
579 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
580 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
581 T26 v26) {
582 return internal::ValueArray26
583 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
584 T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
585 v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);
586 }
587
588 template
589 typename T6, typename T7, typename T8, typename T9, typename T10,
590 typename T11, typename T12, typename T13, typename T14, typename T15,
591 typename T16, typename T17, typename T18, typename T19, typename T20,
592 typename T21, typename T22, typename T23, typename T24, typename T25,
593 typename T26, typename T27>
594 internal::ValueArray27
595 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
596 T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
597 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
598 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
599 T26 v26, T27 v27) {
600 return internal::ValueArray27
601 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
602 T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
603 v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
604 }
605
606 template
607 typename T6, typename T7, typename T8, typename T9, typename T10,
608 typename T11, typename T12, typename T13, typename T14, typename T15,
609 typename T16, typename T17, typename T18, typename T19, typename T20,
610 typename T21, typename T22, typename T23, typename T24, typename T25,
611 typename T26, typename T27, typename T28>
612 internal::ValueArray28
613 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
614 T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
615 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
616 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
617 T26 v26, T27 v27, T28 v28) {
618 return internal::ValueArray28
619 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
620 T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
621 v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
622 v28);
623 }
624
625 template
626 typename T6, typename T7, typename T8, typename T9, typename T10,
627 typename T11, typename T12, typename T13, typename T14, typename T15,
628 typename T16, typename T17, typename T18, typename T19, typename T20,
629 typename T21, typename T22, typename T23, typename T24, typename T25,
630 typename T26, typename T27, typename T28, typename T29>
631 internal::ValueArray29
632 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
633 T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
634 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
635 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
636 T26 v26, T27 v27, T28 v28, T29 v29) {
637 return internal::ValueArray29
638 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
639 T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
640 v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
641 v27, v28, v29);
642 }
643
644 template
645 typename T6, typename T7, typename T8, typename T9, typename T10,
646 typename T11, typename T12, typename T13, typename T14, typename T15,
647 typename T16, typename T17, typename T18, typename T19, typename T20,
648 typename T21, typename T22, typename T23, typename T24, typename T25,
649 typename T26, typename T27, typename T28, typename T29, typename T30>
650 internal::ValueArray30
651 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
652 T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
653 T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
654 T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
655 T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {
656 return internal::ValueArray30
657 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
658 T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
659 v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
660 v26, v27, v28, v29, v30);
661 }
662
663 template
664 typename T6, typename T7, typename T8, typename T9, typename T10,
665 typename T11, typename T12, typename T13, typename T14, typename T15,
666 typename T16, typename T17, typename T18, typename T19, typename T20,
667 typename T21, typename T22, typename T23, typename T24, typename T25,
668 typename T26, typename T27, typename T28, typename T29, typename T30,
669 typename T31>
670 internal::ValueArray31
671 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
672 T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
673 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
674 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
675 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {
676 return internal::ValueArray31
677 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
678 T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
679 v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
680 v25, v26, v27, v28, v29, v30, v31);
681 }
682
683 template
684 typename T6, typename T7, typename T8, typename T9, typename T10,
685 typename T11, typename T12, typename T13, typename T14, typename T15,
686 typename T16, typename T17, typename T18, typename T19, typename T20,
687 typename T21, typename T22, typename T23, typename T24, typename T25,
688 typename T26, typename T27, typename T28, typename T29, typename T30,
689 typename T31, typename T32>
690 internal::ValueArray32
691 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
692 T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
693 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
694 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
695 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
696 T32 v32) {
697 return internal::ValueArray32
698 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
699 T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
700 v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
701 v24, v25, v26, v27, v28, v29, v30, v31, v32);
702 }
703
704 template
705 typename T6, typename T7, typename T8, typename T9, typename T10,
706 typename T11, typename T12, typename T13, typename T14, typename T15,
707 typename T16, typename T17, typename T18, typename T19, typename T20,
708 typename T21, typename T22, typename T23, typename T24, typename T25,
709 typename T26, typename T27, typename T28, typename T29, typename T30,
710 typename T31, typename T32, typename T33>
711 internal::ValueArray33
712 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
713 T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
714 T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
715 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
716 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
717 T32 v32, T33 v33) {
718 return internal::ValueArray33
719 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
720 T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,
721 v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
722 v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);
723 }
724
725 template
726 typename T6, typename T7, typename T8, typename T9, typename T10,
727 typename T11, typename T12, typename T13, typename T14, typename T15,
728 typename T16, typename T17, typename T18, typename T19, typename T20,
729 typename T21, typename T22, typename T23, typename T24, typename T25,
730 typename T26, typename T27, typename T28, typename T29, typename T30,
731 typename T31, typename T32, typename T33, typename T34>
732 internal::ValueArray34
733 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
734 T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
735 T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
736 T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
737 T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
738 T31 v31, T32 v32, T33 v33, T34 v34) {
739 return internal::ValueArray34
740 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
741 T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,
742 v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
743 v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);
744 }
745
746 template
747 typename T6, typename T7, typename T8, typename T9, typename T10,
748 typename T11, typename T12, typename T13, typename T14, typename T15,
749 typename T16, typename T17, typename T18, typename T19, typename T20,
750 typename T21, typename T22, typename T23, typename T24, typename T25,
751 typename T26, typename T27, typename T28, typename T29, typename T30,
752 typename T31, typename T32, typename T33, typename T34, typename T35>
753 internal::ValueArray35
754 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
755 T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,
756 T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
757 T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
758 T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
759 T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {
760 return internal::ValueArray35
761 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
762 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,
763 v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
764 v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);
765 }
766
767 template
768 typename T6, typename T7, typename T8, typename T9, typename T10,
769 typename T11, typename T12, typename T13, typename T14, typename T15,
770 typename T16, typename T17, typename T18, typename T19, typename T20,
771 typename T21, typename T22, typename T23, typename T24, typename T25,
772 typename T26, typename T27, typename T28, typename T29, typename T30,
773 typename T31, typename T32, typename T33, typename T34, typename T35,
774 typename T36>
775 internal::ValueArray36
776 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
777 T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,
778 T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
779 T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
780 T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
781 T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {
782 return internal::ValueArray36
783 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
784 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,
785 v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
786 v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
787 v34, v35, v36);
788 }
789
790 template
791 typename T6, typename T7, typename T8, typename T9, typename T10,
792 typename T11, typename T12, typename T13, typename T14, typename T15,
793 typename T16, typename T17, typename T18, typename T19, typename T20,
794 typename T21, typename T22, typename T23, typename T24, typename T25,
795 typename T26, typename T27, typename T28, typename T29, typename T30,
796 typename T31, typename T32, typename T33, typename T34, typename T35,
797 typename T36, typename T37>
798 internal::ValueArray37
799 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
800 T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,
801 T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
802 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
803 T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
804 T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
805 T37 v37) {
806 return internal::ValueArray37
807 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
808 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,
809 v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
810 v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
811 v34, v35, v36, v37);
812 }
813
814 template
815 typename T6, typename T7, typename T8, typename T9, typename T10,
816 typename T11, typename T12, typename T13, typename T14, typename T15,
817 typename T16, typename T17, typename T18, typename T19, typename T20,
818 typename T21, typename T22, typename T23, typename T24, typename T25,
819 typename T26, typename T27, typename T28, typename T29, typename T30,
820 typename T31, typename T32, typename T33, typename T34, typename T35,
821 typename T36, typename T37, typename T38>
822 internal::ValueArray38
823 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
824 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,
825 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
826 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
827 T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
828 T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
829 T37 v37, T38 v38) {
830 return internal::ValueArray38
831 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
832 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,
833 v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
834 v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,
835 v33, v34, v35, v36, v37, v38);
836 }
837
838 template
839 typename T6, typename T7, typename T8, typename T9, typename T10,
840 typename T11, typename T12, typename T13, typename T14, typename T15,
841 typename T16, typename T17, typename T18, typename T19, typename T20,
842 typename T21, typename T22, typename T23, typename T24, typename T25,
843 typename T26, typename T27, typename T28, typename T29, typename T30,
844 typename T31, typename T32, typename T33, typename T34, typename T35,
845 typename T36, typename T37, typename T38, typename T39>
846 internal::ValueArray39
847 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
848 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,
849 T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
850 T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
851 T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
852 T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
853 T37 v37, T38 v38, T39 v39) {
854 return internal::ValueArray39
855 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
856 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,
857 v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
858 v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
859 v32, v33, v34, v35, v36, v37, v38, v39);
860 }
861
862 template
863 typename T6, typename T7, typename T8, typename T9, typename T10,
864 typename T11, typename T12, typename T13, typename T14, typename T15,
865 typename T16, typename T17, typename T18, typename T19, typename T20,
866 typename T21, typename T22, typename T23, typename T24, typename T25,
867 typename T26, typename T27, typename T28, typename T29, typename T30,
868 typename T31, typename T32, typename T33, typename T34, typename T35,
869 typename T36, typename T37, typename T38, typename T39, typename T40>
870 internal::ValueArray40
871 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
872 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,
873 T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
874 T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
875 T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,
876 T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,
877 T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {
878 return internal::ValueArray40
879 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
880 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
881 T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
882 v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,
883 v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);
884 }
885
886 template
887 typename T6, typename T7, typename T8, typename T9, typename T10,
888 typename T11, typename T12, typename T13, typename T14, typename T15,
889 typename T16, typename T17, typename T18, typename T19, typename T20,
890 typename T21, typename T22, typename T23, typename T24, typename T25,
891 typename T26, typename T27, typename T28, typename T29, typename T30,
892 typename T31, typename T32, typename T33, typename T34, typename T35,
893 typename T36, typename T37, typename T38, typename T39, typename T40,
894 typename T41>
895 internal::ValueArray41
896 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
897 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
898 T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
899 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
900 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
901 T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
902 T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {
903 return internal::ValueArray41
904 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
905 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
906 T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
907 v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,
908 v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);
909 }
910
911 template
912 typename T6, typename T7, typename T8, typename T9, typename T10,
913 typename T11, typename T12, typename T13, typename T14, typename T15,
914 typename T16, typename T17, typename T18, typename T19, typename T20,
915 typename T21, typename T22, typename T23, typename T24, typename T25,
916 typename T26, typename T27, typename T28, typename T29, typename T30,
917 typename T31, typename T32, typename T33, typename T34, typename T35,
918 typename T36, typename T37, typename T38, typename T39, typename T40,
919 typename T41, typename T42>
920 internal::ValueArray42
921 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
922 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
923 T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
924 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
925 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
926 T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
927 T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
928 T42 v42) {
929 return internal::ValueArray42
930 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
931 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
932 T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
933 v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
934 v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,
935 v42);
936 }
937
938 template
939 typename T6, typename T7, typename T8, typename T9, typename T10,
940 typename T11, typename T12, typename T13, typename T14, typename T15,
941 typename T16, typename T17, typename T18, typename T19, typename T20,
942 typename T21, typename T22, typename T23, typename T24, typename T25,
943 typename T26, typename T27, typename T28, typename T29, typename T30,
944 typename T31, typename T32, typename T33, typename T34, typename T35,
945 typename T36, typename T37, typename T38, typename T39, typename T40,
946 typename T41, typename T42, typename T43>
947 internal::ValueArray43
948 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
949 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
950 T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
951 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
952 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
953 T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
954 T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
955 T42 v42, T43 v43) {
956 return internal::ValueArray43
957 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
958 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
959 T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
960 v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
961 v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
962 v41, v42, v43);
963 }
964
965 template
966 typename T6, typename T7, typename T8, typename T9, typename T10,
967 typename T11, typename T12, typename T13, typename T14, typename T15,
968 typename T16, typename T17, typename T18, typename T19, typename T20,
969 typename T21, typename T22, typename T23, typename T24, typename T25,
970 typename T26, typename T27, typename T28, typename T29, typename T30,
971 typename T31, typename T32, typename T33, typename T34, typename T35,
972 typename T36, typename T37, typename T38, typename T39, typename T40,
973 typename T41, typename T42, typename T43, typename T44>
974 internal::ValueArray44
975 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
976 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
977 T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
978 T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
979 T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
980 T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
981 T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
982 T42 v42, T43 v43, T44 v44) {
983 return internal::ValueArray44
984 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
985 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
986 T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
987 v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
988 v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,
989 v40, v41, v42, v43, v44);
990 }
991
992 template
993 typename T6, typename T7, typename T8, typename T9, typename T10,
994 typename T11, typename T12, typename T13, typename T14, typename T15,
995 typename T16, typename T17, typename T18, typename T19, typename T20,
996 typename T21, typename T22, typename T23, typename T24, typename T25,
997 typename T26, typename T27, typename T28, typename T29, typename T30,
998 typename T31, typename T32, typename T33, typename T34, typename T35,
999 typename T36, typename T37, typename T38, typename T39, typename T40,
1000 typename T41, typename T42, typename T43, typename T44, typename T45>
1001 internal::ValueArray45
1002 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1003 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1004 T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
1005 T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
1006 T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
1007 T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
1008 T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
1009 T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {
1010 return internal::ValueArray45
1011 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1012 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1013 T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
1014 v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
1015 v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,
1016 v39, v40, v41, v42, v43, v44, v45);
1017 }
1018
1019 template
1020 typename T6, typename T7, typename T8, typename T9, typename T10,
1021 typename T11, typename T12, typename T13, typename T14, typename T15,
1022 typename T16, typename T17, typename T18, typename T19, typename T20,
1023 typename T21, typename T22, typename T23, typename T24, typename T25,
1024 typename T26, typename T27, typename T28, typename T29, typename T30,
1025 typename T31, typename T32, typename T33, typename T34, typename T35,
1026 typename T36, typename T37, typename T38, typename T39, typename T40,
1027 typename T41, typename T42, typename T43, typename T44, typename T45,
1028 typename T46>
1029 internal::ValueArray46
1030 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1031 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1032 T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
1033 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
1034 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
1035 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
1036 T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
1037 T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {
1038 return internal::ValueArray46
1039 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1040 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1041 T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
1042 v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
1043 v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
1044 v38, v39, v40, v41, v42, v43, v44, v45, v46);
1045 }
1046
1047 template
1048 typename T6, typename T7, typename T8, typename T9, typename T10,
1049 typename T11, typename T12, typename T13, typename T14, typename T15,
1050 typename T16, typename T17, typename T18, typename T19, typename T20,
1051 typename T21, typename T22, typename T23, typename T24, typename T25,
1052 typename T26, typename T27, typename T28, typename T29, typename T30,
1053 typename T31, typename T32, typename T33, typename T34, typename T35,
1054 typename T36, typename T37, typename T38, typename T39, typename T40,
1055 typename T41, typename T42, typename T43, typename T44, typename T45,
1056 typename T46, typename T47>
1057 internal::ValueArray47
1058 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1059 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1060 T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
1061 T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
1062 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
1063 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
1064 T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
1065 T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {
1066 return internal::ValueArray47
1067 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1068 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1069 T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,
1070 v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
1071 v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
1072 v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);
1073 }
1074
1075 template
1076 typename T6, typename T7, typename T8, typename T9, typename T10,
1077 typename T11, typename T12, typename T13, typename T14, typename T15,
1078 typename T16, typename T17, typename T18, typename T19, typename T20,
1079 typename T21, typename T22, typename T23, typename T24, typename T25,
1080 typename T26, typename T27, typename T28, typename T29, typename T30,
1081 typename T31, typename T32, typename T33, typename T34, typename T35,
1082 typename T36, typename T37, typename T38, typename T39, typename T40,
1083 typename T41, typename T42, typename T43, typename T44, typename T45,
1084 typename T46, typename T47, typename T48>
1085 internal::ValueArray48
1086 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1087 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1088 T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
1089 T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
1090 T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
1091 T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
1092 T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
1093 T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,
1094 T48 v48) {
1095 return internal::ValueArray48
1096 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1097 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1098 T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,
1099 v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
1100 v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,
1101 v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);
1102 }
1103
1104 template
1105 typename T6, typename T7, typename T8, typename T9, typename T10,
1106 typename T11, typename T12, typename T13, typename T14, typename T15,
1107 typename T16, typename T17, typename T18, typename T19, typename T20,
1108 typename T21, typename T22, typename T23, typename T24, typename T25,
1109 typename T26, typename T27, typename T28, typename T29, typename T30,
1110 typename T31, typename T32, typename T33, typename T34, typename T35,
1111 typename T36, typename T37, typename T38, typename T39, typename T40,
1112 typename T41, typename T42, typename T43, typename T44, typename T45,
1113 typename T46, typename T47, typename T48, typename T49>
1114 internal::ValueArray49
1115 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1116 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1117 T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
1118 T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
1119 T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
1120 T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
1121 T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,
1122 T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,
1123 T47 v47, T48 v48, T49 v49) {
1124 return internal::ValueArray49
1125 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1126 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1127 T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,
1128 v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
1129 v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,
1130 v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);
1131 }
1132
1133 template
1134 typename T6, typename T7, typename T8, typename T9, typename T10,
1135 typename T11, typename T12, typename T13, typename T14, typename T15,
1136 typename T16, typename T17, typename T18, typename T19, typename T20,
1137 typename T21, typename T22, typename T23, typename T24, typename T25,
1138 typename T26, typename T27, typename T28, typename T29, typename T30,
1139 typename T31, typename T32, typename T33, typename T34, typename T35,
1140 typename T36, typename T37, typename T38, typename T39, typename T40,
1141 typename T41, typename T42, typename T43, typename T44, typename T45,
1142 typename T46, typename T47, typename T48, typename T49, typename T50>
1143 internal::ValueArray50
1144 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
1145 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
1146 T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,
1147 T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
1148 T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
1149 T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
1150 T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,
1151 T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,
1152 T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {
1153 return internal::ValueArray50
1154 T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
1155 T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
1156 T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,
1157 v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
1158 v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
1159 v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,
1160 v48, v49, v50);
1161 }
1162
1163 // Bool() allows generating tests with parameters in a set of (false, true).
1164 //
1165 // Synopsis:
1166 // Bool()
1167 // - returns a generator producing sequences with elements {false, true}.
1168 //
1169 // It is useful when testing code that depends on Boolean flags. Combinations
1170 // of multiple flags can be tested when several Bool()'s are combined using
1171 // Combine() function.
1172 //
1173 // In the following example all tests in the test case FlagDependentTest
1174 // will be instantiated twice with parameters false and true.
1175 //
1176 // class FlagDependentTest : public testing::TestWithParam {
1177 // virtual void SetUp() {
1178 // external_flag = GetParam();
1179 // }
1180 // }
1181 // INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
1182 //
1183 inline internal::ParamGenerator Bool() {
1184 return Values(false, true);
1185 }
1186
1187 #ifdef GTEST_HAS_COMBINE
1188 // Combine() allows the user to combine two or more sequences to produce
1189 // values of a Cartesian product of those sequences' elements.
1190 //
1191 // Synopsis:
1192 // Combine(gen1, gen2, ..., genN)
1193 // - returns a generator producing sequences with elements coming from
1194 // the Cartesian product of elements from the sequences generated by
1195 // gen1, gen2, ..., genN. The sequence elements will have a type of
1196 // tuple where T1, T2, ..., TN are the types
1197 // of elements from sequences produces by gen1, gen2, ..., genN.
1198 //
1199 // Combine can have up to 10 arguments. This number is currently limited
1200 // by the maximum number of elements in the tuple implementation used by Google
1201 // Test.
1202 //
1203 // Example:
1204 //
1205 // This will instantiate tests in test case AnimalTest each one with
1206 // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
1207 // tuple("dog", BLACK), and tuple("dog", WHITE):
1208 //
1209 // enum Color { BLACK, GRAY, WHITE };
1210 // class AnimalTest
1211 // : public testing::TestWithParam > {...};
1212 //
1213 // TEST_P(AnimalTest, AnimalLooksNice) {...}
1214 //
1215 // INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
1216 // Combine(Values("cat", "dog"),
1217 // Values(BLACK, WHITE)));
1218 //
1219 // This will instantiate tests in FlagDependentTest with all variations of two
1220 // Boolean flags:
1221 //
1222 // class FlagDependentTest
1223 // : public testing::TestWithParam > {
1224 // virtual void SetUp() {
1225 // // Assigns external_flag_1 and external_flag_2 values from the tuple.
1226 // tie(external_flag_1, external_flag_2) = GetParam();
1227 // }
1228 // };
1229 //
1230 // TEST_P(FlagDependentTest, TestFeature1) {
1231 // // Test your code using external_flag_1 and external_flag_2 here.
1232 // }
1233 // INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
1234 // Combine(Bool(), Bool()));
1235 //
1236 template
1237 internal::CartesianProductHolder2 Combine(
1238 const Generator1& g1, const Generator2& g2) {
1239 return internal::CartesianProductHolder2(
1240 g1, g2);
1241 }
1242
1243 template
1244 internal::CartesianProductHolder3 Combine(
1245 const Generator1& g1, const Generator2& g2, const Generator3& g3) {
1246 return internal::CartesianProductHolder3(
1247 g1, g2, g3);
1248 }
1249
1250 template
1251 typename Generator4>
1252 internal::CartesianProductHolder4
1253 Generator4> Combine(
1254 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1255 const Generator4& g4) {
1256 return internal::CartesianProductHolder4
1257 Generator4>(
1258 g1, g2, g3, g4);
1259 }
1260
1261 template
1262 typename Generator4, typename Generator5>
1263 internal::CartesianProductHolder5
1264 Generator4, Generator5> Combine(
1265 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1266 const Generator4& g4, const Generator5& g5) {
1267 return internal::CartesianProductHolder5
1268 Generator4, Generator5>(
1269 g1, g2, g3, g4, g5);
1270 }
1271
1272 template
1273 typename Generator4, typename Generator5, typename Generator6>
1274 internal::CartesianProductHolder6
1275 Generator4, Generator5, Generator6> Combine(
1276 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1277 const Generator4& g4, const Generator5& g5, const Generator6& g6) {
1278 return internal::CartesianProductHolder6
1279 Generator4, Generator5, Generator6>(
1280 g1, g2, g3, g4, g5, g6);
1281 }
1282
1283 template
1284 typename Generator4, typename Generator5, typename Generator6,
1285 typename Generator7>
1286 internal::CartesianProductHolder7
1287 Generator4, Generator5, Generator6, Generator7> Combine(
1288 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1289 const Generator4& g4, const Generator5& g5, const Generator6& g6,
1290 const Generator7& g7) {
1291 return internal::CartesianProductHolder7
1292 Generator4, Generator5, Generator6, Generator7>(
1293 g1, g2, g3, g4, g5, g6, g7);
1294 }
1295
1296 template
1297 typename Generator4, typename Generator5, typename Generator6,
1298 typename Generator7, typename Generator8>
1299 internal::CartesianProductHolder8
1300 Generator4, Generator5, Generator6, Generator7, Generator8> Combine(
1301 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1302 const Generator4& g4, const Generator5& g5, const Generator6& g6,
1303 const Generator7& g7, const Generator8& g8) {
1304 return internal::CartesianProductHolder8
1305 Generator4, Generator5, Generator6, Generator7, Generator8>(
1306 g1, g2, g3, g4, g5, g6, g7, g8);
1307 }
1308
1309 template
1310 typename Generator4, typename Generator5, typename Generator6,
1311 typename Generator7, typename Generator8, typename Generator9>
1312 internal::CartesianProductHolder9
1313 Generator4, Generator5, Generator6, Generator7, Generator8,
1314 Generator9> Combine(
1315 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1316 const Generator4& g4, const Generator5& g5, const Generator6& g6,
1317 const Generator7& g7, const Generator8& g8, const Generator9& g9) {
1318 return internal::CartesianProductHolder9
1319 Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(
1320 g1, g2, g3, g4, g5, g6, g7, g8, g9);
1321 }
1322
1323 template
1324 typename Generator4, typename Generator5, typename Generator6,
1325 typename Generator7, typename Generator8, typename Generator9,
1326 typename Generator10>
1327 internal::CartesianProductHolder10
1328 Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
1329 Generator10> Combine(
1330 const Generator1& g1, const Generator2& g2, const Generator3& g3,
1331 const Generator4& g4, const Generator5& g5, const Generator6& g6,
1332 const Generator7& g7, const Generator8& g8, const Generator9& g9,
1333 const Generator10& g10) {
1334 return internal::CartesianProductHolder10
1335 Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
1336 Generator10>(
1337 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
1338 }
1339 #endif // GTEST_HAS_COMBINE
1340
1341
1342
1343 #define TEST_P(test_case_name, test_name) \
1344 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
1345 : public test_case_name { \
1346 public: \
1347 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
1348 virtual void TestBody(); \
1349 private: \
1350 static int AddToRegistry() { \
1351 ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
1352 GetTestCasePatternHolder(\
1353 #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
1354 #test_case_name, \
1355 #test_name, \
1356 new ::testing::internal::TestMetaFactory< \
1357 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
1358 return 0; \
1359 } \
1360 static int gtest_registering_dummy_; \
1361 GTEST_DISALLOW_COPY_AND_ASSIGN_(\
1362 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
1363 }; \
1364 int GTEST_TEST_CLASS_NAME_(test_case_name, \
1365 test_name)::gtest_registering_dummy_ = \
1366 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
1367 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
1368
1369 #define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
1370 ::testing::internal::ParamGenerator \
1371 gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
1372 int gtest_##prefix##test_case_name##_dummy_ = \
1373 ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
1374 GetTestCasePatternHolder(\
1375 #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\
1376 #prefix, \
1377 >est_##prefix##test_case_name##_EvalGenerator_, \
1378 __FILE__, __LINE__)
1379
1380 } // namespace testing
1381
1382 #endif // GTEST_HAS_PARAM_TEST
1383
1384 #endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
0 // Copyright 2007, Google Inc.
1 // All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: wan@google.com (Zhanyong Wan)
30 //
31 // Utilities for testing Google Test itself and code that uses Google Test
32 // (e.g. frameworks built on top of Google Test).
33
34 #ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
35 #define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
36
37 #include
38
39 namespace testing {
40
41 // This helper class can be used to mock out Google Test failure reporting
42 // so that we can test Google Test or code that builds on Google Test.
43 //
44 // An object of this class appends a TestPartResult object to the
45 // TestPartResultArray object given in the constructor whenever a Google Test
46 // failure is reported. It can either intercept only failures that are
47 // generated in the same thread that created this object or it can intercept
48 // all generated failures. The scope of this mock object can be controlled with
49 // the second argument to the two arguments constructor.
50 class ScopedFakeTestPartResultReporter
51 : public TestPartResultReporterInterface {
52 public:
53 // The two possible mocking modes of this object.
54 enum InterceptMode {
55 INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures.
56 INTERCEPT_ALL_THREADS // Intercepts all failures.
57 };
58
59 // The c'tor sets this object as the test part result reporter used
60 // by Google Test. The 'result' parameter specifies where to report the
61 // results. This reporter will only catch failures generated in the current
62 // thread. DEPRECATED
63 explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
64
65 // Same as above, but you can choose the interception scope of this object.
66 ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
67 TestPartResultArray* result);
68
69 // The d'tor restores the previous test part result reporter.
70 virtual ~ScopedFakeTestPartResultReporter();
71
72 // Appends the TestPartResult object to the TestPartResultArray
73 // received in the constructor.
74 //
75 // This method is from the TestPartResultReporterInterface
76 // interface.
77 virtual void ReportTestPartResult(const TestPartResult& result);
78 private:
79 void Init();
80
81 const InterceptMode intercept_mode_;
82 TestPartResultReporterInterface* old_reporter_;
83 TestPartResultArray* const result_;
84
85 GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
86 };
87
88 namespace internal {
89
90 // A helper class for implementing EXPECT_FATAL_FAILURE() and
91 // EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given
92 // TestPartResultArray contains exactly one failure that has the given
93 // type and contains the given substring. If that's not the case, a
94 // non-fatal failure will be generated.
95 class SingleFailureChecker {
96 public:
97 // The constructor remembers the arguments.
98 SingleFailureChecker(const TestPartResultArray* results,
99 TestPartResultType type,
100 const char* substr);
101 ~SingleFailureChecker();
102 private:
103 const TestPartResultArray* const results_;
104 const TestPartResultType type_;
105 const String substr_;
106
107 GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
108 };
109
110 } // namespace internal
111
112 } // namespace testing
113
114 // A set of macros for testing Google Test assertions or code that's expected
115 // to generate Google Test fatal failures. It verifies that the given
116 // statement will cause exactly one fatal Google Test failure with 'substr'
117 // being part of the failure message.
118 //
119 // There are two different versions of this macro. EXPECT_FATAL_FAILURE only
120 // affects and considers failures generated in the current thread and
121 // EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
122 //
123 // The verification of the assertion is done correctly even when the statement
124 // throws an exception or aborts the current function.
125 //
126 // Known restrictions:
127 // - 'statement' cannot reference local non-static variables or
128 // non-static members of the current object.
129 // - 'statement' cannot return a value.
130 // - You cannot stream a failure message to this macro.
131 //
132 // Note that even though the implementations of the following two
133 // macros are much alike, we cannot refactor them to use a common
134 // helper macro, due to some peculiarity in how the preprocessor
135 // works. The AcceptsMacroThatExpandsToUnprotectedComma test in
136 // gtest_unittest.cc will fail to compile if we do that.
137 #define EXPECT_FATAL_FAILURE(statement, substr) \
138 do { \
139 class GTestExpectFatalFailureHelper {\
140 public:\
141 static void Execute() { statement; }\
142 };\
143 ::testing::TestPartResultArray gtest_failures;\
144 ::testing::internal::SingleFailureChecker gtest_checker(\
145 >est_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
146 {\
147 ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
148 ::testing::ScopedFakeTestPartResultReporter:: \
149 INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
150 GTestExpectFatalFailureHelper::Execute();\
151 }\
152 } while (false)
153
154 #define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
155 do { \
156 class GTestExpectFatalFailureHelper {\
157 public:\
158 static void Execute() { statement; }\
159 };\
160 ::testing::TestPartResultArray gtest_failures;\
161 ::testing::internal::SingleFailureChecker gtest_checker(\
162 >est_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\
163 {\
164 ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
165 ::testing::ScopedFakeTestPartResultReporter:: \
166 INTERCEPT_ALL_THREADS, >est_failures);\
167 GTestExpectFatalFailureHelper::Execute();\
168 }\
169 } while (false)
170
171 // A macro for testing Google Test assertions or code that's expected to
172 // generate Google Test non-fatal failures. It asserts that the given
173 // statement will cause exactly one non-fatal Google Test failure with 'substr'
174 // being part of the failure message.
175 //
176 // There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
177 // affects and considers failures generated in the current thread and
178 // EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
179 //
180 // 'statement' is allowed to reference local variables and members of
181 // the current object.
182 //
183 // The verification of the assertion is done correctly even when the statement
184 // throws an exception or aborts the current function.
185 //
186 // Known restrictions:
187 // - You cannot stream a failure message to this macro.
188 //
189 // Note that even though the implementations of the following two
190 // macros are much alike, we cannot refactor them to use a common
191 // helper macro, due to some peculiarity in how the preprocessor
192 // works. The AcceptsMacroThatExpandsToUnprotectedComma test in
193 // gtest_unittest.cc will fail to compile if we do that.
194 #define EXPECT_NONFATAL_FAILURE(statement, substr) \
195 do {\
196 ::testing::TestPartResultArray gtest_failures;\
197 ::testing::internal::SingleFailureChecker gtest_checker(\
198 >est_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
199 {\
200 ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
201 ::testing::ScopedFakeTestPartResultReporter:: \
202 INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
203 statement;\
204 }\
205 } while (false)
206
207 #define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
208 do {\
209 ::testing::TestPartResultArray gtest_failures;\
210 ::testing::internal::SingleFailureChecker gtest_checker(\
211 >est_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\
212 {\
213 ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
214 ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
215 >est_failures);\
216 statement;\
217 }\
218 } while (false)
219
220 #endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
0 // Copyright 2008, Google Inc.
1 // All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: mheule@google.com (Markus Heule)
30 //
31
32 #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
33 #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
34
35 #include
36 #include
37 #include
38
39 namespace testing {
40
41 // The possible outcomes of a test part (i.e. an assertion or an
42 // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
43 enum TestPartResultType {
44 TPRT_SUCCESS, // Succeeded.
45 TPRT_NONFATAL_FAILURE, // Failed but the test can continue.
46 TPRT_FATAL_FAILURE // Failed and the test should be terminated.
47 };
48
49 // A copyable object representing the result of a test part (i.e. an
50 // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
51 //
52 // Don't inherit from TestPartResult as its destructor is not virtual.
53 class TestPartResult {
54 public:
55 // C'tor. TestPartResult does NOT have a default constructor.
56 // Always use this constructor (with parameters) to create a
57 // TestPartResult object.
58 TestPartResult(TestPartResultType type,
59 const char* file_name,
60 int line_number,
61 const char* message)
62 : type_(type),
63 file_name_(file_name),
64 line_number_(line_number),
65 summary_(ExtractSummary(message)),
66 message_(message) {
67 }
68
69 // Gets the outcome of the test part.
70 TestPartResultType type() const { return type_; }
71
72 // Gets the name of the source file where the test part took place, or
73 // NULL if it's unknown.
74 const char* file_name() const { return file_name_.c_str(); }
75
76 // Gets the line in the source file where the test part took place,
77 // or -1 if it's unknown.
78 int line_number() const { return line_number_; }
79
80 // Gets the summary of the failure message.
81 const char* summary() const { return summary_.c_str(); }
82
83 // Gets the message associated with the test part.
84 const char* message() const { return message_.c_str(); }
85
86 // Returns true iff the test part passed.
87 bool passed() const { return type_ == TPRT_SUCCESS; }
88
89 // Returns true iff the test part failed.
90 bool failed() const { return type_ != TPRT_SUCCESS; }
91
92 // Returns true iff the test part non-fatally failed.
93 bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; }
94
95 // Returns true iff the test part fatally failed.
96 bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; }
97 private:
98 TestPartResultType type_;
99
100 // Gets the summary of the failure message by omitting the stack
101 // trace in it.
102 static internal::String ExtractSummary(const char* message);
103
104 // The name of the source file where the test part took place, or
105 // NULL if the source file is unknown.
106 internal::String file_name_;
107 // The line in the source file where the test part took place, or -1
108 // if the line number is unknown.
109 int line_number_;
110 internal::String summary_; // The test failure summary.
111 internal::String message_; // The test failure message.
112 };
113
114 // Prints a TestPartResult object.
115 std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
116
117 // An array of TestPartResult objects.
118 //
119 // We define this class as we cannot use STL containers when compiling
120 // Google Test with MSVC 7.1 and exceptions disabled.
121 //
122 // Don't inherit from TestPartResultArray as its destructor is not
123 // virtual.
124 class TestPartResultArray {
125 public:
126 TestPartResultArray();
127 ~TestPartResultArray();
128
129 // Appends the given TestPartResult to the array.
130 void Append(const TestPartResult& result);
131
132 // Returns the TestPartResult at the given index (0-based).
133 const TestPartResult& GetTestPartResult(int index) const;
134
135 // Returns the number of TestPartResult objects in the array.
136 int size() const;
137 private:
138 // Internally we use a list to simulate the array. Yes, this means
139 // that random access is O(N) in time, but it's OK for its purpose.
140 internal::List* const list_;
141
142 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
143 };
144
145 // This interface knows how to report a test part result.
146 class TestPartResultReporterInterface {
147 public:
148 virtual ~TestPartResultReporterInterface() {}
149
150 virtual void ReportTestPartResult(const TestPartResult& result) = 0;
151 };
152
153 namespace internal {
154
155 // This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
156 // statement generates new fatal failures. To do so it registers itself as the
157 // current test part result reporter. Besides checking if fatal failures were
158 // reported, it only delegates the reporting to the former result reporter.
159 // The original result reporter is restored in the destructor.
160 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
161 class HasNewFatalFailureHelper : public TestPartResultReporterInterface {
162 public:
163 HasNewFatalFailureHelper();
164 virtual ~HasNewFatalFailureHelper();
165 virtual void ReportTestPartResult(const TestPartResult& result);
166 bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
167 private:
168 bool has_new_fatal_failure_;
169 TestPartResultReporterInterface* original_reporter_;
170
171 GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
172 };
173
174 } // namespace internal
175
176 } // namespace testing
177
178 #endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
0 // Copyright 2008 Google Inc.
1 // All Rights Reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: wan@google.com (Zhanyong Wan)
30
31 #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
32 #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
33
34 // This header implements typed tests and type-parameterized tests.
35
36 // Typed (aka type-driven) tests repeat the same test for types in a
37 // list. You must know which types you want to test with when writing
38 // typed tests. Here's how you do it:
39
40 #if 0
41
42 // First, define a fixture class template. It should be parameterized
43 // by a type. Remember to derive it from testing::Test.
44 template
45 class FooTest : public testing::Test {
46 public:
47 ...
48 typedef std::list List;
49 static T shared_;
50 T value_;
51 };
52
53 // Next, associate a list of types with the test case, which will be
54 // repeated for each type in the list. The typedef is necessary for
55 // the macro to parse correctly.
56 typedef testing::Types MyTypes;
57 TYPED_TEST_CASE(FooTest, MyTypes);
58
59 // If the type list contains only one type, you can write that type
60 // directly without Types<...>:
61 // TYPED_TEST_CASE(FooTest, int);
62
63 // Then, use TYPED_TEST() instead of TEST_F() to define as many typed
64 // tests for this test case as you want.
65 TYPED_TEST(FooTest, DoesBlah) {
66 // Inside a test, refer to TypeParam to get the type parameter.
67 // Since we are inside a derived class template, C++ requires use to
68 // visit the members of FooTest via 'this'.
69 TypeParam n = this->value_;
70
71 // To visit static members of the fixture, add the TestFixture::
72 // prefix.
73 n += TestFixture::shared_;
74
75 // To refer to typedefs in the fixture, add the "typename
76 // TestFixture::" prefix.
77 typename TestFixture::List values;
78 values.push_back(n);
79 ...
80 }
81
82 TYPED_TEST(FooTest, HasPropertyA) { ... }
83
84 #endif // 0
85
86 // Type-parameterized tests are abstract test patterns parameterized
87 // by a type. Compared with typed tests, type-parameterized tests
88 // allow you to define the test pattern without knowing what the type
89 // parameters are. The defined pattern can be instantiated with
90 // different types any number of times, in any number of translation
91 // units.
92 //
93 // If you are designing an interface or concept, you can define a
94 // suite of type-parameterized tests to verify properties that any
95 // valid implementation of the interface/concept should have. Then,
96 // each implementation can easily instantiate the test suite to verify
97 // that it conforms to the requirements, without having to write
98 // similar tests repeatedly. Here's an example:
99
100 #if 0
101
102 // First, define a fixture class template. It should be parameterized
103 // by a type. Remember to derive it from testing::Test.
104 template
105 class FooTest : public testing::Test {
106 ...
107 };
108
109 // Next, declare that you will define a type-parameterized test case
110 // (the _P suffix is for "parameterized" or "pattern", whichever you
111 // prefer):
112 TYPED_TEST_CASE_P(FooTest);
113
114 // Then, use TYPED_TEST_P() to define as many type-parameterized tests
115 // for this type-parameterized test case as you want.
116 TYPED_TEST_P(FooTest, DoesBlah) {
117 // Inside a test, refer to TypeParam to get the type parameter.
118 TypeParam n = 0;
119 ...
120 }
121
122 TYPED_TEST_P(FooTest, HasPropertyA) { ... }
123
124 // Now the tricky part: you need to register all test patterns before
125 // you can instantiate them. The first argument of the macro is the
126 // test case name; the rest are the names of the tests in this test
127 // case.
128 REGISTER_TYPED_TEST_CASE_P(FooTest,
129 DoesBlah, HasPropertyA);
130
131 // Finally, you are free to instantiate the pattern with the types you
132 // want. If you put the above code in a header file, you can #include
133 // it in multiple C++ source files and instantiate it multiple times.
134 //
135 // To distinguish different instances of the pattern, the first
136 // argument to the INSTANTIATE_* macro is a prefix that will be added
137 // to the actual test case name. Remember to pick unique prefixes for
138 // different instances.
139 typedef testing::Types MyTypes;
140 INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
141
142 // If the type list contains only one type, you can write that type
143 // directly without Types<...>:
144 // INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
145
146 #endif // 0
147
148 #include
149 #include
150
151 // Implements typed tests.
152
153 #ifdef GTEST_HAS_TYPED_TEST
154
155 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
156 //
157 // Expands to the name of the typedef for the type parameters of the
158 // given test case.
159 #define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
160
161 #define TYPED_TEST_CASE(CaseName, Types) \
162 typedef ::testing::internal::TypeList::type \
163 GTEST_TYPE_PARAMS_(CaseName)
164
165 #define TYPED_TEST(CaseName, TestName) \
166 template \
167 class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
168 : public CaseName { \
169 private: \
170 typedef CaseName TestFixture; \
171 typedef gtest_TypeParam_ TypeParam; \
172 virtual void TestBody(); \
173 }; \
174 bool gtest_##CaseName##_##TestName##_registered_ = \
175 ::testing::internal::TypeParameterizedTest< \
176 CaseName, \
177 ::testing::internal::TemplateSel< \
178 GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
179 GTEST_TYPE_PARAMS_(CaseName)>::Register(\
180 "", #CaseName, #TestName, 0); \
181 template \
182 void GTEST_TEST_CLASS_NAME_(CaseName, TestName)::TestBody()
183
184 #endif // GTEST_HAS_TYPED_TEST
185
186 // Implements type-parameterized tests.
187
188 #ifdef GTEST_HAS_TYPED_TEST_P
189
190 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
191 //
192 // Expands to the namespace name that the type-parameterized tests for
193 // the given type-parameterized test case are defined in. The exact
194 // name of the namespace is subject to change without notice.
195 #define GTEST_CASE_NAMESPACE_(TestCaseName) \
196 gtest_case_##TestCaseName##_
197
198 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
199 //
200 // Expands to the name of the variable used to remember the names of
201 // the defined tests in the given test case.
202 #define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
203 gtest_typed_test_case_p_state_##TestCaseName##_
204
205 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
206 //
207 // Expands to the name of the variable used to remember the names of
208 // the registered tests in the given test case.
209 #define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
210 gtest_registered_test_names_##TestCaseName##_
211
212 // The variables defined in the type-parameterized test macros are
213 // static as typically these macros are used in a .h file that can be
214 // #included in multiple translation units linked together.
215 #define TYPED_TEST_CASE_P(CaseName) \
216 static ::testing::internal::TypedTestCasePState \
217 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
218
219 #define TYPED_TEST_P(CaseName, TestName) \
220 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
221 template \
222 class TestName : public CaseName { \
223 private: \
224 typedef CaseName TestFixture; \
225 typedef gtest_TypeParam_ TypeParam; \
226 virtual void TestBody(); \
227 }; \
228 static bool gtest_##TestName##_defined_ = \
229 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
230 __FILE__, __LINE__, #CaseName, #TestName); \
231 } \
232 template \
233 void GTEST_CASE_NAMESPACE_(CaseName)::TestName::TestBody()
234
235 #define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
236 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
237 typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
238 } \
239 static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
240 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
241 __FILE__, __LINE__, #__VA_ARGS__)
242
243 #define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
244 bool gtest_##Prefix##_##CaseName = \
245 ::testing::internal::TypeParameterizedTestCase
246 GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
247 ::testing::internal::TypeList::type>::Register(\
248 #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
249
250 #endif // GTEST_HAS_TYPED_TEST_P
251
252 #endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
0 // Copyright 2005, Google Inc.
1 // All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Author: wan@google.com (Zhanyong Wan)
30 //
31 // The Google C++ Testing Framework (Google Test)
32 //
33 // This header file defines the public API for Google Test. It should be
34 // included by any test program that uses Google Test.
35 //
36 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
37 // leave some internal implementation details in this header file.
38 // They are clearly marked by comments like this:
39 //
40 // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
41 //
42 // Such code is NOT meant to be used by a user directly, and is subject
43 // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
44 // program!
45 //
46 // Acknowledgment: Google Test borrowed the idea of automatic test
47 // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
48 // easyUnit framework.
49
50 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
51 #define GTEST_INCLUDE_GTEST_GTEST_H_
52
53 // The following platform macros are used throughout Google Test:
54 // _WIN32_WCE Windows CE (set in project files)
55 //
56 // Note that even though _MSC_VER and _WIN32_WCE really indicate a compiler
57 // and a Win32 implementation, respectively, we use them to indicate the
58 // combination of compiler - Win 32 API - C library, since the code currently
59 // only supports:
60 // Windows proper with Visual C++ and MS C library (_MSC_VER && !_WIN32_WCE) and
61 // Windows Mobile with Visual C++ and no C library (_WIN32_WCE).
62
63 #include
64 #include
65 #include
66 #include
67 #include
68 #include
69 #include
70 #include
71 #include
72
73 // Depending on the platform, different string classes are available.
74 // On Windows, ::std::string compiles only when exceptions are
75 // enabled. On Linux, in addition to ::std::string, Google also makes
76 // use of class ::string, which has the same interface as
77 // ::std::string, but has a different implementation.
78 //
79 // The user can tell us whether ::std::string is available in his
80 // environment by defining the macro GTEST_HAS_STD_STRING to either 1
81 // or 0 on the compiler command line. He can also define
82 // GTEST_HAS_GLOBAL_STRING to 1 to indicate that ::string is available
83 // AND is a distinct type to ::std::string, or define it to 0 to
84 // indicate otherwise.
85 //
86 // If the user's ::std::string and ::string are the same class due to
87 // aliasing, he should define GTEST_HAS_STD_STRING to 1 and
88 // GTEST_HAS_GLOBAL_STRING to 0.
89 //
90 // If the user doesn't define GTEST_HAS_STD_STRING and/or
91 // GTEST_HAS_GLOBAL_STRING, they are defined heuristically.
92
93 namespace testing {
94
95 // The upper limit for valid stack trace depths.
96 const int kMaxStackTraceDepth = 100;
97
98 // This flag specifies the maximum number of stack frames to be
99 // printed in a failure message.
100 GTEST_DECLARE_int32_(stack_trace_depth);
101
102 // This flag controls whether Google Test includes Google Test internal
103 // stack frames in failure stack traces.
104 GTEST_DECLARE_bool_(show_internal_stack_frames);
105
106 namespace internal {
107
108 class GTestFlagSaver;
109
110 // Converts a streamable value to a String. A NULL pointer is
111 // converted to "(null)". When the input value is a ::string,
112 // ::std::string, ::wstring, or ::std::wstring object, each NUL
113 // character in it is replaced with "\\0".
114 // Declared in gtest-internal.h but defined here, so that it has access
115 // to the definition of the Message class, required by the ARM
116 // compiler.
117 template
118 String StreamableToString(const T& streamable) {
119 return (Message() << streamable).GetString();
120 }
121
122 } // namespace internal
123
124 // A class for indicating whether an assertion was successful. When
125 // the assertion wasn't successful, the AssertionResult object
126 // remembers a non-empty message that described how it failed.
127 //
128 // This class is useful for defining predicate-format functions to be
129 // used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
130 //
131 // The constructor of AssertionResult is private. To create an
132 // instance of this class, use one of the factory functions
133 // (AssertionSuccess() and AssertionFailure()).
134 //
135 // For example, in order to be able to write:
136 //
137 // // Verifies that Foo() returns an even number.
138 // EXPECT_PRED_FORMAT1(IsEven, Foo());
139 //
140 // you just need to define:
141 //
142 // testing::AssertionResult IsEven(const char* expr, int n) {
143 // if ((n % 2) == 0) return testing::AssertionSuccess();
144 //
145 // Message msg;
146 // msg << "Expected: " << expr << " is even\n"
147 // << " Actual: it's " << n;
148 // return testing::AssertionFailure(msg);
149 // }
150 //
151 // If Foo() returns 5, you will see the following message:
152 //
153 // Expected: Foo() is even
154 // Actual: it's 5
155 class AssertionResult {
156 public:
157 // Declares factory functions for making successful and failed
158 // assertion results as friends.
159 friend AssertionResult AssertionSuccess();
160 friend AssertionResult AssertionFailure(const Message&);
161
162 // Returns true iff the assertion succeeded.
163 operator bool() const { return failure_message_.c_str() == NULL; } // NOLINT
164
165 // Returns the assertion's failure message.
166 const char* failure_message() const { return failure_message_.c_str(); }
167
168 private:
169 // The default constructor. It is used when the assertion succeeded.
170 AssertionResult() {}
171
172 // The constructor used when the assertion failed.
173 explicit AssertionResult(const internal::String& failure_message);
174
175 // Stores the assertion's failure message.
176 internal::String failure_message_;
177 };
178
179 // Makes a successful assertion result.
180 AssertionResult AssertionSuccess();
181
182 // Makes a failed assertion result with the given failure message.
183 AssertionResult AssertionFailure(const Message& msg);
184
185 // The abstract class that all tests inherit from.
186 //
187 // In Google Test, a unit test program contains one or many TestCases, and
188 // each TestCase contains one or many Tests.
189 //
190 // When you define a test using the TEST macro, you don't need to
191 // explicitly derive from Test - the TEST macro automatically does
192 // this for you.
193 //
194 // The only time you derive from Test is when defining a test fixture
195 // to be used a TEST_F. For example:
196 //
197 // class FooTest : public testing::Test {
198 // protected:
199 // virtual void SetUp() { ... }
200 // virtual void TearDown() { ... }
201 // ...
202 // };
203 //
204 // TEST_F(FooTest, Bar) { ... }
205 // TEST_F(FooTest, Baz) { ... }
206 //
207 // Test is not copyable.
208 class Test {
209 public:
210 friend class internal::TestInfoImpl;
211
212 // Defines types for pointers to functions that set up and tear down
213 // a test case.
214 typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;
215 typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;
216
217 // The d'tor is virtual as we intend to inherit from Test.
218 virtual ~Test();
219
220 // Sets up the stuff shared by all tests in this test case.
221 //
222 // Google Test will call Foo::SetUpTestCase() before running the first
223 // test in test case Foo. Hence a sub-class can define its own
224 // SetUpTestCase() method to shadow the one defined in the super
225 // class.
226 static void SetUpTestCase() {}
227
228 // Tears down the stuff shared by all tests in this test case.
229 //
230 // Google Test will call Foo::TearDownTestCase() after running the last
231 // test in test case Foo. Hence a sub-class can define its own
232 // TearDownTestCase() method to shadow the one defined in the super
233 // class.
234 static void TearDownTestCase() {}
235
236 // Returns true iff the current test has a fatal failure.
237 static bool HasFatalFailure();
238
239 // Logs a property for the current test. Only the last value for a given
240 // key is remembered.
241 // These are public static so they can be called from utility functions
242 // that are not members of the test fixture.
243 // The arguments are const char* instead strings, as Google Test is used
244 // on platforms where string doesn't compile.
245 //
246 // Note that a driving consideration for these RecordProperty methods
247 // was to produce xml output suited to the Greenspan charting utility,
248 // which at present will only chart values that fit in a 32-bit int. It
249 // is the user's responsibility to restrict their values to 32-bit ints
250 // if they intend them to be used with Greenspan.
251 static void RecordProperty(const char* key, const char* value);
252 static void RecordProperty(const char* key, int value);
253
254 protected:
255 // Creates a Test object.
256 Test();
257
258 // Sets up the test fixture.
259 virtual void SetUp();
260
261 // Tears down the test fixture.
262 virtual void TearDown();
263
264 private:
265 // Returns true iff the current test has the same fixture class as
266 // the first test in the current test case.
267 static bool HasSameFixtureClass();
268
269 // Runs the test after the test fixture has been set up.
270 //
271 // A sub-class must implement this to define the test logic.
272 //
273 // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
274 // Instead, use the TEST or TEST_F macro.
275 virtual void TestBody() = 0;
276
277 // Sets up, executes, and tears down the test.
278 void Run();
279
280 // Uses a GTestFlagSaver to save and restore all Google Test flags.
281 const internal::GTestFlagSaver* const gtest_flag_saver_;
282
283 // Often a user mis-spells SetUp() as Setup() and spends a long time
284 // wondering why it is never called by Google Test. The declaration of
285 // the following method is solely for catching such an error at
286 // compile time:
287 //
288 // - The return type is deliberately chosen to be not void, so it
289 // will be a conflict if a user declares void Setup() in his test
290 // fixture.
291 //
292 // - This method is private, so it will be another compiler error
293 // if a user calls it from his test fixture.
294 //
295 // DO NOT OVERRIDE THIS FUNCTION.
296 //
297 // If you see an error about overriding the following function or
298 // about it being private, you have mis-spelled SetUp() as Setup().
299 struct Setup_should_be_spelled_SetUp {};
300 virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
301
302 // We disallow copying Tests.
303 GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
304 };
305
306
307 // A TestInfo object stores the following information about a test:
308 //
309 // Test case name
310 // Test name
311 // Whether the test should be run
312 // A function pointer that creates the test object when invoked
313 // Test result
314 //
315 // The constructor of TestInfo registers itself with the UnitTest
316 // singleton such that the RUN_ALL_TESTS() macro knows which tests to
317 // run.
318 class TestInfo {
319 public:
320 // Destructs a TestInfo object. This function is not virtual, so
321 // don't inherit from TestInfo.
322 ~TestInfo();
323
324 // Returns the test case name.
325 const char* test_case_name() const;
326
327 // Returns the test name.
328 const char* name() const;
329
330 // Returns the test case comment.
331 const char* test_case_comment() const;
332
333 // Returns the test comment.
334 const char* comment() const;
335
336 // Returns true if this test should run.
337 //
338 // Google Test allows the user to filter the tests by their full names.
339 // The full name of a test Bar in test case Foo is defined as
340 // "Foo.Bar". Only the tests that match the filter will run.
341 //
342 // A filter is a colon-separated list of glob (not regex) patterns,
343 // optionally followed by a '-' and a colon-separated list of
344 // negative patterns (tests to exclude). A test is run if it
345 // matches one of the positive patterns and does not match any of
346 // the negative patterns.
347 //
348 // For example, *A*:Foo.* is a filter that matches any string that
349 // contains the character 'A' or starts with "Foo.".
350 bool should_run() const;
351
352 // Returns the result of the test.
353 const internal::TestResult* result() const;
354 private:
355 #ifdef GTEST_HAS_DEATH_TEST
356 friend class internal::DefaultDeathTestFactory;
357 #endif // GTEST_HAS_DEATH_TEST
358 friend class internal::TestInfoImpl;
359 friend class internal::UnitTestImpl;
360 friend class Test;
361 friend class TestCase;
362 friend TestInfo* internal::MakeAndRegisterTestInfo(
363 const char* test_case_name, const char* name,
364 const char* test_case_comment, const char* comment,
365 internal::TypeId fixture_class_id,
366 Test::SetUpTestCaseFunc set_up_tc,
367 Test::TearDownTestCaseFunc tear_down_tc,
368 internal::TestFactoryBase* factory);
369
370 // Increments the number of death tests encountered in this test so
371 // far.
372 int increment_death_test_count();
373
374 // Accessors for the implementation object.
375 internal::TestInfoImpl* impl() { return impl_; }
376 const internal::TestInfoImpl* impl() const { return impl_; }
377
378 // Constructs a TestInfo object. The newly constructed instance assumes
379 // ownership of the factory object.
380 TestInfo(const char* test_case_name, const char* name,
381 const char* test_case_comment, const char* comment,
382 internal::TypeId fixture_class_id,
383 internal::TestFactoryBase* factory);
384
385 // An opaque implementation object.
386 internal::TestInfoImpl* impl_;
387
388 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
389 };
390
391 // An Environment object is capable of setting up and tearing down an
392 // environment. The user should subclass this to define his own
393 // environment(s).
394 //
395 // An Environment object does the set-up and tear-down in virtual
396 // methods SetUp() and TearDown() instead of the constructor and the
397 // destructor, as:
398 //
399 // 1. You cannot safely throw from a destructor. This is a problem
400 // as in some cases Google Test is used where exceptions are enabled, and
401 // we may want to implement ASSERT_* using exceptions where they are
402 // available.
403 // 2. You cannot use ASSERT_* directly in a constructor or
404 // destructor.
405 class Environment {
406 public:
407 // The d'tor is virtual as we need to subclass Environment.
408 virtual ~Environment() {}
409
410 // Override this to define how to set up the environment.
411 virtual void SetUp() {}
412
413 // Override this to define how to tear down the environment.
414 virtual void TearDown() {}
415 private:
416 // If you see an error about overriding the following function or
417 // about it being private, you have mis-spelled SetUp() as Setup().
418 struct Setup_should_be_spelled_SetUp {};
419 virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
420 };
421
422 // A UnitTest consists of a list of TestCases.
423 //
424 // This is a singleton class. The only instance of UnitTest is
425 // created when UnitTest::GetInstance() is first called. This
426 // instance is never deleted.
427 //
428 // UnitTest is not copyable.
429 //
430 // This class is thread-safe as long as the methods are called
431 // according to their specification.
432 class UnitTest {
433 public:
434 // Gets the singleton UnitTest object. The first time this method
435 // is called, a UnitTest object is constructed and returned.
436 // Consecutive calls will return the same object.
437 static UnitTest* GetInstance();
438
439 // Registers and returns a global test environment. When a test
440 // program is run, all global test environments will be set-up in
441 // the order they were registered. After all tests in the program
442 // have finished, all global test environments will be torn-down in
443 // the *reverse* order they were registered.
444 //
445 // The UnitTest object takes ownership of the given environment.
446 //
447 // This method can only be called from the main thread.
448 Environment* AddEnvironment(Environment* env);
449
450 // Adds a TestPartResult to the current TestResult object. All
451 // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
452 // eventually call this to report their results. The user code
453 // should use the assertion macros instead of calling this directly.
454 //
455 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
456 void AddTestPartResult(TestPartResultType result_type,
457 const char* file_name,
458 int line_number,
459 const internal::String& message,
460 const internal::String& os_stack_trace);
461
462 // Adds a TestProperty to the current TestResult object. If the result already
463 // contains a property with the same key, the value will be updated.
464 void RecordPropertyForCurrentTest(const char* key, const char* value);
465
466 // Runs all tests in this UnitTest object and prints the result.
467 // Returns 0 if successful, or 1 otherwise.
468 //
469 // This method can only be called from the main thread.
470 //
471 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
472 int Run() GTEST_MUST_USE_RESULT_;
473
474 // Returns the working directory when the first TEST() or TEST_F()
475 // was executed. The UnitTest object owns the string.
476 const char* original_working_dir() const;
477
478 // Returns the TestCase object for the test that's currently running,
479 // or NULL if no test is running.
480 const TestCase* current_test_case() const;
481
482 // Returns the TestInfo object for the test that's currently running,
483 // or NULL if no test is running.
484 const TestInfo* current_test_info() const;
485
486 #ifdef GTEST_HAS_PARAM_TEST
487 // Returns the ParameterizedTestCaseRegistry object used to keep track of
488 // value-parameterized tests and instantiate and register them.
489 internal::ParameterizedTestCaseRegistry& parameterized_test_registry();
490 #endif // GTEST_HAS_PARAM_TEST
491
492 // Accessors for the implementation object.
493 internal::UnitTestImpl* impl() { return impl_; }
494 const internal::UnitTestImpl* impl() const { return impl_; }
495 private:
496 // ScopedTrace is a friend as it needs to modify the per-thread
497 // trace stack, which is a private member of UnitTest.
498 friend class internal::ScopedTrace;
499
500 // Creates an empty UnitTest.
501 UnitTest();
502
503 // D'tor
504 virtual ~UnitTest();
505
506 // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
507 // Google Test trace stack.
508 void PushGTestTrace(const internal::TraceInfo& trace);
509
510 // Pops a trace from the per-thread Google Test trace stack.
511 void PopGTestTrace();
512
513 // Protects mutable state in *impl_. This is mutable as some const
514 // methods need to lock it too.
515 mutable internal::Mutex mutex_;
516
517 // Opaque implementation object. This field is never changed once
518 // the object is constructed. We don't mark it as const here, as
519 // doing so will cause a warning in the constructor of UnitTest.
520 // Mutable state in *impl_ is protected by mutex_.
521 internal::UnitTestImpl* impl_;
522
523 // We disallow copying UnitTest.
524 GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
525 };
526
527 // A convenient wrapper for adding an environment for the test
528 // program.
529 //
530 // You should call this before RUN_ALL_TESTS() is called, probably in
531 // main(). If you use gtest_main, you need to call this before main()
532 // starts for it to take effect. For example, you can define a global
533 // variable like this:
534 //
535 // testing::Environment* const foo_env =
536 // testing::AddGlobalTestEnvironment(new FooEnvironment);
537 //
538 // However, we strongly recommend you to write your own main() and
539 // call AddGlobalTestEnvironment() there, as relying on initialization
540 // of global variables makes the code harder to read and may cause
541 // problems when you register multiple environments from different
542 // translation units and the environments have dependencies among them
543 // (remember that the compiler doesn't guarantee the order in which
544 // global variables from different translation units are initialized).
545 inline Environment* AddGlobalTestEnvironment(Environment* env) {
546 return UnitTest::GetInstance()->AddEnvironment(env);
547 }
548
549 // Initializes Google Test. This must be called before calling
550 // RUN_ALL_TESTS(). In particular, it parses a command line for the
551 // flags that Google Test recognizes. Whenever a Google Test flag is
552 // seen, it is removed from argv, and *argc is decremented.
553 //
554 // No value is returned. Instead, the Google Test flag variables are
555 // updated.
556 //
557 // Calling the function for the second time has no user-visible effect.
558 void InitGoogleTest(int* argc, char** argv);
559
560 // This overloaded version can be used in Windows programs compiled in
561 // UNICODE mode.
562 void InitGoogleTest(int* argc, wchar_t** argv);
563
564 namespace internal {
565
566 // These overloaded versions handle ::std::string and ::std::wstring.
567 #if GTEST_HAS_STD_STRING
568 inline String FormatForFailureMessage(const ::std::string& str) {
569 return (Message() << '"' << str << '"').GetString();
570 }
571 #endif // GTEST_HAS_STD_STRING
572
573 #if GTEST_HAS_STD_WSTRING
574 inline String FormatForFailureMessage(const ::std::wstring& wstr) {
575 return (Message() << "L\"" << wstr << '"').GetString();
576 }
577 #endif // GTEST_HAS_STD_WSTRING
578
579 // These overloaded versions handle ::string and ::wstring.
580 #if GTEST_HAS_GLOBAL_STRING
581 inline String FormatForFailureMessage(const ::string& str) {
582 return (Message() << '"' << str << '"').GetString();
583 }
584 #endif // GTEST_HAS_GLOBAL_STRING
585
586 #if GTEST_HAS_GLOBAL_WSTRING
587 inline String FormatForFailureMessage(const ::wstring& wstr) {
588 return (Message() << "L\"" << wstr << '"').GetString();
589 }
590 #endif // GTEST_HAS_GLOBAL_WSTRING
591
592 // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
593 // operand to be used in a failure message. The type (but not value)
594 // of the other operand may affect the format. This allows us to
595 // print a char* as a raw pointer when it is compared against another
596 // char*, and print it as a C string when it is compared against an
597 // std::string object, for example.
598 //
599 // The default implementation ignores the type of the other operand.
600 // Some specialized versions are used to handle formatting wide or
601 // narrow C strings.
602 //
603 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
604 template
605 String FormatForComparisonFailureMessage(const T1& value,
606 const T2& /* other_operand */) {
607 return FormatForFailureMessage(value);
608 }
609
610 // The helper function for {ASSERT|EXPECT}_EQ.
611 template
612 AssertionResult CmpHelperEQ(const char* expected_expression,
613 const char* actual_expression,
614 const T1& expected,
615 const T2& actual) {
616 if (expected == actual) {
617 return AssertionSuccess();
618 }
619
620 return EqFailure(expected_expression,
621 actual_expression,
622 FormatForComparisonFailureMessage(expected, actual),
623 FormatForComparisonFailureMessage(actual, expected),
624 false);
625 }
626
627 // With this overloaded version, we allow anonymous enums to be used
628 // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
629 // can be implicitly cast to BiggestInt.
630 AssertionResult CmpHelperEQ(const char* expected_expression,
631 const char* actual_expression,
632 BiggestInt expected,
633 BiggestInt actual);
634
635 // The helper class for {ASSERT|EXPECT}_EQ. The template argument
636 // lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
637 // is a null pointer literal. The following default implementation is
638 // for lhs_is_null_literal being false.
639 template
640 class EqHelper {
641 public:
642 // This templatized version is for the general case.
643 template
644 static AssertionResult Compare(const char* expected_expression,
645 const char* actual_expression,
646 const T1& expected,
647 const T2& actual) {
648 return CmpHelperEQ(expected_expression, actual_expression, expected,
649 actual);
650 }
651
652 // With this overloaded version, we allow anonymous enums to be used
653 // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
654 // enums can be implicitly cast to BiggestInt.
655 //
656 // Even though its body looks the same as the above version, we
657 // cannot merge the two, as it will make anonymous enums unhappy.
658 static AssertionResult Compare(const char* expected_expression,
659 const char* actual_expression,
660 BiggestInt expected,
661 BiggestInt actual) {
662 return CmpHelperEQ(expected_expression, actual_expression, expected,
663 actual);
664 }
665 };
666
667 // This specialization is used when the first argument to ASSERT_EQ()
668 // is a null pointer literal.
669 template <>
670 class EqHelper {
671 public:
672 // We define two overloaded versions of Compare(). The first
673 // version will be picked when the second argument to ASSERT_EQ() is
674 // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
675 // EXPECT_EQ(false, a_bool).
676 template
677 static AssertionResult Compare(const char* expected_expression,
678 const char* actual_expression,
679 const T1& expected,
680 const T2& actual) {
681 return CmpHelperEQ(expected_expression, actual_expression, expected,
682 actual);
683 }
684
685 // This version will be picked when the second argument to
686 // ASSERT_EQ() is a pointer, e.g. ASSERT_EQ(NULL, a_pointer).
687 template
688 static AssertionResult Compare(const char* expected_expression,
689 const char* actual_expression,
690 const T1& expected,
691 T2* actual) {
692 // We already know that 'expected' is a null pointer.
693 return CmpHelperEQ(expected_expression, actual_expression,
694 static_cast(NULL), actual);
695 }
696 };
697
698 // A macro for implementing the helper functions needed to implement
699 // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste
700 // of similar code.
701 //
702 // For each templatized helper function, we also define an overloaded
703 // version for BiggestInt in order to reduce code bloat and allow
704 // anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
705 // with gcc 4.
706 //
707 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
708 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
709 template \
710 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
711 const T1& val1, const T2& val2) {\
712 if (val1 op val2) {\
713 return AssertionSuccess();\
714 } else {\
715 Message msg;\
716 msg << "Expected: (" << expr1 << ") " #op " (" << expr2\
717 << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
718 << " vs " << FormatForComparisonFailureMessage(val2, val1);\
719 return AssertionFailure(msg);\
720 }\
721 }\
722 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
723 BiggestInt val1, BiggestInt val2);
724
725 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
726
727 // Implements the helper function for {ASSERT|EXPECT}_NE
728 GTEST_IMPL_CMP_HELPER_(NE, !=)
729 // Implements the helper function for {ASSERT|EXPECT}_LE
730 GTEST_IMPL_CMP_HELPER_(LE, <=)
731 // Implements the helper function for {ASSERT|EXPECT}_LT
732 GTEST_IMPL_CMP_HELPER_(LT, < )
733 // Implements the helper function for {ASSERT|EXPECT}_GE
734 GTEST_IMPL_CMP_HELPER_(GE, >=)
735 // Implements the helper function for {ASSERT|EXPECT}_GT
736 GTEST_IMPL_CMP_HELPER_(GT, > )
737
738 #undef GTEST_IMPL_CMP_HELPER_
739
740 // The helper function for {ASSERT|EXPECT}_STREQ.
741 //
742 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
743 AssertionResult CmpHelperSTREQ(const char* expected_expression,
744 const char* actual_expression,
745 const char* expected,
746 const char* actual);
747
748 // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
749 //
750 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
751 AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
752 const char* actual_expression,
753 const char* expected,
754 const char* actual);
755
756 // The helper function for {ASSERT|EXPECT}_STRNE.
757 //
758 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
759 AssertionResult CmpHelperSTRNE(const char* s1_expression,
760 const char* s2_expression,
761 const char* s1,
762 const char* s2);
763
764 // The helper function for {ASSERT|EXPECT}_STRCASENE.
765 //
766 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
767 AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
768 const char* s2_expression,
769 const char* s1,
770 const char* s2);
771
772
773 // Helper function for *_STREQ on wide strings.
774 //
775 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
776 AssertionResult CmpHelperSTREQ(const char* expected_expression,
777 const char* actual_expression,
778 const wchar_t* expected,
779 const wchar_t* actual);
780
781 // Helper function for *_STRNE on wide strings.
782 //
783 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
784 AssertionResult CmpHelperSTRNE(const char* s1_expression,
785 const char* s2_expression,
786 const wchar_t* s1,
787 const wchar_t* s2);
788
789 } // namespace internal
790
791 // IsSubstring() and IsNotSubstring() are intended to be used as the
792 // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
793 // themselves. They check whether needle is a substring of haystack
794 // (NULL is considered a substring of itself only), and return an
795 // appropriate error message when they fail.
796 //
797 // The {needle,haystack}_expr arguments are the stringified
798 // expressions that generated the two real arguments.
799 AssertionResult IsSubstring(
800 const char* needle_expr, const char* haystack_expr,
801 const char* needle, const char* haystack);
802 AssertionResult IsSubstring(
803 const char* needle_expr, const char* haystack_expr,
804 const wchar_t* needle, const wchar_t* haystack);
805 AssertionResult IsNotSubstring(
806 const char* needle_expr, const char* haystack_expr,
807 const char* needle, const char* haystack);
808 AssertionResult IsNotSubstring(
809 const char* needle_expr, const char* haystack_expr,
810 const wchar_t* needle, const wchar_t* haystack);
811 #if GTEST_HAS_STD_STRING
812 AssertionResult IsSubstring(
813 const char* needle_expr, const char* haystack_expr,
814 const ::std::string& needle, const ::std::string& haystack);
815 AssertionResult IsNotSubstring(
816 const char* needle_expr, const char* haystack_expr,
817 const ::std::string& needle, const ::std::string& haystack);
818 #endif // GTEST_HAS_STD_STRING
819
820 #if GTEST_HAS_STD_WSTRING
821 AssertionResult IsSubstring(
822 const char* needle_expr, const char* haystack_expr,
823 const ::std::wstring& needle, const ::std::wstring& haystack);
824 AssertionResult IsNotSubstring(
825 const char* needle_expr, const char* haystack_expr,
826 const ::std::wstring& needle, const ::std::wstring& haystack);
827 #endif // GTEST_HAS_STD_WSTRING
828
829 namespace internal {
830
831 // Helper template function for comparing floating-points.
832 //
833 // Template parameter:
834 //
835 // RawType: the raw floating-point type (either float or double)
836 //
837 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
838 template
839 AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
840 const char* actual_expression,
841 RawType expected,
842 RawType actual) {
843 const FloatingPoint lhs(expected), rhs(actual);
844
845 if (lhs.AlmostEquals(rhs)) {
846 return AssertionSuccess();
847 }
848
849 StrStream expected_ss;
850 expected_ss << std::setprecision(std::numeric_limits::digits10 + 2)
851 << expected;
852
853 StrStream actual_ss;
854 actual_ss << std::setprecision(std::numeric_limits::digits10 + 2)
855 << actual;
856
857 return EqFailure(expected_expression,
858 actual_expression,
859 StrStreamToString(&expected_ss),
860 StrStreamToString(&actual_ss),
861 false);
862 }
863
864 // Helper function for implementing ASSERT_NEAR.
865 //
866 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.