1 // Copyright 2005, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Author: wan@google.com (Zhanyong Wan)
31 //
32 // The Google C++ Testing Framework (Google Test)
33 //
34 // This header file defines the public API for Google Test.  It should be
35 // included by any test program that uses Google Test.
36 //
37 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
38 // leave some internal implementation details in this header file.
39 // They are clearly marked by comments like this:
40 //
41 //   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
42 //
43 // Such code is NOT meant to be used by a user directly, and is subject
44 // to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
45 // program!
46 //
47 // Acknowledgment: Google Test borrowed the idea of automatic test
48 // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
49 // easyUnit framework.
50 
51 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
52 #define GTEST_INCLUDE_GTEST_GTEST_H_
53 
54 #include <limits>
55 #include <ostream>
56 #include <vector>
57 
58 // Copyright 2005, Google Inc.
59 // All rights reserved.
60 //
61 // Redistribution and use in source and binary forms, with or without
62 // modification, are permitted provided that the following conditions are
63 // met:
64 //
65 //     * Redistributions of source code must retain the above copyright
66 // notice, this list of conditions and the following disclaimer.
67 //     * Redistributions in binary form must reproduce the above
68 // copyright notice, this list of conditions and the following disclaimer
69 // in the documentation and/or other materials provided with the
70 // distribution.
71 //     * Neither the name of Google Inc. nor the names of its
72 // contributors may be used to endorse or promote products derived from
73 // this software without specific prior written permission.
74 //
75 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
76 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
77 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
78 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
79 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
80 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
81 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86 //
87 // Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
88 //
89 // The Google C++ Testing Framework (Google Test)
90 //
91 // This header file declares functions and macros used internally by
92 // Google Test.  They are subject to change without notice.
93 
94 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
95 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
96 
97 // Copyright 2005, Google Inc.
98 // All rights reserved.
99 //
100 // Redistribution and use in source and binary forms, with or without
101 // modification, are permitted provided that the following conditions are
102 // met:
103 //
104 //     * Redistributions of source code must retain the above copyright
105 // notice, this list of conditions and the following disclaimer.
106 //     * Redistributions in binary form must reproduce the above
107 // copyright notice, this list of conditions and the following disclaimer
108 // in the documentation and/or other materials provided with the
109 // distribution.
110 //     * Neither the name of Google Inc. nor the names of its
111 // contributors may be used to endorse or promote products derived from
112 // this software without specific prior written permission.
113 //
114 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
115 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
116 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
117 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
118 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
119 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
120 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
121 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
122 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
124 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
125 //
126 // Authors: wan@google.com (Zhanyong Wan)
127 //
128 // Low-level types and utilities for porting Google Test to various
129 // platforms.  All macros ending with _ and symbols defined in an
130 // internal namespace are subject to change without notice.  Code
131 // outside Google Test MUST NOT USE THEM DIRECTLY.  Macros that don't
132 // end with _ are part of Google Test's public API and can be used by
133 // code outside Google Test.
134 //
135 // This file is fundamental to Google Test.  All other Google Test source
136 // files are expected to #include this.  Therefore, it cannot #include
137 // any other Google Test header.
138 
139 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
140 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
141 
142 // Environment-describing macros
143 // -----------------------------
144 //
145 // Google Test can be used in many different environments.  Macros in
146 // this section tell Google Test what kind of environment it is being
147 // used in, such that Google Test can provide environment-specific
148 // features and implementations.
149 //
150 // Google Test tries to automatically detect the properties of its
151 // environment, so users usually don't need to worry about these
152 // macros.  However, the automatic detection is not perfect.
153 // Sometimes it's necessary for a user to define some of the following
154 // macros in the build script to override Google Test's decisions.
155 //
156 // If the user doesn't define a macro in the list, Google Test will
157 // provide a default definition.  After this header is #included, all
158 // macros in this list will be defined to either 1 or 0.
159 //
160 // Notes to maintainers:
161 //   - Each macro here is a user-tweakable knob; do not grow the list
162 //     lightly.
163 //   - Use #if to key off these macros.  Don't use #ifdef or "#if
164 //     defined(...)", which will not work as these macros are ALWAYS
165 //     defined.
166 //
167 //   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
168 //                              is/isn't available.
169 //   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
170 //                              are enabled.
171 //   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string
172 //                              is/isn't available (some systems define
173 //                              ::string, which is different to std::string).
174 //   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
175 //                              is/isn't available (some systems define
176 //                              ::wstring, which is different to std::wstring).
177 //   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular
178 //                              expressions are/aren't available.
179 //   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>
180 //                              is/isn't available.
181 //   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
182 //                              enabled.
183 //   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
184 //                              std::wstring does/doesn't work (Google Test can
185 //                              be used where std::wstring is unavailable).
186 //   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple
187 //                              is/isn't available.
188 //   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
189 //                              compiler supports Microsoft's "Structured
190 //                              Exception Handling".
191 //   GTEST_HAS_STREAM_REDIRECTION
192 //                            - Define it to 1/0 to indicate whether the
193 //                              platform supports I/O stream redirection using
194 //                              dup() and dup2().
195 //   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google
196 //                              Test's own tr1 tuple implementation should be
197 //                              used.  Unused when the user sets
198 //                              GTEST_HAS_TR1_TUPLE to 0.
199 //   GTEST_LANG_CXX11         - Define it to 1/0 to indicate that Google Test
200 //                              is building in C++11/C++98 mode.
201 //   GTEST_LINKED_AS_SHARED_LIBRARY
202 //                            - Define to 1 when compiling tests that use
203 //                              Google Test as a shared library (known as
204 //                              DLL on Windows).
205 //   GTEST_CREATE_SHARED_LIBRARY
206 //                            - Define to 1 when compiling Google Test itself
207 //                              as a shared library.
208 
209 // Platform-indicating macros
210 // --------------------------
211 //
212 // Macros indicating the platform on which Google Test is being used
213 // (a macro is defined to 1 if compiled on the given platform;
214 // otherwise UNDEFINED -- it's never defined to 0.).  Google Test
215 // defines these macros automatically.  Code outside Google Test MUST
216 // NOT define them.
217 //
218 //   GTEST_OS_AIX      - IBM AIX
219 //   GTEST_OS_CYGWIN   - Cygwin
220 //   GTEST_OS_FREEBSD  - FreeBSD
221 //   GTEST_OS_HPUX     - HP-UX
222 //   GTEST_OS_LINUX    - Linux
223 //     GTEST_OS_LINUX_ANDROID - Google Android
224 //   GTEST_OS_MAC      - Mac OS X
225 //     GTEST_OS_IOS    - iOS
226 //   GTEST_OS_NACL     - Google Native Client (NaCl)
227 //   GTEST_OS_OPENBSD  - OpenBSD
228 //   GTEST_OS_QNX      - QNX
229 //   GTEST_OS_SOLARIS  - Sun Solaris
230 //   GTEST_OS_SYMBIAN  - Symbian
231 //   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
232 //     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
233 //     GTEST_OS_WINDOWS_MINGW    - MinGW
234 //     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
235 //     GTEST_OS_WINDOWS_PHONE    - Windows Phone
236 //     GTEST_OS_WINDOWS_RT       - Windows Store App/WinRT
237 //   GTEST_OS_ZOS      - z/OS
238 //
239 // Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
240 // most stable support.  Since core members of the Google Test project
241 // don't have access to other platforms, support for them may be less
242 // stable.  If you notice any problems on your platform, please notify
243 // googletestframework@googlegroups.com (patches for fixing them are
244 // even more welcome!).
245 //
246 // It is possible that none of the GTEST_OS_* macros are defined.
247 
248 // Feature-indicating macros
249 // -------------------------
250 //
251 // Macros indicating which Google Test features are available (a macro
252 // is defined to 1 if the corresponding feature is supported;
253 // otherwise UNDEFINED -- it's never defined to 0.).  Google Test
254 // defines these macros automatically.  Code outside Google Test MUST
255 // NOT define them.
256 //
257 // These macros are public so that portable tests can be written.
258 // Such tests typically surround code using a feature with an #if
259 // which controls that code.  For example:
260 //
261 // #if GTEST_HAS_DEATH_TEST
262 //   EXPECT_DEATH(DoSomethingDeadly());
263 // #endif
264 //
265 //   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized
266 //                            tests)
267 //   GTEST_HAS_DEATH_TEST   - death tests
268 //   GTEST_HAS_PARAM_TEST   - value-parameterized tests
269 //   GTEST_HAS_TYPED_TEST   - typed tests
270 //   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
271 //   GTEST_IS_THREADSAFE    - Google Test is thread-safe.
272 //   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with
273 //                            GTEST_HAS_POSIX_RE (see above) which users can
274 //                            define themselves.
275 //   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
276 //                            the above two are mutually exclusive.
277 //   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
278 
279 // Misc public macros
280 // ------------------
281 //
282 //   GTEST_FLAG(flag_name)  - references the variable corresponding to
283 //                            the given Google Test flag.
284 
285 // Internal utilities
286 // ------------------
287 //
288 // The following macros and utilities are for Google Test's INTERNAL
289 // use only.  Code outside Google Test MUST NOT USE THEM DIRECTLY.
290 //
291 // Macros for basic C++ coding:
292 //   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
293 //   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
294 //                              variable don't have to be used.
295 //   GTEST_DISALLOW_ASSIGN_   - disables operator=.
296 //   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
297 //   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
298 //   GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
299 //                                        suppressed (constant conditional).
300 //   GTEST_INTENTIONAL_CONST_COND_POP_  - finish code section where MSVC C4127
301 //                                        is suppressed.
302 //
303 // C++11 feature wrappers:
304 //
305 //   testing::internal::move  - portability wrapper for std::move.
306 //
307 // Synchronization:
308 //   Mutex, MutexLock, ThreadLocal, GetThreadCount()
309 //                            - synchronization primitives.
310 //
311 // Template meta programming:
312 //   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.
313 //   IteratorTraits - partial implementation of std::iterator_traits, which
314 //                    is not available in libCstd when compiled with Sun C++.
315 //
316 // Smart pointers:
317 //   scoped_ptr     - as in TR2.
318 //
319 // Regular expressions:
320 //   RE             - a simple regular expression class using the POSIX
321 //                    Extended Regular Expression syntax on UNIX-like
322 //                    platforms, or a reduced regular exception syntax on
323 //                    other platforms, including Windows.
324 //
325 // Logging:
326 //   GTEST_LOG_()   - logs messages at the specified severity level.
327 //   LogToStderr()  - directs all log messages to stderr.
328 //   FlushInfoLog() - flushes informational log messages.
329 //
330 // Stdout and stderr capturing:
331 //   CaptureStdout()     - starts capturing stdout.
332 //   GetCapturedStdout() - stops capturing stdout and returns the captured
333 //                         string.
334 //   CaptureStderr()     - starts capturing stderr.
335 //   GetCapturedStderr() - stops capturing stderr and returns the captured
336 //                         string.
337 //
338 // Integer types:
339 //   TypeWithSize   - maps an integer to a int type.
340 //   Int32, UInt32, Int64, UInt64, TimeInMillis
341 //                  - integers of known sizes.
342 //   BiggestInt     - the biggest signed integer type.
343 //
344 // Command-line utilities:
345 //   GTEST_DECLARE_*()  - declares a flag.
346 //   GTEST_DEFINE_*()   - defines a flag.
347 //   GetInjectableArgvs() - returns the command line as a vector of strings.
348 //
349 // Environment variable utilities:
350 //   GetEnv()             - gets the value of an environment variable.
351 //   BoolFromGTestEnv()   - parses a bool environment variable.
352 //   Int32FromGTestEnv()  - parses an Int32 environment variable.
353 //   StringFromGTestEnv() - parses a string environment variable.
354 
355 #include <ctype.h>   // for isspace, etc
356 #include <stddef.h>  // for ptrdiff_t
357 #include <stdlib.h>
358 #include <stdio.h>
359 #include <string.h>
360 #ifndef _WIN32_WCE
361 # include <sys/types.h>
362 # include <sys/stat.h>
363 #endif  // !_WIN32_WCE
364 
365 #if defined __APPLE__
366 # include <AvailabilityMacros.h>
367 # include <TargetConditionals.h>
368 #endif
369 
370 #include <algorithm>  // NOLINT
371 #include <iostream>  // NOLINT
372 #include <sstream>  // NOLINT
373 #include <string>  // NOLINT
374 #include <utility>
375 #include <vector>  // NOLINT
376 
377 // Copyright 2015, Google Inc.
378 // All rights reserved.
379 //
380 // Redistribution and use in source and binary forms, with or without
381 // modification, are permitted provided that the following conditions are
382 // met:
383 //
384 //     * Redistributions of source code must retain the above copyright
385 // notice, this list of conditions and the following disclaimer.
386 //     * Redistributions in binary form must reproduce the above
387 // copyright notice, this list of conditions and the following disclaimer
388 // in the documentation and/or other materials provided with the
389 // distribution.
390 //     * Neither the name of Google Inc. nor the names of its
391 // contributors may be used to endorse or promote products derived from
392 // this software without specific prior written permission.
393 //
394 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
395 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
396 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
397 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
398 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
399 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
400 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
401 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
402 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
403 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
404 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
405 //
406 // The Google C++ Testing Framework (Google Test)
407 //
408 // This header file defines the GTEST_OS_* macro.
409 // It is separate from gtest-port.h so that custom/gtest-port.h can include it.
410 
411 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
412 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
413 
414 // Determines the platform on which Google Test is compiled.
415 #ifdef __CYGWIN__
416 # define GTEST_OS_CYGWIN 1
417 #elif defined __SYMBIAN32__
418 # define GTEST_OS_SYMBIAN 1
419 #elif defined _WIN32
420 # define GTEST_OS_WINDOWS 1
421 # ifdef _WIN32_WCE
422 #  define GTEST_OS_WINDOWS_MOBILE 1
423 # elif defined(__MINGW__) || defined(__MINGW32__)
424 #  define GTEST_OS_WINDOWS_MINGW 1
425 # elif defined(WINAPI_FAMILY)
426 #  include <winapifamily.h>
427 #  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
428 #   define GTEST_OS_WINDOWS_DESKTOP 1
429 #  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
430 #   define GTEST_OS_WINDOWS_PHONE 1
431 #  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
432 #   define GTEST_OS_WINDOWS_RT 1
433 #  else
434     // WINAPI_FAMILY defined but no known partition matched.
435     // Default to desktop.
436 #   define GTEST_OS_WINDOWS_DESKTOP 1
437 #  endif
438 # else
439 #  define GTEST_OS_WINDOWS_DESKTOP 1
440 # endif  // _WIN32_WCE
441 #elif defined __APPLE__
442 # define GTEST_OS_MAC 1
443 # if TARGET_OS_IPHONE
444 #  define GTEST_OS_IOS 1
445 # endif
446 #elif defined __FreeBSD__
447 # define GTEST_OS_FREEBSD 1
448 #elif defined __linux__
449 # define GTEST_OS_LINUX 1
450 # if defined __ANDROID__
451 #  define GTEST_OS_LINUX_ANDROID 1
452 # endif
453 #elif defined __MVS__
454 # define GTEST_OS_ZOS 1
455 #elif defined(__sun) && defined(__SVR4)
456 # define GTEST_OS_SOLARIS 1
457 #elif defined(_AIX)
458 # define GTEST_OS_AIX 1
459 #elif defined(__hpux)
460 # define GTEST_OS_HPUX 1
461 #elif defined __native_client__
462 # define GTEST_OS_NACL 1
463 #elif defined __OpenBSD__
464 # define GTEST_OS_OPENBSD 1
465 #elif defined __QNX__
466 # define GTEST_OS_QNX 1
467 #endif  // __CYGWIN__
468 
469 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
470 // Copyright 2015, Google Inc.
471 // All rights reserved.
472 //
473 // Redistribution and use in source and binary forms, with or without
474 // modification, are permitted provided that the following conditions are
475 // met:
476 //
477 //     * Redistributions of source code must retain the above copyright
478 // notice, this list of conditions and the following disclaimer.
479 //     * Redistributions in binary form must reproduce the above
480 // copyright notice, this list of conditions and the following disclaimer
481 // in the documentation and/or other materials provided with the
482 // distribution.
483 //     * Neither the name of Google Inc. nor the names of its
484 // contributors may be used to endorse or promote products derived from
485 // this software without specific prior written permission.
486 //
487 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
488 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
489 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
490 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
491 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
492 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
493 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
494 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
495 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
496 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
497 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
498 //
499 // Injection point for custom user configurations.
500 // The following macros can be defined:
501 //
502 //   Flag related macros:
503 //     GTEST_FLAG(flag_name)
504 //     GTEST_USE_OWN_FLAGFILE_FLAG_  - Define to 0 when the system provides its
505 //                                     own flagfile flag parsing.
506 //     GTEST_DECLARE_bool_(name)
507 //     GTEST_DECLARE_int32_(name)
508 //     GTEST_DECLARE_string_(name)
509 //     GTEST_DEFINE_bool_(name, default_val, doc)
510 //     GTEST_DEFINE_int32_(name, default_val, doc)
511 //     GTEST_DEFINE_string_(name, default_val, doc)
512 //
513 //   Test filtering:
514 //     GTEST_TEST_FILTER_ENV_VAR_ - The name of an environment variable that
515 //                                  will be used if --GTEST_FLAG(test_filter)
516 //                                  is not provided.
517 //
518 //   Logging:
519 //     GTEST_LOG_(severity)
520 //     GTEST_CHECK_(condition)
521 //     Functions LogToStderr() and FlushInfoLog() have to be provided too.
522 //
523 //   Threading:
524 //     GTEST_HAS_NOTIFICATION_ - Enabled if Notification is already provided.
525 //     GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Enabled if Mutex and ThreadLocal are
526 //                                         already provided.
527 //     Must also provide GTEST_DECLARE_STATIC_MUTEX_(mutex) and
528 //     GTEST_DEFINE_STATIC_MUTEX_(mutex)
529 //
530 //     GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
531 //     GTEST_LOCK_EXCLUDED_(locks)
532 //
533 // ** Custom implementation starts here **
534 
535 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
536 #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
537 
538 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
539 
540 #if !defined(GTEST_DEV_EMAIL_)
541 # define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
542 # define GTEST_FLAG_PREFIX_ "gtest_"
543 # define GTEST_FLAG_PREFIX_DASH_ "gtest-"
544 # define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
545 # define GTEST_NAME_ "Google Test"
546 # define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
547 #endif  // !defined(GTEST_DEV_EMAIL_)
548 
549 #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
550 # define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
551 #endif  // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
552 
553 // Determines the version of gcc that is used to compile this.
554 #ifdef __GNUC__
555 // 40302 means version 4.3.2.
556 # define GTEST_GCC_VER_ \
557     (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
558 #endif  // __GNUC__
559 
560 // Macros for disabling Microsoft Visual C++ warnings.
561 //
562 //   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
563 //   /* code that triggers warnings C4800 and C4385 */
564 //   GTEST_DISABLE_MSC_WARNINGS_POP_()
565 #if _MSC_VER >= 1500
566 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
567     __pragma(warning(push))                        \
568     __pragma(warning(disable: warnings))
569 # define GTEST_DISABLE_MSC_WARNINGS_POP_()          \
570     __pragma(warning(pop))
571 #else
572 // Older versions of MSVC don't have __pragma.
573 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
574 # define GTEST_DISABLE_MSC_WARNINGS_POP_()
575 #endif
576 
577 #ifndef GTEST_LANG_CXX11
578 // gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when
579 // -std={c,gnu}++{0x,11} is passed.  The C++11 standard specifies a
580 // value for __cplusplus, and recent versions of clang, gcc, and
581 // probably other compilers set that too in C++11 mode.
582 # if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
583 // Compiling in at least C++11 mode.
584 #  define GTEST_LANG_CXX11 1
585 # else
586 #  define GTEST_LANG_CXX11 0
587 # endif
588 #endif
589 
590 // Distinct from C++11 language support, some environments don't provide
591 // proper C++11 library support. Notably, it's possible to build in
592 // C++11 mode when targeting Mac OS X 10.6, which has an old libstdc++
593 // with no C++11 support.
594 //
595 // libstdc++ has sufficient C++11 support as of GCC 4.6.0, __GLIBCXX__
596 // 20110325, but maintenance releases in the 4.4 and 4.5 series followed
597 // this date, so check for those versions by their date stamps.
598 // https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning
599 #if GTEST_LANG_CXX11 && \
600     (!defined(__GLIBCXX__) || ( \
601         __GLIBCXX__ >= 20110325ul &&  /* GCC >= 4.6.0 */ \
602         /* Blacklist of patch releases of older branches: */ \
603         __GLIBCXX__ != 20110416ul &&  /* GCC 4.4.6 */ \
604         __GLIBCXX__ != 20120313ul &&  /* GCC 4.4.7 */ \
605         __GLIBCXX__ != 20110428ul &&  /* GCC 4.5.3 */ \
606         __GLIBCXX__ != 20120702ul))   /* GCC 4.5.4 */
607 # define GTEST_STDLIB_CXX11 1
608 #endif
609 
610 // Only use C++11 library features if the library provides them.
611 #if GTEST_STDLIB_CXX11
612 # define GTEST_HAS_STD_BEGIN_AND_END_ 1
613 # define GTEST_HAS_STD_FORWARD_LIST_ 1
614 # define GTEST_HAS_STD_FUNCTION_ 1
615 # define GTEST_HAS_STD_INITIALIZER_LIST_ 1
616 # define GTEST_HAS_STD_MOVE_ 1
617 # define GTEST_HAS_STD_SHARED_PTR_ 1
618 # define GTEST_HAS_STD_TYPE_TRAITS_ 1
619 # define GTEST_HAS_STD_UNIQUE_PTR_ 1
620 #endif
621 
622 // C++11 specifies that <tuple> provides std::tuple.
623 // Some platforms still might not have it, however.
624 #if GTEST_LANG_CXX11
625 # define GTEST_HAS_STD_TUPLE_ 1
626 # if defined(__clang__)
627 // Inspired by http://clang.llvm.org/docs/LanguageExtensions.html#__has_include
628 #  if defined(__has_include) && !__has_include(<tuple>)
629 #   undef GTEST_HAS_STD_TUPLE_
630 #  endif
631 # elif defined(_MSC_VER)
632 // Inspired by boost/config/stdlib/dinkumware.hpp
633 #  if defined(_CPPLIB_VER) && _CPPLIB_VER < 520
634 #   undef GTEST_HAS_STD_TUPLE_
635 #  endif
636 # elif defined(__GLIBCXX__)
637 // Inspired by boost/config/stdlib/libstdcpp3.hpp,
638 // http://gcc.gnu.org/gcc-4.2/changes.html and
639 // http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x
640 #  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
641 #   undef GTEST_HAS_STD_TUPLE_
642 #  endif
643 # endif
644 #endif
645 
646 // Brings in definitions for functions used in the testing::internal::posix
647 // namespace (read, write, close, chdir, isatty, stat). We do not currently
648 // use them on Windows Mobile.
649 #if GTEST_OS_WINDOWS
650 # if !GTEST_OS_WINDOWS_MOBILE
651 #  include <direct.h>
652 #  include <io.h>
653 # endif
654 // In order to avoid having to include <windows.h>, use forward declaration
655 // assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
656 // This assumption is verified by
657 // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
658 struct _RTL_CRITICAL_SECTION;
659 #else
660 // This assumes that non-Windows OSes provide unistd.h. For OSes where this
661 // is not the case, we need to include headers that provide the functions
662 // mentioned above.
663 # include <unistd.h>
664 # include <strings.h>
665 #endif  // GTEST_OS_WINDOWS
666 
667 #if GTEST_OS_LINUX_ANDROID
668 // Used to define __ANDROID_API__ matching the target NDK API level.
669 #  include <android/api-level.h>  // NOLINT
670 #endif
671 
672 // Defines this to true iff Google Test can use POSIX regular expressions.
673 #ifndef GTEST_HAS_POSIX_RE
674 # if GTEST_OS_LINUX_ANDROID
675 // On Android, <regex.h> is only available starting with Gingerbread.
676 #  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
677 # else
678 #  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
679 # endif
680 #endif
681 
682 #if GTEST_USES_PCRE
683 // The appropriate headers have already been included.
684 
685 #elif GTEST_HAS_POSIX_RE
686 
687 // On some platforms, <regex.h> needs someone to define size_t, and
688 // won't compile otherwise.  We can #include it here as we already
689 // included <stdlib.h>, which is guaranteed to define size_t through
690 // <stddef.h>.
691 # include <regex.h>  // NOLINT
692 
693 # define GTEST_USES_POSIX_RE 1
694 
695 #elif GTEST_OS_WINDOWS
696 
697 // <regex.h> is not available on Windows.  Use our own simple regex
698 // implementation instead.
699 # define GTEST_USES_SIMPLE_RE 1
700 
701 #else
702 
703 // <regex.h> may not be available on this platform.  Use our own
704 // simple regex implementation instead.
705 # define GTEST_USES_SIMPLE_RE 1
706 
707 #endif  // GTEST_USES_PCRE
708 
709 #ifndef GTEST_HAS_EXCEPTIONS
710 // The user didn't tell us whether exceptions are enabled, so we need
711 // to figure it out.
712 # if defined(_MSC_VER) || defined(__BORLANDC__)
713 // MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
714 // macro to enable exceptions, so we'll do the same.
715 // Assumes that exceptions are enabled by default.
716 #  ifndef _HAS_EXCEPTIONS
717 #   define _HAS_EXCEPTIONS 1
718 #  endif  // _HAS_EXCEPTIONS
719 #  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
720 # elif defined(__clang__)
721 // clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,
722 // but iff cleanups are enabled after that. In Obj-C++ files, there can be
723 // cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
724 // are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
725 // exceptions starting at clang r206352, but which checked for cleanups prior to
726 // that. To reliably check for C++ exception availability with clang, check for
727 // __EXCEPTIONS && __has_feature(cxx_exceptions).
728 #  define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
729 # elif defined(__GNUC__) && __EXCEPTIONS
730 // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
731 #  define GTEST_HAS_EXCEPTIONS 1
732 # elif defined(__SUNPRO_CC)
733 // Sun Pro CC supports exceptions.  However, there is no compile-time way of
734 // detecting whether they are enabled or not.  Therefore, we assume that
735 // they are enabled unless the user tells us otherwise.
736 #  define GTEST_HAS_EXCEPTIONS 1
737 # elif defined(__IBMCPP__) && __EXCEPTIONS
738 // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
739 #  define GTEST_HAS_EXCEPTIONS 1
740 # elif defined(__HP_aCC)
741 // Exception handling is in effect by default in HP aCC compiler. It has to
742 // be turned of by +noeh compiler option if desired.
743 #  define GTEST_HAS_EXCEPTIONS 1
744 # else
745 // For other compilers, we assume exceptions are disabled to be
746 // conservative.
747 #  define GTEST_HAS_EXCEPTIONS 0
748 # endif  // defined(_MSC_VER) || defined(__BORLANDC__)
749 #endif  // GTEST_HAS_EXCEPTIONS
750 
751 #if !defined(GTEST_HAS_STD_STRING)
752 // Even though we don't use this macro any longer, we keep it in case
753 // some clients still depend on it.
754 # define GTEST_HAS_STD_STRING 1
755 #elif !GTEST_HAS_STD_STRING
756 // The user told us that ::std::string isn't available.
757 # error "Google Test cannot be used where ::std::string isn't available."
758 #endif  // !defined(GTEST_HAS_STD_STRING)
759 
760 #ifndef GTEST_HAS_GLOBAL_STRING
761 // The user didn't tell us whether ::string is available, so we need
762 // to figure it out.
763 
764 # define GTEST_HAS_GLOBAL_STRING 0
765 
766 #endif  // GTEST_HAS_GLOBAL_STRING
767 
768 #ifndef GTEST_HAS_STD_WSTRING
769 // The user didn't tell us whether ::std::wstring is available, so we need
770 // to figure it out.
771 // TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
772 //   is available.
773 
774 // Cygwin 1.7 and below doesn't support ::std::wstring.
775 // Solaris' libc++ doesn't support it either.  Android has
776 // no support for it at least as recent as Froyo (2.2).
777 # define GTEST_HAS_STD_WSTRING \
778     (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
779 
780 #endif  // GTEST_HAS_STD_WSTRING
781 
782 #ifndef GTEST_HAS_GLOBAL_WSTRING
783 // The user didn't tell us whether ::wstring is available, so we need
784 // to figure it out.
785 # define GTEST_HAS_GLOBAL_WSTRING \
786     (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
787 #endif  // GTEST_HAS_GLOBAL_WSTRING
788 
789 // Determines whether RTTI is available.
790 #ifndef GTEST_HAS_RTTI
791 // The user didn't tell us whether RTTI is enabled, so we need to
792 // figure it out.
793 
794 # ifdef _MSC_VER
795 
796 #  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
797 #   define GTEST_HAS_RTTI 1
798 #  else
799 #   define GTEST_HAS_RTTI 0
800 #  endif
801 
802 // Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
803 # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
804 
805 #  ifdef __GXX_RTTI
806 // When building against STLport with the Android NDK and with
807 // -frtti -fno-exceptions, the build fails at link time with undefined
808 // references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
809 // so disable RTTI when detected.
810 #   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
811        !defined(__EXCEPTIONS)
812 #    define GTEST_HAS_RTTI 0
813 #   else
814 #    define GTEST_HAS_RTTI 1
815 #   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
816 #  else
817 #   define GTEST_HAS_RTTI 0
818 #  endif  // __GXX_RTTI
819 
820 // Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
821 // using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
822 // first version with C++ support.
823 # elif defined(__clang__)
824 
825 #  define GTEST_HAS_RTTI __has_feature(cxx_rtti)
826 
827 // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
828 // both the typeid and dynamic_cast features are present.
829 # elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
830 
831 #  ifdef __RTTI_ALL__
832 #   define GTEST_HAS_RTTI 1
833 #  else
834 #   define GTEST_HAS_RTTI 0
835 #  endif
836 
837 # else
838 
839 // For all other compilers, we assume RTTI is enabled.
840 #  define GTEST_HAS_RTTI 1
841 
842 # endif  // _MSC_VER
843 
844 #endif  // GTEST_HAS_RTTI
845 
846 // It's this header's responsibility to #include <typeinfo> when RTTI
847 // is enabled.
848 #if GTEST_HAS_RTTI
849 # include <typeinfo>
850 #endif
851 
852 // Determines whether Google Test can use the pthreads library.
853 #ifndef GTEST_HAS_PTHREAD
854 // The user didn't tell us explicitly, so we make reasonable assumptions about
855 // which platforms have pthreads support.
856 //
857 // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
858 // to your compiler flags.
859 # define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
860     || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NACL)
861 #endif  // GTEST_HAS_PTHREAD
862 
863 #if GTEST_HAS_PTHREAD
864 // gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
865 // true.
866 # include <pthread.h>  // NOLINT
867 
868 // For timespec and nanosleep, used below.
869 # include <time.h>  // NOLINT
870 #endif
871 
872 // Determines if hash_map/hash_set are available.
873 // Only used for testing against those containers.
874 #if !defined(GTEST_HAS_HASH_MAP_)
875 # if _MSC_VER
876 #  define GTEST_HAS_HASH_MAP_ 1  // Indicates that hash_map is available.
877 #  define GTEST_HAS_HASH_SET_ 1  // Indicates that hash_set is available.
878 # endif  // _MSC_VER
879 #endif  // !defined(GTEST_HAS_HASH_MAP_)
880 
881 // Determines whether Google Test can use tr1/tuple.  You can define
882 // this macro to 0 to prevent Google Test from using tuple (any
883 // feature depending on tuple with be disabled in this mode).
884 #ifndef GTEST_HAS_TR1_TUPLE
885 # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
886 // STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.
887 #  define GTEST_HAS_TR1_TUPLE 0
888 # else
889 // The user didn't tell us not to do it, so we assume it's OK.
890 #  define GTEST_HAS_TR1_TUPLE 1
891 # endif
892 #endif  // GTEST_HAS_TR1_TUPLE
893 
894 // Determines whether Google Test's own tr1 tuple implementation
895 // should be used.
896 #ifndef GTEST_USE_OWN_TR1_TUPLE
897 // The user didn't tell us, so we need to figure it out.
898 
899 // We use our own TR1 tuple if we aren't sure the user has an
900 // implementation of it already.  At this time, libstdc++ 4.0.0+ and
901 // MSVC 2010 are the only mainstream standard libraries that come
902 // with a TR1 tuple implementation.  NVIDIA's CUDA NVCC compiler
903 // pretends to be GCC by defining __GNUC__ and friends, but cannot
904 // compile GCC's tuple implementation.  MSVC 2008 (9.0) provides TR1
905 // tuple in a 323 MB Feature Pack download, which we cannot assume the
906 // user has.  QNX's QCC compiler is a modified GCC but it doesn't
907 // support TR1 tuple.  libc++ only provides std::tuple, in C++11 mode,
908 // and it can be used with some compilers that define __GNUC__.
909 # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
910       && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
911 #  define GTEST_ENV_HAS_TR1_TUPLE_ 1
912 # endif
913 
914 // C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used
915 // in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6
916 // can build with clang but need to use gcc4.2's libstdc++).
917 # if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
918 #  define GTEST_ENV_HAS_STD_TUPLE_ 1
919 # endif
920 
921 # if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
922 #  define GTEST_USE_OWN_TR1_TUPLE 0
923 # else
924 #  define GTEST_USE_OWN_TR1_TUPLE 1
925 # endif
926 
927 #endif  // GTEST_USE_OWN_TR1_TUPLE
928 
929 // To avoid conditional compilation everywhere, we make it
930 // gtest-port.h's responsibility to #include the header implementing
931 // tuple.
932 #if GTEST_HAS_STD_TUPLE_
933 # include <tuple>  // IWYU pragma: export
934 # define GTEST_TUPLE_NAMESPACE_ ::std
935 #endif  // GTEST_HAS_STD_TUPLE_
936 
937 // We include tr1::tuple even if std::tuple is available to define printers for
938 // them.
939 #if GTEST_HAS_TR1_TUPLE
940 # ifndef GTEST_TUPLE_NAMESPACE_
941 #  define GTEST_TUPLE_NAMESPACE_ ::std::tr1
942 # endif  // GTEST_TUPLE_NAMESPACE_
943 
944 # if GTEST_USE_OWN_TR1_TUPLE
945 // This file was GENERATED by command:
946 //     pump.py gtest-tuple.h.pump
947 // DO NOT EDIT BY HAND!!!
948 
949 // Copyright 2009 Google Inc.
950 // All Rights Reserved.
951 //
952 // Redistribution and use in source and binary forms, with or without
953 // modification, are permitted provided that the following conditions are
954 // met:
955 //
956 //     * Redistributions of source code must retain the above copyright
957 // notice, this list of conditions and the following disclaimer.
958 //     * Redistributions in binary form must reproduce the above
959 // copyright notice, this list of conditions and the following disclaimer
960 // in the documentation and/or other materials provided with the
961 // distribution.
962 //     * Neither the name of Google Inc. nor the names of its
963 // contributors may be used to endorse or promote products derived from
964 // this software without specific prior written permission.
965 //
966 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
967 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
968 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
969 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
970 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
971 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
972 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
973 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
974 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
975 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
976 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
977 //
978 // Author: wan@google.com (Zhanyong Wan)
979 
980 // Implements a subset of TR1 tuple needed by Google Test and Google Mock.
981 
982 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
983 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
984 
985 #include <utility>  // For ::std::pair.
986 
987 // The compiler used in Symbian has a bug that prevents us from declaring the
988 // tuple template as a friend (it complains that tuple is redefined).  This
989 // hack bypasses the bug by declaring the members that should otherwise be
990 // private as public.
991 // Sun Studio versions < 12 also have the above bug.
992 #if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
993 # define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
994 #else
995 # define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
996     template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
997    private:
998 #endif
999 
1000 // Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict
1001 // with our own definitions. Therefore using our own tuple does not work on
1002 // those compilers.
1003 #if defined(_MSC_VER) && _MSC_VER >= 1600  /* 1600 is Visual Studio 2010 */
1004 # error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
1005 GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
1006 #endif
1007 
1008 // GTEST_n_TUPLE_(T) is the type of an n-tuple.
1009 #define GTEST_0_TUPLE_(T) tuple<>
1010 #define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
1011     void, void, void>
1012 #define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
1013     void, void, void>
1014 #define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
1015     void, void, void>
1016 #define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
1017     void, void, void>
1018 #define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
1019     void, void, void>
1020 #define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
1021     void, void, void>
1022 #define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
1023     void, void, void>
1024 #define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
1025     T##7, void, void>
1026 #define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
1027     T##7, T##8, void>
1028 #define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
1029     T##7, T##8, T##9>
1030 
1031 // GTEST_n_TYPENAMES_(T) declares a list of n typenames.
1032 #define GTEST_0_TYPENAMES_(T)
1033 #define GTEST_1_TYPENAMES_(T) typename T##0
1034 #define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
1035 #define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
1036 #define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1037     typename T##3
1038 #define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1039     typename T##3, typename T##4
1040 #define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1041     typename T##3, typename T##4, typename T##5
1042 #define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1043     typename T##3, typename T##4, typename T##5, typename T##6
1044 #define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1045     typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
1046 #define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1047     typename T##3, typename T##4, typename T##5, typename T##6, \
1048     typename T##7, typename T##8
1049 #define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
1050     typename T##3, typename T##4, typename T##5, typename T##6, \
1051     typename T##7, typename T##8, typename T##9
1052 
1053 // In theory, defining stuff in the ::std namespace is undefined
1054 // behavior.  We can do this as we are playing the role of a standard
1055 // library vendor.
1056 namespace std {
1057 namespace tr1 {
1058 
1059 template <typename T0 = void, typename T1 = void, typename T2 = void,
1060     typename T3 = void, typename T4 = void, typename T5 = void,
1061     typename T6 = void, typename T7 = void, typename T8 = void,
1062     typename T9 = void>
1063 class tuple;
1064 
1065 // Anything in namespace gtest_internal is Google Test's INTERNAL
1066 // IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
1067 namespace gtest_internal {
1068 
1069 // ByRef<T>::type is T if T is a reference; otherwise it's const T&.
1070 template <typename T>
1071 struct ByRef { typedef const T& type; };  // NOLINT
1072 template <typename T>
1073 struct ByRef<T&> { typedef T& type; };  // NOLINT
1074 
1075 // A handy wrapper for ByRef.
1076 #define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
1077 
1078 // AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
1079 // is the same as tr1::add_reference<T>::type.
1080 template <typename T>
1081 struct AddRef { typedef T& type; };  // NOLINT
1082 template <typename T>
1083 struct AddRef<T&> { typedef T& type; };  // NOLINT
1084 
1085 // A handy wrapper for AddRef.
1086 #define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
1087 
1088 // A helper for implementing get<k>().
1089 template <int k> class Get;
1090 
1091 // A helper for implementing tuple_element<k, T>.  kIndexValid is true
1092 // iff k < the number of fields in tuple type T.
1093 template <bool kIndexValid, int kIndex, class Tuple>
1094 struct TupleElement;
1095 
1096 template <GTEST_10_TYPENAMES_(T)>
1097 struct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {
1098   typedef T0 type;
1099 };
1100 
1101 template <GTEST_10_TYPENAMES_(T)>
1102 struct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {
1103   typedef T1 type;
1104 };
1105 
1106 template <GTEST_10_TYPENAMES_(T)>
1107 struct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {
1108   typedef T2 type;
1109 };
1110 
1111 template <GTEST_10_TYPENAMES_(T)>
1112 struct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {
1113   typedef T3 type;
1114 };
1115 
1116 template <GTEST_10_TYPENAMES_(T)>
1117 struct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {
1118   typedef T4 type;
1119 };
1120 
1121 template <GTEST_10_TYPENAMES_(T)>
1122 struct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {
1123   typedef T5 type;
1124 };
1125 
1126 template <GTEST_10_TYPENAMES_(T)>
1127 struct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {
1128   typedef T6 type;
1129 };
1130 
1131 template <GTEST_10_TYPENAMES_(T)>
1132 struct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {
1133   typedef T7 type;
1134 };
1135 
1136 template <GTEST_10_TYPENAMES_(T)>
1137 struct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {
1138   typedef T8 type;
1139 };
1140 
1141 template <GTEST_10_TYPENAMES_(T)>
1142 struct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {
1143   typedef T9 type;
1144 };
1145 
1146 }  // namespace gtest_internal
1147 
1148 template <>
1149 class tuple<> {
1150  public:
1151   tuple() {}
1152   tuple(const tuple& /* t */)  {}
1153   tuple& operator=(const tuple& /* t */) { return *this; }
1154 };
1155 
1156 template <GTEST_1_TYPENAMES_(T)>
1157 class GTEST_1_TUPLE_(T) {
1158  public:
1159   template <int k> friend class gtest_internal::Get;
1160 
1161   tuple() : f0_() {}
1162 
1163   explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
1164 
1165   tuple(const tuple& t) : f0_(t.f0_) {}
1166 
1167   template <GTEST_1_TYPENAMES_(U)>
1168   tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
1169 
1170   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1171 
1172   template <GTEST_1_TYPENAMES_(U)>
1173   tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
1174     return CopyFrom(t);
1175   }
1176 
1177   GTEST_DECLARE_TUPLE_AS_FRIEND_
1178 
1179   template <GTEST_1_TYPENAMES_(U)>
1180   tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
1181     f0_ = t.f0_;
1182     return *this;
1183   }
1184 
1185   T0 f0_;
1186 };
1187 
1188 template <GTEST_2_TYPENAMES_(T)>
1189 class GTEST_2_TUPLE_(T) {
1190  public:
1191   template <int k> friend class gtest_internal::Get;
1192 
1193   tuple() : f0_(), f1_() {}
1194 
1195   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
1196       f1_(f1) {}
1197 
1198   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
1199 
1200   template <GTEST_2_TYPENAMES_(U)>
1201   tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
1202   template <typename U0, typename U1>
1203   tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
1204 
1205   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1206 
1207   template <GTEST_2_TYPENAMES_(U)>
1208   tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
1209     return CopyFrom(t);
1210   }
1211   template <typename U0, typename U1>
1212   tuple& operator=(const ::std::pair<U0, U1>& p) {
1213     f0_ = p.first;
1214     f1_ = p.second;
1215     return *this;
1216   }
1217 
1218   GTEST_DECLARE_TUPLE_AS_FRIEND_
1219 
1220   template <GTEST_2_TYPENAMES_(U)>
1221   tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
1222     f0_ = t.f0_;
1223     f1_ = t.f1_;
1224     return *this;
1225   }
1226 
1227   T0 f0_;
1228   T1 f1_;
1229 };
1230 
1231 template <GTEST_3_TYPENAMES_(T)>
1232 class GTEST_3_TUPLE_(T) {
1233  public:
1234   template <int k> friend class gtest_internal::Get;
1235 
1236   tuple() : f0_(), f1_(), f2_() {}
1237 
1238   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1239       GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
1240 
1241   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
1242 
1243   template <GTEST_3_TYPENAMES_(U)>
1244   tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
1245 
1246   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1247 
1248   template <GTEST_3_TYPENAMES_(U)>
1249   tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
1250     return CopyFrom(t);
1251   }
1252 
1253   GTEST_DECLARE_TUPLE_AS_FRIEND_
1254 
1255   template <GTEST_3_TYPENAMES_(U)>
1256   tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
1257     f0_ = t.f0_;
1258     f1_ = t.f1_;
1259     f2_ = t.f2_;
1260     return *this;
1261   }
1262 
1263   T0 f0_;
1264   T1 f1_;
1265   T2 f2_;
1266 };
1267 
1268 template <GTEST_4_TYPENAMES_(T)>
1269 class GTEST_4_TUPLE_(T) {
1270  public:
1271   template <int k> friend class gtest_internal::Get;
1272 
1273   tuple() : f0_(), f1_(), f2_(), f3_() {}
1274 
1275   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1276       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
1277       f3_(f3) {}
1278 
1279   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
1280 
1281   template <GTEST_4_TYPENAMES_(U)>
1282   tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1283       f3_(t.f3_) {}
1284 
1285   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1286 
1287   template <GTEST_4_TYPENAMES_(U)>
1288   tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
1289     return CopyFrom(t);
1290   }
1291 
1292   GTEST_DECLARE_TUPLE_AS_FRIEND_
1293 
1294   template <GTEST_4_TYPENAMES_(U)>
1295   tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
1296     f0_ = t.f0_;
1297     f1_ = t.f1_;
1298     f2_ = t.f2_;
1299     f3_ = t.f3_;
1300     return *this;
1301   }
1302 
1303   T0 f0_;
1304   T1 f1_;
1305   T2 f2_;
1306   T3 f3_;
1307 };
1308 
1309 template <GTEST_5_TYPENAMES_(T)>
1310 class GTEST_5_TUPLE_(T) {
1311  public:
1312   template <int k> friend class gtest_internal::Get;
1313 
1314   tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
1315 
1316   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1317       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
1318       GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
1319 
1320   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1321       f4_(t.f4_) {}
1322 
1323   template <GTEST_5_TYPENAMES_(U)>
1324   tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1325       f3_(t.f3_), f4_(t.f4_) {}
1326 
1327   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1328 
1329   template <GTEST_5_TYPENAMES_(U)>
1330   tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
1331     return CopyFrom(t);
1332   }
1333 
1334   GTEST_DECLARE_TUPLE_AS_FRIEND_
1335 
1336   template <GTEST_5_TYPENAMES_(U)>
1337   tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
1338     f0_ = t.f0_;
1339     f1_ = t.f1_;
1340     f2_ = t.f2_;
1341     f3_ = t.f3_;
1342     f4_ = t.f4_;
1343     return *this;
1344   }
1345 
1346   T0 f0_;
1347   T1 f1_;
1348   T2 f2_;
1349   T3 f3_;
1350   T4 f4_;
1351 };
1352 
1353 template <GTEST_6_TYPENAMES_(T)>
1354 class GTEST_6_TUPLE_(T) {
1355  public:
1356   template <int k> friend class gtest_internal::Get;
1357 
1358   tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
1359 
1360   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1361       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1362       GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
1363       f5_(f5) {}
1364 
1365   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1366       f4_(t.f4_), f5_(t.f5_) {}
1367 
1368   template <GTEST_6_TYPENAMES_(U)>
1369   tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1370       f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
1371 
1372   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1373 
1374   template <GTEST_6_TYPENAMES_(U)>
1375   tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
1376     return CopyFrom(t);
1377   }
1378 
1379   GTEST_DECLARE_TUPLE_AS_FRIEND_
1380 
1381   template <GTEST_6_TYPENAMES_(U)>
1382   tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
1383     f0_ = t.f0_;
1384     f1_ = t.f1_;
1385     f2_ = t.f2_;
1386     f3_ = t.f3_;
1387     f4_ = t.f4_;
1388     f5_ = t.f5_;
1389     return *this;
1390   }
1391 
1392   T0 f0_;
1393   T1 f1_;
1394   T2 f2_;
1395   T3 f3_;
1396   T4 f4_;
1397   T5 f5_;
1398 };
1399 
1400 template <GTEST_7_TYPENAMES_(T)>
1401 class GTEST_7_TUPLE_(T) {
1402  public:
1403   template <int k> friend class gtest_internal::Get;
1404 
1405   tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
1406 
1407   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1408       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1409       GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
1410       f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
1411 
1412   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1413       f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
1414 
1415   template <GTEST_7_TYPENAMES_(U)>
1416   tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1417       f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
1418 
1419   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1420 
1421   template <GTEST_7_TYPENAMES_(U)>
1422   tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
1423     return CopyFrom(t);
1424   }
1425 
1426   GTEST_DECLARE_TUPLE_AS_FRIEND_
1427 
1428   template <GTEST_7_TYPENAMES_(U)>
1429   tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
1430     f0_ = t.f0_;
1431     f1_ = t.f1_;
1432     f2_ = t.f2_;
1433     f3_ = t.f3_;
1434     f4_ = t.f4_;
1435     f5_ = t.f5_;
1436     f6_ = t.f6_;
1437     return *this;
1438   }
1439 
1440   T0 f0_;
1441   T1 f1_;
1442   T2 f2_;
1443   T3 f3_;
1444   T4 f4_;
1445   T5 f5_;
1446   T6 f6_;
1447 };
1448 
1449 template <GTEST_8_TYPENAMES_(T)>
1450 class GTEST_8_TUPLE_(T) {
1451  public:
1452   template <int k> friend class gtest_internal::Get;
1453 
1454   tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
1455 
1456   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1457       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1458       GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
1459       GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
1460       f5_(f5), f6_(f6), f7_(f7) {}
1461 
1462   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1463       f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
1464 
1465   template <GTEST_8_TYPENAMES_(U)>
1466   tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1467       f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
1468 
1469   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1470 
1471   template <GTEST_8_TYPENAMES_(U)>
1472   tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
1473     return CopyFrom(t);
1474   }
1475 
1476   GTEST_DECLARE_TUPLE_AS_FRIEND_
1477 
1478   template <GTEST_8_TYPENAMES_(U)>
1479   tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
1480     f0_ = t.f0_;
1481     f1_ = t.f1_;
1482     f2_ = t.f2_;
1483     f3_ = t.f3_;
1484     f4_ = t.f4_;
1485     f5_ = t.f5_;
1486     f6_ = t.f6_;
1487     f7_ = t.f7_;
1488     return *this;
1489   }
1490 
1491   T0 f0_;
1492   T1 f1_;
1493   T2 f2_;
1494   T3 f3_;
1495   T4 f4_;
1496   T5 f5_;
1497   T6 f6_;
1498   T7 f7_;
1499 };
1500 
1501 template <GTEST_9_TYPENAMES_(T)>
1502 class GTEST_9_TUPLE_(T) {
1503  public:
1504   template <int k> friend class gtest_internal::Get;
1505 
1506   tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
1507 
1508   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1509       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1510       GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
1511       GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
1512       f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
1513 
1514   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1515       f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
1516 
1517   template <GTEST_9_TYPENAMES_(U)>
1518   tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1519       f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
1520 
1521   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1522 
1523   template <GTEST_9_TYPENAMES_(U)>
1524   tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
1525     return CopyFrom(t);
1526   }
1527 
1528   GTEST_DECLARE_TUPLE_AS_FRIEND_
1529 
1530   template <GTEST_9_TYPENAMES_(U)>
1531   tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
1532     f0_ = t.f0_;
1533     f1_ = t.f1_;
1534     f2_ = t.f2_;
1535     f3_ = t.f3_;
1536     f4_ = t.f4_;
1537     f5_ = t.f5_;
1538     f6_ = t.f6_;
1539     f7_ = t.f7_;
1540     f8_ = t.f8_;
1541     return *this;
1542   }
1543 
1544   T0 f0_;
1545   T1 f1_;
1546   T2 f2_;
1547   T3 f3_;
1548   T4 f4_;
1549   T5 f5_;
1550   T6 f6_;
1551   T7 f7_;
1552   T8 f8_;
1553 };
1554 
1555 template <GTEST_10_TYPENAMES_(T)>
1556 class tuple {
1557  public:
1558   template <int k> friend class gtest_internal::Get;
1559 
1560   tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
1561       f9_() {}
1562 
1563   explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1564       GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1565       GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
1566       GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
1567       f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
1568 
1569   tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1570       f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
1571 
1572   template <GTEST_10_TYPENAMES_(U)>
1573   tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1574       f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
1575       f9_(t.f9_) {}
1576 
1577   tuple& operator=(const tuple& t) { return CopyFrom(t); }
1578 
1579   template <GTEST_10_TYPENAMES_(U)>
1580   tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
1581     return CopyFrom(t);
1582   }
1583 
1584   GTEST_DECLARE_TUPLE_AS_FRIEND_
1585 
1586   template <GTEST_10_TYPENAMES_(U)>
1587   tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
1588     f0_ = t.f0_;
1589     f1_ = t.f1_;
1590     f2_ = t.f2_;
1591     f3_ = t.f3_;
1592     f4_ = t.f4_;
1593     f5_ = t.f5_;
1594     f6_ = t.f6_;
1595     f7_ = t.f7_;
1596     f8_ = t.f8_;
1597     f9_ = t.f9_;
1598     return *this;
1599   }
1600 
1601   T0 f0_;
1602   T1 f1_;
1603   T2 f2_;
1604   T3 f3_;
1605   T4 f4_;
1606   T5 f5_;
1607   T6 f6_;
1608   T7 f7_;
1609   T8 f8_;
1610   T9 f9_;
1611 };
1612 
1613 // 6.1.3.2 Tuple creation functions.
1614 
1615 // Known limitations: we don't support passing an
1616 // std::tr1::reference_wrapper<T> to make_tuple().  And we don't
1617 // implement tie().
1618 
1619 inline tuple<> make_tuple() { return tuple<>(); }
1620 
1621 template <GTEST_1_TYPENAMES_(T)>
1622 inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
1623   return GTEST_1_TUPLE_(T)(f0);
1624 }
1625 
1626 template <GTEST_2_TYPENAMES_(T)>
1627 inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
1628   return GTEST_2_TUPLE_(T)(f0, f1);
1629 }
1630 
1631 template <GTEST_3_TYPENAMES_(T)>
1632 inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
1633   return GTEST_3_TUPLE_(T)(f0, f1, f2);
1634 }
1635 
1636 template <GTEST_4_TYPENAMES_(T)>
1637 inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1638     const T3& f3) {
1639   return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
1640 }
1641 
1642 template <GTEST_5_TYPENAMES_(T)>
1643 inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1644     const T3& f3, const T4& f4) {
1645   return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
1646 }
1647 
1648 template <GTEST_6_TYPENAMES_(T)>
1649 inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1650     const T3& f3, const T4& f4, const T5& f5) {
1651   return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
1652 }
1653 
1654 template <GTEST_7_TYPENAMES_(T)>
1655 inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1656     const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
1657   return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
1658 }
1659 
1660 template <GTEST_8_TYPENAMES_(T)>
1661 inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1662     const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
1663   return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
1664 }
1665 
1666 template <GTEST_9_TYPENAMES_(T)>
1667 inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1668     const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
1669     const T8& f8) {
1670   return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
1671 }
1672 
1673 template <GTEST_10_TYPENAMES_(T)>
1674 inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1675     const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
1676     const T8& f8, const T9& f9) {
1677   return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
1678 }
1679 
1680 // 6.1.3.3 Tuple helper classes.
1681 
1682 template <typename Tuple> struct tuple_size;
1683 
1684 template <GTEST_0_TYPENAMES_(T)>
1685 struct tuple_size<GTEST_0_TUPLE_(T) > {
1686   static const int value = 0;
1687 };
1688 
1689 template <GTEST_1_TYPENAMES_(T)>
1690 struct tuple_size<GTEST_1_TUPLE_(T) > {
1691   static const int value = 1;
1692 };
1693 
1694 template <GTEST_2_TYPENAMES_(T)>
1695 struct tuple_size<GTEST_2_TUPLE_(T) > {
1696   static const int value = 2;
1697 };
1698 
1699 template <GTEST_3_TYPENAMES_(T)>
1700 struct tuple_size<GTEST_3_TUPLE_(T) > {
1701   static const int value = 3;
1702 };
1703 
1704 template <GTEST_4_TYPENAMES_(T)>
1705 struct tuple_size<GTEST_4_TUPLE_(T) > {
1706   static const int value = 4;
1707 };
1708 
1709 template <GTEST_5_TYPENAMES_(T)>
1710 struct tuple_size<GTEST_5_TUPLE_(T) > {
1711   static const int value = 5;
1712 };
1713 
1714 template <GTEST_6_TYPENAMES_(T)>
1715 struct tuple_size<GTEST_6_TUPLE_(T) > {
1716   static const int value = 6;
1717 };
1718 
1719 template <GTEST_7_TYPENAMES_(T)>
1720 struct tuple_size<GTEST_7_TUPLE_(T) > {
1721   static const int value = 7;
1722 };
1723 
1724 template <GTEST_8_TYPENAMES_(T)>
1725 struct tuple_size<GTEST_8_TUPLE_(T) > {
1726   static const int value = 8;
1727 };
1728 
1729 template <GTEST_9_TYPENAMES_(T)>
1730 struct tuple_size<GTEST_9_TUPLE_(T) > {
1731   static const int value = 9;
1732 };
1733 
1734 template <GTEST_10_TYPENAMES_(T)>
1735 struct tuple_size<GTEST_10_TUPLE_(T) > {
1736   static const int value = 10;
1737 };
1738 
1739 template <int k, class Tuple>
1740 struct tuple_element {
1741   typedef typename gtest_internal::TupleElement<
1742       k < (tuple_size<Tuple>::value), k, Tuple>::type type;
1743 };
1744 
1745 #define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
1746 
1747 // 6.1.3.4 Element access.
1748 
1749 namespace gtest_internal {
1750 
1751 template <>
1752 class Get<0> {
1753  public:
1754   template <class Tuple>
1755   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
1756   Field(Tuple& t) { return t.f0_; }  // NOLINT
1757 
1758   template <class Tuple>
1759   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
1760   ConstField(const Tuple& t) { return t.f0_; }
1761 };
1762 
1763 template <>
1764 class Get<1> {
1765  public:
1766   template <class Tuple>
1767   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
1768   Field(Tuple& t) { return t.f1_; }  // NOLINT
1769 
1770   template <class Tuple>
1771   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
1772   ConstField(const Tuple& t) { return t.f1_; }
1773 };
1774 
1775 template <>
1776 class Get<2> {
1777  public:
1778   template <class Tuple>
1779   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
1780   Field(Tuple& t) { return t.f2_; }  // NOLINT
1781 
1782   template <class Tuple>
1783   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
1784   ConstField(const Tuple& t) { return t.f2_; }
1785 };
1786 
1787 template <>
1788 class Get<3> {
1789  public:
1790   template <class Tuple>
1791   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
1792   Field(Tuple& t) { return t.f3_; }  // NOLINT
1793 
1794   template <class Tuple>
1795   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
1796   ConstField(const Tuple& t) { return t.f3_; }
1797 };
1798 
1799 template <>
1800 class Get<4> {
1801  public:
1802   template <class Tuple>
1803   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
1804   Field(Tuple& t) { return t.f4_; }  // NOLINT
1805 
1806   template <class Tuple>
1807   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
1808   ConstField(const Tuple& t) { return t.f4_; }
1809 };
1810 
1811 template <>
1812 class Get<5> {
1813  public:
1814   template <class Tuple>
1815   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
1816   Field(Tuple& t) { return t.f5_; }  // NOLINT
1817 
1818   template <class Tuple>
1819   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
1820   ConstField(const Tuple& t) { return t.f5_; }
1821 };
1822 
1823 template <>
1824 class Get<6> {
1825  public:
1826   template <class Tuple>
1827   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
1828   Field(Tuple& t) { return t.f6_; }  // NOLINT
1829 
1830   template <class Tuple>
1831   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
1832   ConstField(const Tuple& t) { return t.f6_; }
1833 };
1834 
1835 template <>
1836 class Get<7> {
1837  public:
1838   template <class Tuple>
1839   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
1840   Field(Tuple& t) { return t.f7_; }  // NOLINT
1841 
1842   template <class Tuple>
1843   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
1844   ConstField(const Tuple& t) { return t.f7_; }
1845 };
1846 
1847 template <>
1848 class Get<8> {
1849  public:
1850   template <class Tuple>
1851   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
1852   Field(Tuple& t) { return t.f8_; }  // NOLINT
1853 
1854   template <class Tuple>
1855   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
1856   ConstField(const Tuple& t) { return t.f8_; }
1857 };
1858 
1859 template <>
1860 class Get<9> {
1861  public:
1862   template <class Tuple>
1863   static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
1864   Field(Tuple& t) { return t.f9_; }  // NOLINT
1865 
1866   template <class Tuple>
1867   static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
1868   ConstField(const Tuple& t) { return t.f9_; }
1869 };
1870 
1871 }  // namespace gtest_internal
1872 
1873 template <int k, GTEST_10_TYPENAMES_(T)>
1874 GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
1875 get(GTEST_10_TUPLE_(T)& t) {
1876   return gtest_internal::Get<k>::Field(t);
1877 }
1878 
1879 template <int k, GTEST_10_TYPENAMES_(T)>
1880 GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))
1881 get(const GTEST_10_TUPLE_(T)& t) {
1882   return gtest_internal::Get<k>::ConstField(t);
1883 }
1884 
1885 // 6.1.3.5 Relational operators
1886 
1887 // We only implement == and !=, as we don't have a need for the rest yet.
1888 
1889 namespace gtest_internal {
1890 
1891 // SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
1892 // first k fields of t1 equals the first k fields of t2.
1893 // SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
1894 // k1 != k2.
1895 template <int kSize1, int kSize2>
1896 struct SameSizeTuplePrefixComparator;
1897 
1898 template <>
1899 struct SameSizeTuplePrefixComparator<0, 0> {
1900   template <class Tuple1, class Tuple2>
1901   static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
1902     return true;
1903   }
1904 };
1905 
1906 template <int k>
1907 struct SameSizeTuplePrefixComparator<k, k> {
1908   template <class Tuple1, class Tuple2>
1909   static bool Eq(const Tuple1& t1, const Tuple2& t2) {
1910     return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
1911         ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
1912   }
1913 };
1914 
1915 }  // namespace gtest_internal
1916 
1917 template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
1918 inline bool operator==(const GTEST_10_TUPLE_(T)& t,
1919                        const GTEST_10_TUPLE_(U)& u) {
1920   return gtest_internal::SameSizeTuplePrefixComparator<
1921       tuple_size<GTEST_10_TUPLE_(T) >::value,
1922       tuple_size<GTEST_10_TUPLE_(U) >::value>::Eq(t, u);
1923 }
1924 
1925 template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
1926 inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
1927                        const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
1928 
1929 // 6.1.4 Pairs.
1930 // Unimplemented.
1931 
1932 }  // namespace tr1
1933 }  // namespace std
1934 
1935 #undef GTEST_0_TUPLE_
1936 #undef GTEST_1_TUPLE_
1937 #undef GTEST_2_TUPLE_
1938 #undef GTEST_3_TUPLE_
1939 #undef GTEST_4_TUPLE_
1940 #undef GTEST_5_TUPLE_
1941 #undef GTEST_6_TUPLE_
1942 #undef GTEST_7_TUPLE_
1943 #undef GTEST_8_TUPLE_
1944 #undef GTEST_9_TUPLE_
1945 #undef GTEST_10_TUPLE_
1946 
1947 #undef GTEST_0_TYPENAMES_
1948 #undef GTEST_1_TYPENAMES_
1949 #undef GTEST_2_TYPENAMES_
1950 #undef GTEST_3_TYPENAMES_
1951 #undef GTEST_4_TYPENAMES_
1952 #undef GTEST_5_TYPENAMES_
1953 #undef GTEST_6_TYPENAMES_
1954 #undef GTEST_7_TYPENAMES_
1955 #undef GTEST_8_TYPENAMES_
1956 #undef GTEST_9_TYPENAMES_
1957 #undef GTEST_10_TYPENAMES_
1958 
1959 #undef GTEST_DECLARE_TUPLE_AS_FRIEND_
1960 #undef GTEST_BY_REF_
1961 #undef GTEST_ADD_REF_
1962 #undef GTEST_TUPLE_ELEMENT_
1963 
1964 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
1965 # elif GTEST_ENV_HAS_STD_TUPLE_
1966 #  include <tuple>
1967 // C++11 puts its tuple into the ::std namespace rather than
1968 // ::std::tr1.  gtest expects tuple to live in ::std::tr1, so put it there.
1969 // This causes undefined behavior, but supported compilers react in
1970 // the way we intend.
1971 namespace std {
1972 namespace tr1 {
1973 using ::std::get;
1974 using ::std::make_tuple;
1975 using ::std::tuple;
1976 using ::std::tuple_element;
1977 using ::std::tuple_size;
1978 }
1979 }
1980 
1981 # elif GTEST_OS_SYMBIAN
1982 
1983 // On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
1984 // use STLport's tuple implementation, which unfortunately doesn't
1985 // work as the copy of STLport distributed with Symbian is incomplete.
1986 // By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
1987 // use its own tuple implementation.
1988 #  ifdef BOOST_HAS_TR1_TUPLE
1989 #   undef BOOST_HAS_TR1_TUPLE
1990 #  endif  // BOOST_HAS_TR1_TUPLE
1991 
1992 // This prevents <boost/tr1/detail/config.hpp>, which defines
1993 // BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
1994 #  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
1995 #  include <tuple>  // IWYU pragma: export  // NOLINT
1996 
1997 # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
1998 // GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does
1999 // not conform to the TR1 spec, which requires the header to be <tuple>.
2000 
2001 #  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
2002 // Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
2003 // which is #included by <tr1/tuple>, to not compile when RTTI is
2004 // disabled.  _TR1_FUNCTIONAL is the header guard for
2005 // <tr1/functional>.  Hence the following #define is a hack to prevent
2006 // <tr1/functional> from being included.
2007 #   define _TR1_FUNCTIONAL 1
2008 #   include <tr1/tuple>
2009 #   undef _TR1_FUNCTIONAL  // Allows the user to #include
2010                         // <tr1/functional> if he chooses to.
2011 #  else
2012 #   include <tr1/tuple>  // NOLINT
2013 #  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
2014 
2015 # else
2016 // If the compiler is not GCC 4.0+, we assume the user is using a
2017 // spec-conforming TR1 implementation.
2018 #  include <tuple>  // IWYU pragma: export  // NOLINT
2019 # endif  // GTEST_USE_OWN_TR1_TUPLE
2020 
2021 #endif  // GTEST_HAS_TR1_TUPLE
2022 
2023 // Determines whether clone(2) is supported.
2024 // Usually it will only be available on Linux, excluding
2025 // Linux on the Itanium architecture.
2026 // Also see http://linux.die.net/man/2/clone.
2027 #ifndef GTEST_HAS_CLONE
2028 // The user didn't tell us, so we need to figure it out.
2029 
2030 # if GTEST_OS_LINUX && !defined(__ia64__)
2031 #  if GTEST_OS_LINUX_ANDROID
2032 // On Android, clone() is only available on ARM starting with Gingerbread.
2033 #    if defined(__arm__) && __ANDROID_API__ >= 9
2034 #     define GTEST_HAS_CLONE 1
2035 #    else
2036 #     define GTEST_HAS_CLONE 0
2037 #    endif
2038 #  else
2039 #   define GTEST_HAS_CLONE 1
2040 #  endif
2041 # else
2042 #  define GTEST_HAS_CLONE 0
2043 # endif  // GTEST_OS_LINUX && !defined(__ia64__)
2044 
2045 #endif  // GTEST_HAS_CLONE
2046 
2047 // Determines whether to support stream redirection. This is used to test
2048 // output correctness and to implement death tests.
2049 #ifndef GTEST_HAS_STREAM_REDIRECTION
2050 // By default, we assume that stream redirection is supported on all
2051 // platforms except known mobile ones.
2052 # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || \
2053     GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
2054 #  define GTEST_HAS_STREAM_REDIRECTION 0
2055 # else
2056 #  define GTEST_HAS_STREAM_REDIRECTION 1
2057 # endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
2058 #endif  // GTEST_HAS_STREAM_REDIRECTION
2059 
2060 // Determines whether to support death tests.
2061 // Google Test does not support death tests for VC 7.1 and earlier as
2062 // abort() in a VC 7.1 application compiled as GUI in debug config
2063 // pops up a dialog window that cannot be suppressed programmatically.
2064 #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
2065      (GTEST_OS_MAC && !GTEST_OS_IOS) || \
2066      (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
2067      GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
2068      GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
2069 # define GTEST_HAS_DEATH_TEST 1
2070 #endif
2071 
2072 // We don't support MSVC 7.1 with exceptions disabled now.  Therefore
2073 // all the compilers we care about are adequate for supporting
2074 // value-parameterized tests.
2075 #define GTEST_HAS_PARAM_TEST 1
2076 
2077 // Determines whether to support type-driven tests.
2078 
2079 // Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
2080 // Sun Pro CC, IBM Visual Age, and HP aCC support.
2081 #if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
2082     defined(__IBMCPP__) || defined(__HP_aCC)
2083 # define GTEST_HAS_TYPED_TEST 1
2084 # define GTEST_HAS_TYPED_TEST_P 1
2085 #endif
2086 
2087 // Determines whether to support Combine(). This only makes sense when
2088 // value-parameterized tests are enabled.  The implementation doesn't
2089 // work on Sun Studio since it doesn't understand templated conversion
2090 // operators.
2091 #if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
2092 # define GTEST_HAS_COMBINE 1
2093 #endif
2094 
2095 // Determines whether the system compiler uses UTF-16 for encoding wide strings.
2096 #define GTEST_WIDE_STRING_USES_UTF16_ \
2097     (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
2098 
2099 // Determines whether test results can be streamed to a socket.
2100 #if GTEST_OS_LINUX
2101 # define GTEST_CAN_STREAM_RESULTS_ 1
2102 #endif
2103 
2104 // Defines some utility macros.
2105 
2106 // The GNU compiler emits a warning if nested "if" statements are followed by
2107 // an "else" statement and braces are not used to explicitly disambiguate the
2108 // "else" binding.  This leads to problems with code like:
2109 //
2110 //   if (gate)
2111 //     ASSERT_*(condition) << "Some message";
2112 //
2113 // The "switch (0) case 0:" idiom is used to suppress this.
2114 #ifdef __INTEL_COMPILER
2115 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
2116 #else
2117 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
2118 #endif
2119 
2120 // Use this annotation at the end of a struct/class definition to
2121 // prevent the compiler from optimizing away instances that are never
2122 // used.  This is useful when all interesting logic happens inside the
2123 // c'tor and / or d'tor.  Example:
2124 //
2125 //   struct Foo {
2126 //     Foo() { ... }
2127 //   } GTEST_ATTRIBUTE_UNUSED_;
2128 //
2129 // Also use it after a variable or parameter declaration to tell the
2130 // compiler the variable/parameter does not have to be used.
2131 #if defined(__GNUC__) && !defined(COMPILER_ICC)
2132 # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
2133 #elif defined(__clang__)
2134 # if __has_attribute(unused)
2135 #  define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
2136 # endif
2137 #endif
2138 #ifndef GTEST_ATTRIBUTE_UNUSED_
2139 # define GTEST_ATTRIBUTE_UNUSED_
2140 #endif
2141 
2142 // A macro to disallow operator=
2143 // This should be used in the private: declarations for a class.
2144 #define GTEST_DISALLOW_ASSIGN_(type)\
2145   void operator=(type const &)
2146 
2147 // A macro to disallow copy constructor and operator=
2148 // This should be used in the private: declarations for a class.
2149 #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
2150   type(type const &);\
2151   GTEST_DISALLOW_ASSIGN_(type)
2152 
2153 // Tell the compiler to warn about unused return values for functions declared
2154 // with this macro.  The macro should be used on function declarations
2155 // following the argument list:
2156 //
2157 //   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
2158 #if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
2159 # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
2160 #else
2161 # define GTEST_MUST_USE_RESULT_
2162 #endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
2163 
2164 // MS C++ compiler emits warning when a conditional expression is compile time
2165 // constant. In some contexts this warning is false positive and needs to be
2166 // suppressed. Use the following two macros in such cases:
2167 //
2168 // GTEST_INTENTIONAL_CONST_COND_PUSH_()
2169 // while (true) {
2170 // GTEST_INTENTIONAL_CONST_COND_POP_()
2171 // }
2172 # define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
2173     GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
2174 # define GTEST_INTENTIONAL_CONST_COND_POP_() \
2175     GTEST_DISABLE_MSC_WARNINGS_POP_()
2176 
2177 // Determine whether the compiler supports Microsoft's Structured Exception
2178 // Handling.  This is supported by several Windows compilers but generally
2179 // does not exist on any other system.
2180 #ifndef GTEST_HAS_SEH
2181 // The user didn't tell us, so we need to figure it out.
2182 
2183 # if defined(_MSC_VER) || defined(__BORLANDC__)
2184 // These two compilers are known to support SEH.
2185 #  define GTEST_HAS_SEH 1
2186 # else
2187 // Assume no SEH.
2188 #  define GTEST_HAS_SEH 0
2189 # endif
2190 
2191 #define GTEST_IS_THREADSAFE \
2192     (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \
2193      || (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \
2194      || GTEST_HAS_PTHREAD)
2195 
2196 #endif  // GTEST_HAS_SEH
2197 
2198 #ifdef _MSC_VER
2199 # if GTEST_LINKED_AS_SHARED_LIBRARY
2200 #  define GTEST_API_ __declspec(dllimport)
2201 # elif GTEST_CREATE_SHARED_LIBRARY
2202 #  define GTEST_API_ __declspec(dllexport)
2203 # endif
2204 #elif __GNUC__ >= 4 || defined(__clang__)
2205 # define GTEST_API_ __attribute__((visibility ("default")))
2206 #endif // _MSC_VER
2207 
2208 #ifndef GTEST_API_
2209 # define GTEST_API_
2210 #endif
2211 
2212 #ifdef __GNUC__
2213 // Ask the compiler to never inline a given function.
2214 # define GTEST_NO_INLINE_ __attribute__((noinline))
2215 #else
2216 # define GTEST_NO_INLINE_
2217 #endif
2218 
2219 // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
2220 #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
2221 # define GTEST_HAS_CXXABI_H_ 1
2222 #else
2223 # define GTEST_HAS_CXXABI_H_ 0
2224 #endif
2225 
2226 // A function level attribute to disable checking for use of uninitialized
2227 // memory when built with MemorySanitizer.
2228 #if defined(__clang__)
2229 # if __has_feature(memory_sanitizer)
2230 #  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
2231        __attribute__((no_sanitize_memory))
2232 # else
2233 #  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
2234 # endif  // __has_feature(memory_sanitizer)
2235 #else
2236 # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
2237 #endif  // __clang__
2238 
2239 // A function level attribute to disable AddressSanitizer instrumentation.
2240 #if defined(__clang__)
2241 # if __has_feature(address_sanitizer)
2242 #  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
2243        __attribute__((no_sanitize_address))
2244 # else
2245 #  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
2246 # endif  // __has_feature(address_sanitizer)
2247 #else
2248 # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
2249 #endif  // __clang__
2250 
2251 // A function level attribute to disable ThreadSanitizer instrumentation.
2252 #if defined(__clang__)
2253 # if __has_feature(thread_sanitizer)
2254 #  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \
2255        __attribute__((no_sanitize_thread))
2256 # else
2257 #  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
2258 # endif  // __has_feature(thread_sanitizer)
2259 #else
2260 # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
2261 #endif  // __clang__
2262 
2263 namespace testing {
2264 
2265 class Message;
2266 
2267 #if defined(GTEST_TUPLE_NAMESPACE_)
2268 // Import tuple and friends into the ::testing namespace.
2269 // It is part of our interface, having them in ::testing allows us to change
2270 // their types as needed.
2271 using GTEST_TUPLE_NAMESPACE_::get;
2272 using GTEST_TUPLE_NAMESPACE_::make_tuple;
2273 using GTEST_TUPLE_NAMESPACE_::tuple;
2274 using GTEST_TUPLE_NAMESPACE_::tuple_size;
2275 using GTEST_TUPLE_NAMESPACE_::tuple_element;
2276 #endif  // defined(GTEST_TUPLE_NAMESPACE_)
2277 
2278 namespace internal {
2279 
2280 // A secret type that Google Test users don't know about.  It has no
2281 // definition on purpose.  Therefore it's impossible to create a
2282 // Secret object, which is what we want.
2283 class Secret;
2284 
2285 // The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time
2286 // expression is true. For example, you could use it to verify the
2287 // size of a static array:
2288 //
2289 //   GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,
2290 //                         names_incorrect_size);
2291 //
2292 // or to make sure a struct is smaller than a certain size:
2293 //
2294 //   GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);
2295 //
2296 // The second argument to the macro is the name of the variable. If
2297 // the expression is false, most compilers will issue a warning/error
2298 // containing the name of the variable.
2299 
2300 #if GTEST_LANG_CXX11
2301 # define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
2302 #else  // !GTEST_LANG_CXX11
2303 template <bool>
2304   struct CompileAssert {
2305 };
2306 
2307 # define GTEST_COMPILE_ASSERT_(expr, msg) \
2308   typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \
2309       msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_
2310 #endif  // !GTEST_LANG_CXX11
2311 
2312 // Implementation details of GTEST_COMPILE_ASSERT_:
2313 //
2314 // (In C++11, we simply use static_assert instead of the following)
2315 //
2316 // - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1
2317 //   elements (and thus is invalid) when the expression is false.
2318 //
2319 // - The simpler definition
2320 //
2321 //    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]
2322 //
2323 //   does not work, as gcc supports variable-length arrays whose sizes
2324 //   are determined at run-time (this is gcc's extension and not part
2325 //   of the C++ standard).  As a result, gcc fails to reject the
2326 //   following code with the simple definition:
2327 //
2328 //     int foo;
2329 //     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is
2330 //                                      // not a compile-time constant.
2331 //
2332 // - By using the type CompileAssert<(bool(expr))>, we ensures that
2333 //   expr is a compile-time constant.  (Template arguments must be
2334 //   determined at compile-time.)
2335 //
2336 // - The outter parentheses in CompileAssert<(bool(expr))> are necessary
2337 //   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written
2338 //
2339 //     CompileAssert<bool(expr)>
2340 //
2341 //   instead, these compilers will refuse to compile
2342 //
2343 //     GTEST_COMPILE_ASSERT_(5 > 0, some_message);
2344 //
2345 //   (They seem to think the ">" in "5 > 0" marks the end of the
2346 //   template argument list.)
2347 //
2348 // - The array size is (bool(expr) ? 1 : -1), instead of simply
2349 //
2350 //     ((expr) ? 1 : -1).
2351 //
2352 //   This is to avoid running into a bug in MS VC 7.1, which
2353 //   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
2354 
2355 // StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
2356 //
2357 // This template is declared, but intentionally undefined.
2358 template <typename T1, typename T2>
2359 struct StaticAssertTypeEqHelper;
2360 
2361 template <typename T>
2362 struct StaticAssertTypeEqHelper<T, T> {
2363   enum { value = true };
2364 };
2365 
2366 // Evaluates to the number of elements in 'array'.
2367 #define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
2368 
2369 #if GTEST_HAS_GLOBAL_STRING
2370 typedef ::string string;
2371 #else
2372 typedef ::std::string string;
2373 #endif  // GTEST_HAS_GLOBAL_STRING
2374 
2375 #if GTEST_HAS_GLOBAL_WSTRING
2376 typedef ::wstring wstring;
2377 #elif GTEST_HAS_STD_WSTRING
2378 typedef ::std::wstring wstring;
2379 #endif  // GTEST_HAS_GLOBAL_WSTRING
2380 
2381 // A helper for suppressing warnings on constant condition.  It just
2382 // returns 'condition'.
2383 GTEST_API_ bool IsTrue(bool condition);
2384 
2385 // Defines scoped_ptr.
2386 
2387 // This implementation of scoped_ptr is PARTIAL - it only contains
2388 // enough stuff to satisfy Google Test's need.
2389 template <typename T>
2390 class scoped_ptr {
2391  public:
2392   typedef T element_type;
2393 
2394   explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
2395   ~scoped_ptr() { reset(); }
2396 
2397   T& operator*() const { return *ptr_; }
2398   T* operator->() const { return ptr_; }
2399   T* get() const { return ptr_; }
2400 
2401   T* release() {
2402     T* const ptr = ptr_;
2403     ptr_ = NULL;
2404     return ptr;
2405   }
2406 
2407   void reset(T* p = NULL) {
2408     if (p != ptr_) {
2409       if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.
2410         delete ptr_;
2411       }
2412       ptr_ = p;
2413     }
2414   }
2415 
2416   friend void swap(scoped_ptr& a, scoped_ptr& b) {
2417     using std::swap;
2418     swap(a.ptr_, b.ptr_);
2419   }
2420 
2421  private:
2422   T* ptr_;
2423 
2424   GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
2425 };
2426 
2427 // Defines RE.
2428 
2429 // A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended
2430 // Regular Expression syntax.
2431 class GTEST_API_ RE {
2432  public:
2433   // A copy constructor is required by the Standard to initialize object
2434   // references from r-values.
2435   RE(const RE& other) { Init(other.pattern()); }
2436 
2437   // Constructs an RE from a string.
2438   RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT
2439 
2440 #if GTEST_HAS_GLOBAL_STRING
2441 
2442   RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT
2443 
2444 #endif  // GTEST_HAS_GLOBAL_STRING
2445 
2446   RE(const char* regex) { Init(regex); }  // NOLINT
2447   ~RE();
2448 
2449   // Returns the string representation of the regex.
2450   const char* pattern() const { return pattern_; }
2451 
2452   // FullMatch(str, re) returns true iff regular expression re matches
2453   // the entire str.
2454   // PartialMatch(str, re) returns true iff regular expression re
2455   // matches a substring of str (including str itself).
2456   //
2457   // TODO(wan@google.com): make FullMatch() and PartialMatch() work
2458   // when str contains NUL characters.
2459   static bool FullMatch(const ::std::string& str, const RE& re) {
2460     return FullMatch(str.c_str(), re);
2461   }
2462   static bool PartialMatch(const ::std::string& str, const RE& re) {
2463     return PartialMatch(str.c_str(), re);
2464   }
2465 
2466 #if GTEST_HAS_GLOBAL_STRING
2467 
2468   static bool FullMatch(const ::string& str, const RE& re) {
2469     return FullMatch(str.c_str(), re);
2470   }
2471   static bool PartialMatch(const ::string& str, const RE& re) {
2472     return PartialMatch(str.c_str(), re);
2473   }
2474 
2475 #endif  // GTEST_HAS_GLOBAL_STRING
2476 
2477   static bool FullMatch(const char* str, const RE& re);
2478   static bool PartialMatch(const char* str, const RE& re);
2479 
2480  private:
2481   void Init(const char* regex);
2482 
2483   // We use a const char* instead of an std::string, as Google Test used to be
2484   // used where std::string is not available.  TODO(wan@google.com): change to
2485   // std::string.
2486   const char* pattern_;
2487   bool is_valid_;
2488 
2489 #if GTEST_USES_POSIX_RE
2490 
2491   regex_t full_regex_;     // For FullMatch().
2492   regex_t partial_regex_;  // For PartialMatch().
2493 
2494 #else  // GTEST_USES_SIMPLE_RE
2495 
2496   const char* full_pattern_;  // For FullMatch();
2497 
2498 #endif
2499 
2500   GTEST_DISALLOW_ASSIGN_(RE);
2501 };
2502 
2503 // Formats a source file path and a line number as they would appear
2504 // in an error message from the compiler used to compile this code.
2505 GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
2506 
2507 // Formats a file location for compiler-independent XML output.
2508 // Although this function is not platform dependent, we put it next to
2509 // FormatFileLocation in order to contrast the two functions.
2510 GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
2511                                                                int line);
2512 
2513 // Defines logging utilities:
2514 //   GTEST_LOG_(severity) - logs messages at the specified severity level. The
2515 //                          message itself is streamed into the macro.
2516 //   LogToStderr()  - directs all log messages to stderr.
2517 //   FlushInfoLog() - flushes informational log messages.
2518 
2519 enum GTestLogSeverity {
2520   GTEST_INFO,
2521   GTEST_WARNING,
2522   GTEST_ERROR,
2523   GTEST_FATAL
2524 };
2525 
2526 // Formats log entry severity, provides a stream object for streaming the
2527 // log message, and terminates the message with a newline when going out of
2528 // scope.
2529 class GTEST_API_ GTestLog {
2530  public:
2531   GTestLog(GTestLogSeverity severity, const char* file, int line);
2532 
2533   // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
2534   ~GTestLog();
2535 
2536   ::std::ostream& GetStream() { return ::std::cerr; }
2537 
2538  private:
2539   const GTestLogSeverity severity_;
2540 
2541   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
2542 };
2543 
2544 #if !defined(GTEST_LOG_)
2545 
2546 # define GTEST_LOG_(severity) \
2547     ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
2548                                   __FILE__, __LINE__).GetStream()
2549 
2550 inline void LogToStderr() {}
2551 inline void FlushInfoLog() { fflush(NULL); }
2552 
2553 #endif  // !defined(GTEST_LOG_)
2554 
2555 #if !defined(GTEST_CHECK_)
2556 // INTERNAL IMPLEMENTATION - DO NOT USE.
2557 //
2558 // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
2559 // is not satisfied.
2560 //  Synopsys:
2561 //    GTEST_CHECK_(boolean_condition);
2562 //     or
2563 //    GTEST_CHECK_(boolean_condition) << "Additional message";
2564 //
2565 //    This checks the condition and if the condition is not satisfied
2566 //    it prints message about the condition violation, including the
2567 //    condition itself, plus additional message streamed into it, if any,
2568 //    and then it aborts the program. It aborts the program irrespective of
2569 //    whether it is built in the debug mode or not.
2570 # define GTEST_CHECK_(condition) \
2571     GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
2572     if (::testing::internal::IsTrue(condition)) \
2573       ; \
2574     else \
2575       GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
2576 #endif  // !defined(GTEST_CHECK_)
2577 
2578 // An all-mode assert to verify that the given POSIX-style function
2579 // call returns 0 (indicating success).  Known limitation: this
2580 // doesn't expand to a balanced 'if' statement, so enclose the macro
2581 // in {} if you need to use it as the only statement in an 'if'
2582 // branch.
2583 #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
2584   if (const int gtest_error = (posix_call)) \
2585     GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
2586                       << gtest_error
2587 
2588 #if GTEST_HAS_STD_MOVE_
2589 using std::move;
2590 #else  // GTEST_HAS_STD_MOVE_
2591 template <typename T>
2592 const T& move(const T& t) {
2593   return t;
2594 }
2595 #endif  // GTEST_HAS_STD_MOVE_
2596 
2597 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
2598 //
2599 // Use ImplicitCast_ as a safe version of static_cast for upcasting in
2600 // the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
2601 // const Foo*).  When you use ImplicitCast_, the compiler checks that
2602 // the cast is safe.  Such explicit ImplicitCast_s are necessary in
2603 // surprisingly many situations where C++ demands an exact type match
2604 // instead of an argument type convertable to a target type.
2605 //
2606 // The syntax for using ImplicitCast_ is the same as for static_cast:
2607 //
2608 //   ImplicitCast_<ToType>(expr)
2609 //
2610 // ImplicitCast_ would have been part of the C++ standard library,
2611 // but the proposal was submitted too late.  It will probably make
2612 // its way into the language in the future.
2613 //
2614 // This relatively ugly name is intentional. It prevents clashes with
2615 // similar functions users may have (e.g., implicit_cast). The internal
2616 // namespace alone is not enough because the function can be found by ADL.
2617 template<typename To>
2618 inline To ImplicitCast_(To x) { return x; }
2619 
2620 // When you upcast (that is, cast a pointer from type Foo to type
2621 // SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
2622 // always succeed.  When you downcast (that is, cast a pointer from
2623 // type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
2624 // how do you know the pointer is really of type SubclassOfFoo?  It
2625 // could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
2626 // when you downcast, you should use this macro.  In debug mode, we
2627 // use dynamic_cast<> to double-check the downcast is legal (we die
2628 // if it's not).  In normal mode, we do the efficient static_cast<>
2629 // instead.  Thus, it's important to test in debug mode to make sure
2630 // the cast is legal!
2631 //    This is the only place in the code we should use dynamic_cast<>.
2632 // In particular, you SHOULDN'T be using dynamic_cast<> in order to
2633 // do RTTI (eg code like this:
2634 //    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
2635 //    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
2636 // You should design the code some other way not to need this.
2637 //
2638 // This relatively ugly name is intentional. It prevents clashes with
2639 // similar functions users may have (e.g., down_cast). The internal
2640 // namespace alone is not enough because the function can be found by ADL.
2641 template<typename To, typename From>  // use like this: DownCast_<T*>(foo);
2642 inline To DownCast_(From* f) {  // so we only accept pointers
2643   // Ensures that To is a sub-type of From *.  This test is here only
2644   // for compile-time type checking, and has no overhead in an
2645   // optimized build at run-time, as it will be optimized away
2646   // completely.
2647   GTEST_INTENTIONAL_CONST_COND_PUSH_()
2648   if (false) {
2649   GTEST_INTENTIONAL_CONST_COND_POP_()
2650     const To to = NULL;
2651     ::testing::internal::ImplicitCast_<From*>(to);
2652   }
2653 
2654 #if GTEST_HAS_RTTI
2655   // RTTI: debug mode only!
2656   GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);
2657 #endif
2658   return static_cast<To>(f);
2659 }
2660 
2661 // Downcasts the pointer of type Base to Derived.
2662 // Derived must be a subclass of Base. The parameter MUST
2663 // point to a class of type Derived, not any subclass of it.
2664 // When RTTI is available, the function performs a runtime
2665 // check to enforce this.
2666 template <class Derived, class Base>
2667 Derived* CheckedDowncastToActualType(Base* base) {
2668 #if GTEST_HAS_RTTI
2669   GTEST_CHECK_(typeid(*base) == typeid(Derived));
2670 #endif
2671 
2672 #if GTEST_HAS_DOWNCAST_
2673   return ::down_cast<Derived*>(base);
2674 #elif GTEST_HAS_RTTI
2675   return dynamic_cast<Derived*>(base);  // NOLINT
2676 #else
2677   return static_cast<Derived*>(base);  // Poor man's downcast.
2678 #endif
2679 }
2680 
2681 #if GTEST_HAS_STREAM_REDIRECTION
2682 
2683 // Defines the stderr capturer:
2684 //   CaptureStdout     - starts capturing stdout.
2685 //   GetCapturedStdout - stops capturing stdout and returns the captured string.
2686 //   CaptureStderr     - starts capturing stderr.
2687 //   GetCapturedStderr - stops capturing stderr and returns the captured string.
2688 //
2689 GTEST_API_ void CaptureStdout();
2690 GTEST_API_ std::string GetCapturedStdout();
2691 GTEST_API_ void CaptureStderr();
2692 GTEST_API_ std::string GetCapturedStderr();
2693 
2694 #endif  // GTEST_HAS_STREAM_REDIRECTION
2695 
2696 // Returns a path to temporary directory.
2697 GTEST_API_ std::string TempDir();
2698 
2699 // Returns the size (in bytes) of a file.
2700 GTEST_API_ size_t GetFileSize(FILE* file);
2701 
2702 // Reads the entire content of a file as a string.
2703 GTEST_API_ std::string ReadEntireFile(FILE* file);
2704 
2705 // All command line arguments.
2706 GTEST_API_ const ::std::vector<testing::internal::string>& GetArgvs();
2707 
2708 #if GTEST_HAS_DEATH_TEST
2709 
2710 const ::std::vector<testing::internal::string>& GetInjectableArgvs();
2711 void SetInjectableArgvs(const ::std::vector<testing::internal::string>*
2712                              new_argvs);
2713 
2714 
2715 #endif  // GTEST_HAS_DEATH_TEST
2716 
2717 // Defines synchronization primitives.
2718 #if GTEST_IS_THREADSAFE
2719 # if GTEST_HAS_PTHREAD
2720 // Sleeps for (roughly) n milliseconds.  This function is only for testing
2721 // Google Test's own constructs.  Don't use it in user tests, either
2722 // directly or indirectly.
2723 inline void SleepMilliseconds(int n) {
2724   const timespec time = {
2725     0,                  // 0 seconds.
2726     n * 1000L * 1000L,  // And n ms.
2727   };
2728   nanosleep(&time, NULL);
2729 }
2730 # endif  // GTEST_HAS_PTHREAD
2731 
2732 # if GTEST_HAS_NOTIFICATION_
2733 // Notification has already been imported into the namespace.
2734 // Nothing to do here.
2735 
2736 # elif GTEST_HAS_PTHREAD
2737 // Allows a controller thread to pause execution of newly created
2738 // threads until notified.  Instances of this class must be created
2739 // and destroyed in the controller thread.
2740 //
2741 // This class is only for testing Google Test's own constructs. Do not
2742 // use it in user tests, either directly or indirectly.
2743 class Notification {
2744  public:
2745   Notification() : notified_(false) {
2746     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
2747   }
2748   ~Notification() {
2749     pthread_mutex_destroy(&mutex_);
2750   }
2751 
2752   // Notifies all threads created with this notification to start. Must
2753   // be called from the controller thread.
2754   void Notify() {
2755     pthread_mutex_lock(&mutex_);
2756     notified_ = true;
2757     pthread_mutex_unlock(&mutex_);
2758   }
2759 
2760   // Blocks until the controller thread notifies. Must be called from a test
2761   // thread.
2762   void WaitForNotification() {
2763     for (;;) {
2764       pthread_mutex_lock(&mutex_);
2765       const bool notified = notified_;
2766       pthread_mutex_unlock(&mutex_);
2767       if (notified)
2768         break;
2769       SleepMilliseconds(10);
2770     }
2771   }
2772 
2773  private:
2774   pthread_mutex_t mutex_;
2775   bool notified_;
2776 
2777   GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
2778 };
2779 
2780 # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
2781 
2782 GTEST_API_ void SleepMilliseconds(int n);
2783 
2784 // Provides leak-safe Windows kernel handle ownership.
2785 // Used in death tests and in threading support.
2786 class GTEST_API_ AutoHandle {
2787  public:
2788   // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to
2789   // avoid including <windows.h> in this header file. Including <windows.h> is
2790   // undesirable because it defines a lot of symbols and macros that tend to
2791   // conflict with client code. This assumption is verified by
2792   // WindowsTypesTest.HANDLEIsVoidStar.
2793   typedef void* Handle;
2794   AutoHandle();
2795   explicit AutoHandle(Handle handle);
2796 
2797   ~AutoHandle();
2798 
2799   Handle Get() const;
2800   void Reset();
2801   void Reset(Handle handle);
2802 
2803  private:
2804   // Returns true iff the handle is a valid handle object that can be closed.
2805   bool IsCloseable() const;
2806 
2807   Handle handle_;
2808 
2809   GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
2810 };
2811 
2812 // Allows a controller thread to pause execution of newly created
2813 // threads until notified.  Instances of this class must be created
2814 // and destroyed in the controller thread.
2815 //
2816 // This class is only for testing Google Test's own constructs. Do not
2817 // use it in user tests, either directly or indirectly.
2818 class GTEST_API_ Notification {
2819  public:
2820   Notification();
2821   void Notify();
2822   void WaitForNotification();
2823 
2824  private:
2825   AutoHandle event_;
2826 
2827   GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
2828 };
2829 # endif  // GTEST_HAS_NOTIFICATION_
2830 
2831 // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD
2832 // defined, but we don't want to use MinGW's pthreads implementation, which
2833 // has conformance problems with some versions of the POSIX standard.
2834 # if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW
2835 
2836 // As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
2837 // Consequently, it cannot select a correct instantiation of ThreadWithParam
2838 // in order to call its Run(). Introducing ThreadWithParamBase as a
2839 // non-templated base class for ThreadWithParam allows us to bypass this
2840 // problem.
2841 class ThreadWithParamBase {
2842  public:
2843   virtual ~ThreadWithParamBase() {}
2844   virtual void Run() = 0;
2845 };
2846 
2847 // pthread_create() accepts a pointer to a function type with the C linkage.
2848 // According to the Standard (7.5/1), function types with different linkages
2849 // are different even if they are otherwise identical.  Some compilers (for
2850 // example, SunStudio) treat them as different types.  Since class methods
2851 // cannot be defined with C-linkage we need to define a free C-function to
2852 // pass into pthread_create().
2853 extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
2854   static_cast<ThreadWithParamBase*>(thread)->Run();
2855   return NULL;
2856 }
2857 
2858 // Helper class for testing Google Test's multi-threading constructs.
2859 // To use it, write:
2860 //
2861 //   void ThreadFunc(int param) { /* Do things with param */ }
2862 //   Notification thread_can_start;
2863 //   ...
2864 //   // The thread_can_start parameter is optional; you can supply NULL.
2865 //   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
2866 //   thread_can_start.Notify();
2867 //
2868 // These classes are only for testing Google Test's own constructs. Do
2869 // not use them in user tests, either directly or indirectly.
2870 template <typename T>
2871 class ThreadWithParam : public ThreadWithParamBase {
2872  public:
2873   typedef void UserThreadFunc(T);
2874 
2875   ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
2876       : func_(func),
2877         param_(param),
2878         thread_can_start_(thread_can_start),
2879         finished_(false) {
2880     ThreadWithParamBase* const base = this;
2881     // The thread can be created only after all fields except thread_
2882     // have been initialized.
2883     GTEST_CHECK_POSIX_SUCCESS_(
2884         pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));
2885   }
2886   ~ThreadWithParam() { Join(); }
2887 
2888   void Join() {
2889     if (!finished_) {
2890       GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));
2891       finished_ = true;
2892     }
2893   }
2894 
2895   virtual void Run() {
2896     if (thread_can_start_ != NULL)
2897       thread_can_start_->WaitForNotification();
2898     func_(param_);
2899   }
2900 
2901  private:
2902   UserThreadFunc* const func_;  // User-supplied thread function.
2903   const T param_;  // User-supplied parameter to the thread function.
2904   // When non-NULL, used to block execution until the controller thread
2905   // notifies.
2906   Notification* const thread_can_start_;
2907   bool finished_;  // true iff we know that the thread function has finished.
2908   pthread_t thread_;  // The native thread object.
2909 
2910   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
2911 };
2912 # endif  // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
2913          // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
2914 
2915 # if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
2916 // Mutex and ThreadLocal have already been imported into the namespace.
2917 // Nothing to do here.
2918 
2919 # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
2920 
2921 // Mutex implements mutex on Windows platforms.  It is used in conjunction
2922 // with class MutexLock:
2923 //
2924 //   Mutex mutex;
2925 //   ...
2926 //   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the
2927 //                            // end of the current scope.
2928 //
2929 // A static Mutex *must* be defined or declared using one of the following
2930 // macros:
2931 //   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
2932 //   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
2933 //
2934 // (A non-static Mutex is defined/declared in the usual way).
2935 class GTEST_API_ Mutex {
2936  public:
2937   enum MutexType { kStatic = 0, kDynamic = 1 };
2938   // We rely on kStaticMutex being 0 as it is to what the linker initializes
2939   // type_ in static mutexes.  critical_section_ will be initialized lazily
2940   // in ThreadSafeLazyInit().
2941   enum StaticConstructorSelector { kStaticMutex = 0 };
2942 
2943   // This constructor intentionally does nothing.  It relies on type_ being
2944   // statically initialized to 0 (effectively setting it to kStatic) and on
2945   // ThreadSafeLazyInit() to lazily initialize the rest of the members.
2946   explicit Mutex(StaticConstructorSelector /*dummy*/) {}
2947 
2948   Mutex();
2949   ~Mutex();
2950 
2951   void Lock();
2952 
2953   void Unlock();
2954 
2955   // Does nothing if the current thread holds the mutex. Otherwise, crashes
2956   // with high probability.
2957   void AssertHeld();
2958 
2959  private:
2960   // Initializes owner_thread_id_ and critical_section_ in static mutexes.
2961   void ThreadSafeLazyInit();
2962 
2963   // Per http://blogs.msdn.com/b/oldnewthing/archive/2004/02/23/78395.aspx,
2964   // we assume that 0 is an invalid value for thread IDs.
2965   unsigned int owner_thread_id_;
2966 
2967   // For static mutexes, we rely on these members being initialized to zeros
2968   // by the linker.
2969   MutexType type_;
2970   long critical_section_init_phase_;  // NOLINT
2971   _RTL_CRITICAL_SECTION* critical_section_;
2972 
2973   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
2974 };
2975 
2976 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
2977     extern ::testing::internal::Mutex mutex
2978 
2979 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
2980     ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
2981 
2982 // We cannot name this class MutexLock because the ctor declaration would
2983 // conflict with a macro named MutexLock, which is defined on some
2984 // platforms. That macro is used as a defensive measure to prevent against
2985 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
2986 // "MutexLock l(&mu)".  Hence the typedef trick below.
2987 class GTestMutexLock {
2988  public:
2989   explicit GTestMutexLock(Mutex* mutex)
2990       : mutex_(mutex) { mutex_->Lock(); }
2991 
2992   ~GTestMutexLock() { mutex_->Unlock(); }
2993 
2994  private:
2995   Mutex* const mutex_;
2996 
2997   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
2998 };
2999 
3000 typedef GTestMutexLock MutexLock;
3001 
3002 // Base class for ValueHolder<T>.  Allows a caller to hold and delete a value
3003 // without knowing its type.
3004 class ThreadLocalValueHolderBase {
3005  public:
3006   virtual ~ThreadLocalValueHolderBase() {}
3007 };
3008 
3009 // Provides a way for a thread to send notifications to a ThreadLocal
3010 // regardless of its parameter type.
3011 class ThreadLocalBase {
3012  public:
3013   // Creates a new ValueHolder<T> object holding a default value passed to
3014   // this ThreadLocal<T>'s constructor and returns it.  It is the caller's
3015   // responsibility not to call this when the ThreadLocal<T> instance already
3016   // has a value on the current thread.
3017   virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;
3018 
3019  protected:
3020   ThreadLocalBase() {}
3021   virtual ~ThreadLocalBase() {}
3022 
3023  private:
3024   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);
3025 };
3026 
3027 // Maps a thread to a set of ThreadLocals that have values instantiated on that
3028 // thread and notifies them when the thread exits.  A ThreadLocal instance is
3029 // expected to persist until all threads it has values on have terminated.
3030 class GTEST_API_ ThreadLocalRegistry {
3031  public:
3032   // Registers thread_local_instance as having value on the current thread.
3033   // Returns a value that can be used to identify the thread from other threads.
3034   static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
3035       const ThreadLocalBase* thread_local_instance);
3036 
3037   // Invoked when a ThreadLocal instance is destroyed.
3038   static void OnThreadLocalDestroyed(
3039       const ThreadLocalBase* thread_local_instance);
3040 };
3041 
3042 class GTEST_API_ ThreadWithParamBase {
3043  public:
3044   void Join();
3045 
3046  protected:
3047   class Runnable {
3048    public:
3049     virtual ~Runnable() {}
3050     virtual void Run() = 0;
3051   };
3052 
3053   ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);
3054   virtual ~ThreadWithParamBase();
3055 
3056  private:
3057   AutoHandle thread_;
3058 };
3059 
3060 // Helper class for testing Google Test's multi-threading constructs.
3061 template <typename T>
3062 class ThreadWithParam : public ThreadWithParamBase {
3063  public:
3064   typedef void UserThreadFunc(T);
3065 
3066   ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
3067       : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {
3068   }
3069   virtual ~ThreadWithParam() {}
3070 
3071  private:
3072   class RunnableImpl : public Runnable {
3073    public:
3074     RunnableImpl(UserThreadFunc* func, T param)
3075         : func_(func),
3076           param_(param) {
3077     }
3078     virtual ~RunnableImpl() {}
3079     virtual void Run() {
3080       func_(param_);
3081     }
3082 
3083    private:
3084     UserThreadFunc* const func_;
3085     const T param_;
3086 
3087     GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);
3088   };
3089 
3090   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
3091 };
3092 
3093 // Implements thread-local storage on Windows systems.
3094 //
3095 //   // Thread 1
3096 //   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.
3097 //
3098 //   // Thread 2
3099 //   tl.set(150);  // Changes the value for thread 2 only.
3100 //   EXPECT_EQ(150, tl.get());
3101 //
3102 //   // Thread 1
3103 //   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
3104 //   tl.set(200);
3105 //   EXPECT_EQ(200, tl.get());
3106 //
3107 // The template type argument T must have a public copy constructor.
3108 // In addition, the default ThreadLocal constructor requires T to have
3109 // a public default constructor.
3110 //
3111 // The users of a TheadLocal instance have to make sure that all but one
3112 // threads (including the main one) using that instance have exited before
3113 // destroying it. Otherwise, the per-thread objects managed for them by the
3114 // ThreadLocal instance are not guaranteed to be destroyed on all platforms.
3115 //
3116 // Google Test only uses global ThreadLocal objects.  That means they
3117 // will die after main() has returned.  Therefore, no per-thread
3118 // object managed by Google Test will be leaked as long as all threads
3119 // using Google Test have exited when main() returns.
3120 template <typename T>
3121 class ThreadLocal : public ThreadLocalBase {
3122  public:
3123   ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
3124   explicit ThreadLocal(const T& value)
3125       : default_factory_(new InstanceValueHolderFactory(value)) {}
3126 
3127   ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }
3128 
3129   T* pointer() { return GetOrCreateValue(); }
3130   const T* pointer() const { return GetOrCreateValue(); }
3131   const T& get() const { return *pointer(); }
3132   void set(const T& value) { *pointer() = value; }
3133 
3134  private:
3135   // Holds a value of T.  Can be deleted via its base class without the caller
3136   // knowing the type of T.
3137   class ValueHolder : public ThreadLocalValueHolderBase {
3138    public:
3139     ValueHolder() : value_() {}
3140     explicit ValueHolder(const T& value) : value_(value) {}
3141 
3142     T* pointer() { return &value_; }
3143 
3144    private:
3145     T value_;
3146     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
3147   };
3148 
3149 
3150   T* GetOrCreateValue() const {
3151     return static_cast<ValueHolder*>(
3152         ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();
3153   }
3154 
3155   virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {
3156     return default_factory_->MakeNewHolder();
3157   }
3158 
3159   class ValueHolderFactory {
3160    public:
3161     ValueHolderFactory() {}
3162     virtual ~ValueHolderFactory() {}
3163     virtual ValueHolder* MakeNewHolder() const = 0;
3164 
3165    private:
3166     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
3167   };
3168 
3169   class DefaultValueHolderFactory : public ValueHolderFactory {
3170    public:
3171     DefaultValueHolderFactory() {}
3172     virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
3173 
3174    private:
3175     GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
3176   };
3177 
3178   class InstanceValueHolderFactory : public ValueHolderFactory {
3179    public:
3180     explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
3181     virtual ValueHolder* MakeNewHolder() const {
3182       return new ValueHolder(value_);
3183     }
3184 
3185    private:
3186     const T value_;  // The value for each thread.
3187 
3188     GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
3189   };
3190 
3191   scoped_ptr<ValueHolderFactory> default_factory_;
3192 
3193   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
3194 };
3195 
3196 # elif GTEST_HAS_PTHREAD
3197 
3198 // MutexBase and Mutex implement mutex on pthreads-based platforms.
3199 class MutexBase {
3200  public:
3201   // Acquires this mutex.
3202   void Lock() {
3203     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
3204     owner_ = pthread_self();
3205     has_owner_ = true;
3206   }
3207 
3208   // Releases this mutex.
3209   void Unlock() {
3210     // Since the lock is being released the owner_ field should no longer be
3211     // considered valid. We don't protect writing to has_owner_ here, as it's
3212     // the caller's responsibility to ensure that the current thread holds the
3213     // mutex when this is called.
3214     has_owner_ = false;
3215     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
3216   }
3217 
3218   // Does nothing if the current thread holds the mutex. Otherwise, crashes
3219   // with high probability.
3220   void AssertHeld() const {
3221     GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
3222         << "The current thread is not holding the mutex @" << this;
3223   }
3224 
3225   // A static mutex may be used before main() is entered.  It may even
3226   // be used before the dynamic initialization stage.  Therefore we
3227   // must be able to initialize a static mutex object at link time.
3228   // This means MutexBase has to be a POD and its member variables
3229   // have to be public.
3230  public:
3231   pthread_mutex_t mutex_;  // The underlying pthread mutex.
3232   // has_owner_ indicates whether the owner_ field below contains a valid thread
3233   // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
3234   // accesses to the owner_ field should be protected by a check of this field.
3235   // An alternative might be to memset() owner_ to all zeros, but there's no
3236   // guarantee that a zero'd pthread_t is necessarily invalid or even different
3237   // from pthread_self().
3238   bool has_owner_;
3239   pthread_t owner_;  // The thread holding the mutex.
3240 };
3241 
3242 // Forward-declares a static mutex.
3243 #  define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
3244      extern ::testing::internal::MutexBase mutex
3245 
3246 // Defines and statically (i.e. at link time) initializes a static mutex.
3247 #  define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
3248      ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false, pthread_t() }
3249 
3250 // The Mutex class can only be used for mutexes created at runtime. It
3251 // shares its API with MutexBase otherwise.
3252 class Mutex : public MutexBase {
3253  public:
3254   Mutex() {
3255     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
3256     has_owner_ = false;
3257   }
3258   ~Mutex() {
3259     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
3260   }
3261 
3262  private:
3263   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
3264 };
3265 
3266 // We cannot name this class MutexLock because the ctor declaration would
3267 // conflict with a macro named MutexLock, which is defined on some
3268 // platforms. That macro is used as a defensive measure to prevent against
3269 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
3270 // "MutexLock l(&mu)".  Hence the typedef trick below.
3271 class GTestMutexLock {
3272  public:
3273   explicit GTestMutexLock(MutexBase* mutex)
3274       : mutex_(mutex) { mutex_->Lock(); }
3275 
3276   ~GTestMutexLock() { mutex_->Unlock(); }
3277 
3278  private:
3279   MutexBase* const mutex_;
3280 
3281   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
3282 };
3283 
3284 typedef GTestMutexLock MutexLock;
3285 
3286 // Helpers for ThreadLocal.
3287 
3288 // pthread_key_create() requires DeleteThreadLocalValue() to have
3289 // C-linkage.  Therefore it cannot be templatized to access
3290 // ThreadLocal<T>.  Hence the need for class
3291 // ThreadLocalValueHolderBase.
3292 class ThreadLocalValueHolderBase {
3293  public:
3294   virtual ~ThreadLocalValueHolderBase() {}
3295 };
3296 
3297 // Called by pthread to delete thread-local data stored by
3298 // pthread_setspecific().
3299 extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
3300   delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
3301 }
3302 
3303 // Implements thread-local storage on pthreads-based systems.
3304 template <typename T>
3305 class ThreadLocal {
3306  public:
3307   ThreadLocal()
3308       : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
3309   explicit ThreadLocal(const T& value)
3310       : key_(CreateKey()),
3311         default_factory_(new InstanceValueHolderFactory(value)) {}
3312 
3313   ~ThreadLocal() {
3314     // Destroys the managed object for the current thread, if any.
3315     DeleteThreadLocalValue(pthread_getspecific(key_));
3316 
3317     // Releases resources associated with the key.  This will *not*
3318     // delete managed objects for other threads.
3319     GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
3320   }
3321 
3322   T* pointer() { return GetOrCreateValue(); }
3323   const T* pointer() const { return GetOrCreateValue(); }
3324   const T& get() const { return *pointer(); }
3325   void set(const T& value) { *pointer() = value; }
3326 
3327  private:
3328   // Holds a value of type T.
3329   class ValueHolder : public ThreadLocalValueHolderBase {
3330    public:
3331     ValueHolder() : value_() {}
3332     explicit ValueHolder(const T& value) : value_(value) {}
3333 
3334     T* pointer() { return &value_; }
3335 
3336    private:
3337     T value_;
3338     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
3339   };
3340 
3341   static pthread_key_t CreateKey() {
3342     pthread_key_t key;
3343     // When a thread exits, DeleteThreadLocalValue() will be called on
3344     // the object managed for that thread.
3345     GTEST_CHECK_POSIX_SUCCESS_(
3346         pthread_key_create(&key, &DeleteThreadLocalValue));
3347     return key;
3348   }
3349 
3350   T* GetOrCreateValue() const {
3351     ThreadLocalValueHolderBase* const holder =
3352         static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
3353     if (holder != NULL) {
3354       return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
3355     }
3356 
3357     ValueHolder* const new_holder = default_factory_->MakeNewHolder();
3358     ThreadLocalValueHolderBase* const holder_base = new_holder;
3359     GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
3360     return new_holder->pointer();
3361   }
3362 
3363   class ValueHolderFactory {
3364    public:
3365     ValueHolderFactory() {}
3366     virtual ~ValueHolderFactory() {}
3367     virtual ValueHolder* MakeNewHolder() const = 0;
3368 
3369    private:
3370     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
3371   };
3372 
3373   class DefaultValueHolderFactory : public ValueHolderFactory {
3374    public:
3375     DefaultValueHolderFactory() {}
3376     virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
3377 
3378    private:
3379     GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
3380   };
3381 
3382   class InstanceValueHolderFactory : public ValueHolderFactory {
3383    public:
3384     explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
3385     virtual ValueHolder* MakeNewHolder() const {
3386       return new ValueHolder(value_);
3387     }
3388 
3389    private:
3390     const T value_;  // The value for each thread.
3391 
3392     GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
3393   };
3394 
3395   // A key pthreads uses for looking up per-thread values.
3396   const pthread_key_t key_;
3397   scoped_ptr<ValueHolderFactory> default_factory_;
3398 
3399   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
3400 };
3401 
3402 # endif  // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
3403 
3404 #else  // GTEST_IS_THREADSAFE
3405 
3406 // A dummy implementation of synchronization primitives (mutex, lock,
3407 // and thread-local variable).  Necessary for compiling Google Test where
3408 // mutex is not supported - using Google Test in multiple threads is not
3409 // supported on such platforms.
3410 
3411 class Mutex {
3412  public:
3413   Mutex() {}
3414   void Lock() {}
3415   void Unlock() {}
3416   void AssertHeld() const {}
3417 };
3418 
3419 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
3420   extern ::testing::internal::Mutex mutex
3421 
3422 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
3423 
3424 // We cannot name this class MutexLock because the ctor declaration would
3425 // conflict with a macro named MutexLock, which is defined on some
3426 // platforms. That macro is used as a defensive measure to prevent against
3427 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
3428 // "MutexLock l(&mu)".  Hence the typedef trick below.
3429 class GTestMutexLock {
3430  public:
3431   explicit GTestMutexLock(Mutex*) {}  // NOLINT
3432 };
3433 
3434 typedef GTestMutexLock MutexLock;
3435 
3436 template <typename T>
3437 class ThreadLocal {
3438  public:
3439   ThreadLocal() : value_() {}
3440   explicit ThreadLocal(const T& value) : value_(value) {}
3441   T* pointer() { return &value_; }
3442   const T* pointer() const { return &value_; }
3443   const T& get() const { return value_; }
3444   void set(const T& value) { value_ = value; }
3445  private:
3446   T value_;
3447 };
3448 
3449 #endif  // GTEST_IS_THREADSAFE
3450 
3451 // Returns the number of threads running in the process, or 0 to indicate that
3452 // we cannot detect it.
3453 GTEST_API_ size_t GetThreadCount();
3454 
3455 // Passing non-POD classes through ellipsis (...) crashes the ARM
3456 // compiler and generates a warning in Sun Studio.  The Nokia Symbian
3457 // and the IBM XL C/C++ compiler try to instantiate a copy constructor
3458 // for objects passed through ellipsis (...), failing for uncopyable
3459 // objects.  We define this to ensure that only POD is passed through
3460 // ellipsis on these systems.
3461 #if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
3462 // We lose support for NULL detection where the compiler doesn't like
3463 // passing non-POD classes through ellipsis (...).
3464 # define GTEST_ELLIPSIS_NEEDS_POD_ 1
3465 #else
3466 # define GTEST_CAN_COMPARE_NULL 1
3467 #endif
3468 
3469 // The Nokia Symbian and IBM XL C/C++ compilers cannot decide between
3470 // const T& and const T* in a function template.  These compilers
3471 // _can_ decide between class template specializations for T and T*,
3472 // so a tr1::type_traits-like is_pointer works.
3473 #if defined(__SYMBIAN32__) || defined(__IBMCPP__)
3474 # define GTEST_NEEDS_IS_POINTER_ 1
3475 #endif
3476 
3477 template <bool bool_value>
3478 struct bool_constant {
3479   typedef bool_constant<bool_value> type;
3480   static const bool value = bool_value;
3481 };
3482 template <bool bool_value> const bool bool_constant<bool_value>::value;
3483 
3484 typedef bool_constant<false> false_type;
3485 typedef bool_constant<true> true_type;
3486 
3487 template <typename T>
3488 struct is_pointer : public false_type {};
3489 
3490 template <typename T>
3491 struct is_pointer<T*> : public true_type {};
3492 
3493 template <typename Iterator>
3494 struct IteratorTraits {
3495   typedef typename Iterator::value_type value_type;
3496 };
3497 
3498 template <typename T>
3499 struct IteratorTraits<T*> {
3500   typedef T value_type;
3501 };
3502 
3503 template <typename T>
3504 struct IteratorTraits<const T*> {
3505   typedef T value_type;
3506 };
3507 
3508 #if GTEST_OS_WINDOWS
3509 # define GTEST_PATH_SEP_ "\\"
3510 # define GTEST_HAS_ALT_PATH_SEP_ 1
3511 // The biggest signed integer type the compiler supports.
3512 typedef __int64 BiggestInt;
3513 #else
3514 # define GTEST_PATH_SEP_ "/"
3515 # define GTEST_HAS_ALT_PATH_SEP_ 0
3516 typedef long long BiggestInt;  // NOLINT
3517 #endif  // GTEST_OS_WINDOWS
3518 
3519 // Utilities for char.
3520 
3521 // isspace(int ch) and friends accept an unsigned char or EOF.  char
3522 // may be signed, depending on the compiler (or compiler flags).
3523 // Therefore we need to cast a char to unsigned char before calling
3524 // isspace(), etc.
3525 
3526 inline bool IsAlpha(char ch) {
3527   return isalpha(static_cast<unsigned char>(ch)) != 0;
3528 }
3529 inline bool IsAlNum(char ch) {
3530   return isalnum(static_cast<unsigned char>(ch)) != 0;
3531 }
3532 inline bool IsDigit(char ch) {
3533   return isdigit(static_cast<unsigned char>(ch)) != 0;
3534 }
3535 inline bool IsLower(char ch) {
3536   return islower(static_cast<unsigned char>(ch)) != 0;
3537 }
3538 inline bool IsSpace(char ch) {
3539   return isspace(static_cast<unsigned char>(ch)) != 0;
3540 }
3541 inline bool IsUpper(char ch) {
3542   return isupper(static_cast<unsigned char>(ch)) != 0;
3543 }
3544 inline bool IsXDigit(char ch) {
3545   return isxdigit(static_cast<unsigned char>(ch)) != 0;
3546 }
3547 inline bool IsXDigit(wchar_t ch) {
3548   const unsigned char low_byte = static_cast<unsigned char>(ch);
3549   return ch == low_byte && isxdigit(low_byte) != 0;
3550 }
3551 
3552 inline char ToLower(char ch) {
3553   return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
3554 }
3555 inline char ToUpper(char ch) {
3556   return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
3557 }
3558 
3559 inline std::string StripTrailingSpaces(std::string str) {
3560   std::string::iterator it = str.end();
3561   while (it != str.begin() && IsSpace(*--it))
3562     it = str.erase(it);
3563   return str;
3564 }
3565 
3566 // The testing::internal::posix namespace holds wrappers for common
3567 // POSIX functions.  These wrappers hide the differences between
3568 // Windows/MSVC and POSIX systems.  Since some compilers define these
3569 // standard functions as macros, the wrapper cannot have the same name
3570 // as the wrapped function.
3571 
3572 namespace posix {
3573 
3574 // Functions with a different name on Windows.
3575 
3576 #if GTEST_OS_WINDOWS
3577 
3578 typedef struct _stat StatStruct;
3579 
3580 # ifdef __BORLANDC__
3581 inline int IsATTY(int fd) { return isatty(fd); }
3582 inline int StrCaseCmp(const char* s1, const char* s2) {
3583   return stricmp(s1, s2);
3584 }
3585 inline char* StrDup(const char* src) { return strdup(src); }
3586 # else  // !__BORLANDC__
3587 #  if GTEST_OS_WINDOWS_MOBILE
3588 inline int IsATTY(int /* fd */) { return 0; }
3589 #  else
3590 inline int IsATTY(int fd) { return _isatty(fd); }
3591 #  endif  // GTEST_OS_WINDOWS_MOBILE
3592 inline int StrCaseCmp(const char* s1, const char* s2) {
3593   return _stricmp(s1, s2);
3594 }
3595 inline char* StrDup(const char* src) { return _strdup(src); }
3596 # endif  // __BORLANDC__
3597 
3598 # if GTEST_OS_WINDOWS_MOBILE
3599 inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
3600 // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
3601 // time and thus not defined there.
3602 # else
3603 inline int FileNo(FILE* file) { return _fileno(file); }
3604 inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
3605 inline int RmDir(const char* dir) { return _rmdir(dir); }
3606 inline bool IsDir(const StatStruct& st) {
3607   return (_S_IFDIR & st.st_mode) != 0;
3608 }
3609 # endif  // GTEST_OS_WINDOWS_MOBILE
3610 
3611 #else
3612 
3613 typedef struct stat StatStruct;
3614 
3615 inline int FileNo(FILE* file) { return fileno(file); }
3616 inline int IsATTY(int fd) { return isatty(fd); }
3617 inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
3618 inline int StrCaseCmp(const char* s1, const char* s2) {
3619   return strcasecmp(s1, s2);
3620 }
3621 inline char* StrDup(const char* src) { return strdup(src); }
3622 inline int RmDir(const char* dir) { return rmdir(dir); }
3623 inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
3624 
3625 #endif  // GTEST_OS_WINDOWS
3626 
3627 // Functions deprecated by MSVC 8.0.
3628 
3629 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */)
3630 
3631 inline const char* StrNCpy(char* dest, const char* src, size_t n) {
3632   return strncpy(dest, src, n);
3633 }
3634 
3635 // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
3636 // StrError() aren't needed on Windows CE at this time and thus not
3637 // defined there.
3638 
3639 #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
3640 inline int ChDir(const char* dir) { return chdir(dir); }
3641 #endif
3642 inline FILE* FOpen(const char* path, const char* mode) {
3643   return fopen(path, mode);
3644 }
3645 #if !GTEST_OS_WINDOWS_MOBILE
3646 inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
3647   return freopen(path, mode, stream);
3648 }
3649 inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
3650 #endif
3651 inline int FClose(FILE* fp) { return fclose(fp); }
3652 #if !GTEST_OS_WINDOWS_MOBILE
3653 inline int Read(int fd, void* buf, unsigned int count) {
3654   return static_cast<int>(read(fd, buf, count));
3655 }
3656 inline int Write(int fd, const void* buf, unsigned int count) {
3657   return static_cast<int>(write(fd, buf, count));
3658 }
3659 inline int Close(int fd) { return close(fd); }
3660 inline const char* StrError(int errnum) { return strerror(errnum); }
3661 #endif
3662 inline const char* GetEnv(const char* name) {
3663 #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE | GTEST_OS_WINDOWS_RT
3664   // We are on Windows CE, which has no environment variables.
3665   static_cast<void>(name);  // To prevent 'unused argument' warning.
3666   return NULL;
3667 #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
3668   // Environment variables which we programmatically clear will be set to the
3669   // empty string rather than unset (NULL).  Handle that case.
3670   const char* const env = getenv(name);
3671   return (env != NULL && env[0] != '\0') ? env : NULL;
3672 #else
3673   return getenv(name);
3674 #endif
3675 }
3676 
3677 GTEST_DISABLE_MSC_WARNINGS_POP_()
3678 
3679 #if GTEST_OS_WINDOWS_MOBILE
3680 // Windows CE has no C library. The abort() function is used in
3681 // several places in Google Test. This implementation provides a reasonable
3682 // imitation of standard behaviour.
3683 void Abort();
3684 #else
3685 inline void Abort() { abort(); }
3686 #endif  // GTEST_OS_WINDOWS_MOBILE
3687 
3688 }  // namespace posix
3689 
3690 // MSVC "deprecates" snprintf and issues warnings wherever it is used.  In
3691 // order to avoid these warnings, we need to use _snprintf or _snprintf_s on
3692 // MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate
3693 // function in order to achieve that.  We use macro definition here because
3694 // snprintf is a variadic function.
3695 #if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
3696 // MSVC 2005 and above support variadic macros.
3697 # define GTEST_SNPRINTF_(buffer, size, format, ...) \
3698      _snprintf_s(buffer, size, size, format, __VA_ARGS__)
3699 #elif defined(_MSC_VER)
3700 // Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't
3701 // complain about _snprintf.
3702 # define GTEST_SNPRINTF_ _snprintf
3703 #else
3704 # define GTEST_SNPRINTF_ snprintf
3705 #endif
3706 
3707 // The maximum number a BiggestInt can represent.  This definition
3708 // works no matter BiggestInt is represented in one's complement or
3709 // two's complement.
3710 //
3711 // We cannot rely on numeric_limits in STL, as __int64 and long long
3712 // are not part of standard C++ and numeric_limits doesn't need to be
3713 // defined for them.
3714 const BiggestInt kMaxBiggestInt =
3715     ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
3716 
3717 // This template class serves as a compile-time function from size to
3718 // type.  It maps a size in bytes to a primitive type with that
3719 // size. e.g.
3720 //
3721 //   TypeWithSize<4>::UInt
3722 //
3723 // is typedef-ed to be unsigned int (unsigned integer made up of 4
3724 // bytes).
3725 //
3726 // Such functionality should belong to STL, but I cannot find it
3727 // there.
3728 //
3729 // Google Test uses this class in the implementation of floating-point
3730 // comparison.
3731 //
3732 // For now it only handles UInt (unsigned int) as that's all Google Test
3733 // needs.  Other types can be easily added in the future if need
3734 // arises.
3735 template <size_t size>
3736 class TypeWithSize {
3737  public:
3738   // This prevents the user from using TypeWithSize<N> with incorrect
3739   // values of N.
3740   typedef void UInt;
3741 };
3742 
3743 // The specialization for size 4.
3744 template <>
3745 class TypeWithSize<4> {
3746  public:
3747   // unsigned int has size 4 in both gcc and MSVC.
3748   //
3749   // As base/basictypes.h doesn't compile on Windows, we cannot use
3750   // uint32, uint64, and etc here.
3751   typedef int Int;
3752   typedef unsigned int UInt;
3753 };
3754 
3755 // The specialization for size 8.
3756 template <>
3757 class TypeWithSize<8> {
3758  public:
3759 #if GTEST_OS_WINDOWS
3760   typedef __int64 Int;
3761   typedef unsigned __int64 UInt;
3762 #else
3763   typedef long long Int;  // NOLINT
3764   typedef unsigned long long UInt;  // NOLINT
3765 #endif  // GTEST_OS_WINDOWS
3766 };
3767 
3768 // Integer types of known sizes.
3769 typedef TypeWithSize<4>::Int Int32;
3770 typedef TypeWithSize<4>::UInt UInt32;
3771 typedef TypeWithSize<8>::Int Int64;
3772 typedef TypeWithSize<8>::UInt UInt64;
3773 typedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.
3774 
3775 // Utilities for command line flags and environment variables.
3776 
3777 // Macro for referencing flags.
3778 #if !defined(GTEST_FLAG)
3779 # define GTEST_FLAG(name) FLAGS_gtest_##name
3780 #endif  // !defined(GTEST_FLAG)
3781 
3782 #if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
3783 # define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
3784 #endif  // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
3785 
3786 #if !defined(GTEST_DECLARE_bool_)
3787 # define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
3788 
3789 // Macros for declaring flags.
3790 # define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
3791 # define GTEST_DECLARE_int32_(name) \
3792     GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
3793 #define GTEST_DECLARE_string_(name) \
3794     GTEST_API_ extern ::std::string GTEST_FLAG(name)
3795 
3796 // Macros for defining flags.
3797 #define GTEST_DEFINE_bool_(name, default_val, doc) \
3798     GTEST_API_ bool GTEST_FLAG(name) = (default_val)
3799 #define GTEST_DEFINE_int32_(name, default_val, doc) \
3800     GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
3801 #define GTEST_DEFINE_string_(name, default_val, doc) \
3802     GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
3803 
3804 #endif  // !defined(GTEST_DECLARE_bool_)
3805 
3806 // Thread annotations
3807 #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
3808 # define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
3809 # define GTEST_LOCK_EXCLUDED_(locks)
3810 #endif  // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
3811 
3812 // Parses 'str' for a 32-bit signed integer.  If successful, writes the result
3813 // to *value and returns true; otherwise leaves *value unchanged and returns
3814 // false.
3815 // TODO(chandlerc): Find a better way to refactor flag and environment parsing
3816 // out of both gtest-port.cc and gtest.cc to avoid exporting this utility
3817 // function.
3818 bool ParseInt32(const Message& src_text, const char* str, Int32* value);
3819 
3820 // Parses a bool/Int32/string from the environment variable
3821 // corresponding to the given Google Test flag.
3822 bool BoolFromGTestEnv(const char* flag, bool default_val);
3823 GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
3824 std::string StringFromGTestEnv(const char* flag, const char* default_val);
3825 
3826 }  // namespace internal
3827 }  // namespace testing
3828 
3829 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
3830 
3831 #if GTEST_OS_LINUX
3832 # include <stdlib.h>
3833 # include <sys/types.h>
3834 # include <sys/wait.h>
3835 # include <unistd.h>
3836 #endif  // GTEST_OS_LINUX
3837 
3838 #if GTEST_HAS_EXCEPTIONS
3839 # include <stdexcept>
3840 #endif
3841 
3842 #include <ctype.h>
3843 #include <float.h>
3844 #include <string.h>
3845 #include <iomanip>
3846 #include <limits>
3847 #include <map>
3848 #include <set>
3849 #include <string>
3850 #include <vector>
3851 
3852 // Copyright 2005, Google Inc.
3853 // All rights reserved.
3854 //
3855 // Redistribution and use in source and binary forms, with or without
3856 // modification, are permitted provided that the following conditions are
3857 // met:
3858 //
3859 //     * Redistributions of source code must retain the above copyright
3860 // notice, this list of conditions and the following disclaimer.
3861 //     * Redistributions in binary form must reproduce the above
3862 // copyright notice, this list of conditions and the following disclaimer
3863 // in the documentation and/or other materials provided with the
3864 // distribution.
3865 //     * Neither the name of Google Inc. nor the names of its
3866 // contributors may be used to endorse or promote products derived from
3867 // this software without specific prior written permission.
3868 //
3869 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3870 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3871 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3872 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3873 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3874 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3875 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3876 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3877 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3878 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3879 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3880 //
3881 // Author: wan@google.com (Zhanyong Wan)
3882 //
3883 // The Google C++ Testing Framework (Google Test)
3884 //
3885 // This header file defines the Message class.
3886 //
3887 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
3888 // leave some internal implementation details in this header file.
3889 // They are clearly marked by comments like this:
3890 //
3891 //   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
3892 //
3893 // Such code is NOT meant to be used by a user directly, and is subject
3894 // to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
3895 // program!
3896 
3897 #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
3898 #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
3899 
3900 #include <limits>
3901 
3902 
3903 // Ensures that there is at least one operator<< in the global namespace.
3904 // See Message& operator<<(...) below for why.
3905 void operator<<(const testing::internal::Secret&, int);
3906 
3907 namespace testing {
3908 
3909 // The Message class works like an ostream repeater.
3910 //
3911 // Typical usage:
3912 //
3913 //   1. You stream a bunch of values to a Message object.
3914 //      It will remember the text in a stringstream.
3915 //   2. Then you stream the Message object to an ostream.
3916 //      This causes the text in the Message to be streamed
3917 //      to the ostream.
3918 //
3919 // For example;
3920 //
3921 //   testing::Message foo;
3922 //   foo << 1 << " != " << 2;
3923 //   std::cout << foo;
3924 //
3925 // will print "1 != 2".
3926 //
3927 // Message is not intended to be inherited from.  In particular, its
3928 // destructor is not virtual.
3929 //
3930 // Note that stringstream behaves differently in gcc and in MSVC.  You
3931 // can stream a NULL char pointer to it in the former, but not in the
3932 // latter (it causes an access violation if you do).  The Message
3933 // class hides this difference by treating a NULL char pointer as
3934 // "(null)".
3935 class GTEST_API_ Message {
3936  private:
3937   // The type of basic IO manipulators (endl, ends, and flush) for
3938   // narrow streams.
3939   typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
3940 
3941  public:
3942   // Constructs an empty Message.
3943   Message();
3944 
3945   // Copy constructor.
3946   Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT
3947     *ss_ << msg.GetString();
3948   }
3949 
3950   // Constructs a Message from a C-string.
3951   explicit Message(const char* str) : ss_(new ::std::stringstream) {
3952     *ss_ << str;
3953   }
3954 
3955 #if GTEST_OS_SYMBIAN
3956   // Streams a value (either a pointer or not) to this object.
3957   template <typename T>
3958   inline Message& operator <<(const T& value) {
3959     StreamHelper(typename internal::is_pointer<T>::type(), value);
3960     return *this;
3961   }
3962 #else
3963   // Streams a non-pointer value to this object.
3964   template <typename T>
3965   inline Message& operator <<(const T& val) {
3966     // Some libraries overload << for STL containers.  These
3967     // overloads are defined in the global namespace instead of ::std.
3968     //
3969     // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
3970     // overloads are visible in either the std namespace or the global
3971     // namespace, but not other namespaces, including the testing
3972     // namespace which Google Test's Message class is in.
3973     //
3974     // To allow STL containers (and other types that has a << operator
3975     // defined in the global namespace) to be used in Google Test
3976     // assertions, testing::Message must access the custom << operator
3977     // from the global namespace.  With this using declaration,
3978     // overloads of << defined in the global namespace and those
3979     // visible via Koenig lookup are both exposed in this function.
3980     using ::operator <<;
3981     *ss_ << val;
3982     return *this;
3983   }
3984 
3985   // Streams a pointer value to this object.
3986   //
3987   // This function is an overload of the previous one.  When you
3988   // stream a pointer to a Message, this definition will be used as it
3989   // is more specialized.  (The C++ Standard, section
3990   // [temp.func.order].)  If you stream a non-pointer, then the
3991   // previous definition will be used.
3992   //
3993   // The reason for this overload is that streaming a NULL pointer to
3994   // ostream is undefined behavior.  Depending on the compiler, you
3995   // may get "0", "(nil)", "(null)", or an access violation.  To
3996   // ensure consistent result across compilers, we always treat NULL
3997   // as "(null)".
3998   template <typename T>
3999   inline Message& operator <<(T* const& pointer) {  // NOLINT
4000     if (pointer == NULL) {
4001       *ss_ << "(null)";
4002     } else {
4003       *ss_ << pointer;
4004     }
4005     return *this;
4006   }
4007 #endif  // GTEST_OS_SYMBIAN
4008 
4009   // Since the basic IO manipulators are overloaded for both narrow
4010   // and wide streams, we have to provide this specialized definition
4011   // of operator <<, even though its body is the same as the
4012   // templatized version above.  Without this definition, streaming
4013   // endl or other basic IO manipulators to Message will confuse the
4014   // compiler.
4015   Message& operator <<(BasicNarrowIoManip val) {
4016     *ss_ << val;
4017     return *this;
4018   }
4019 
4020   // Instead of 1/0, we want to see true/false for bool values.
4021   Message& operator <<(bool b) {
4022     return *this << (b ? "true" : "false");
4023   }
4024 
4025   // These two overloads allow streaming a wide C string to a Message
4026   // using the UTF-8 encoding.
4027   Message& operator <<(const wchar_t* wide_c_str);
4028   Message& operator <<(wchar_t* wide_c_str);
4029 
4030 #if GTEST_HAS_STD_WSTRING
4031   // Converts the given wide string to a narrow string using the UTF-8
4032   // encoding, and streams the result to this Message object.
4033   Message& operator <<(const ::std::wstring& wstr);
4034 #endif  // GTEST_HAS_STD_WSTRING
4035 
4036 #if GTEST_HAS_GLOBAL_WSTRING
4037   // Converts the given wide string to a narrow string using the UTF-8
4038   // encoding, and streams the result to this Message object.
4039   Message& operator <<(const ::wstring& wstr);
4040 #endif  // GTEST_HAS_GLOBAL_WSTRING
4041 
4042   // Gets the text streamed to this object so far as an std::string.
4043   // Each '\0' character in the buffer is replaced with "\\0".
4044   //
4045   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
4046   std::string GetString() const;
4047 
4048  private:
4049 
4050 #if GTEST_OS_SYMBIAN
4051   // These are needed as the Nokia Symbian Compiler cannot decide between
4052   // const T& and const T* in a function template. The Nokia compiler _can_
4053   // decide between class template specializations for T and T*, so a
4054   // tr1::type_traits-like is_pointer works, and we can overload on that.
4055   template <typename T>
4056   inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {
4057     if (pointer == NULL) {
4058       *ss_ << "(null)";
4059     } else {
4060       *ss_ << pointer;
4061     }
4062   }
4063   template <typename T>
4064   inline void StreamHelper(internal::false_type /*is_pointer*/,
4065                            const T& value) {
4066     // See the comments in Message& operator <<(const T&) above for why
4067     // we need this using statement.
4068     using ::operator <<;
4069     *ss_ << value;
4070   }
4071 #endif  // GTEST_OS_SYMBIAN
4072 
4073   // We'll hold the text streamed to this object here.
4074   const internal::scoped_ptr< ::std::stringstream> ss_;
4075 
4076   // We declare (but don't implement) this to prevent the compiler
4077   // from implementing the assignment operator.
4078   void operator=(const Message&);
4079 };
4080 
4081 // Streams a Message to an ostream.
4082 inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
4083   return os << sb.GetString();
4084 }
4085 
4086 namespace internal {
4087 
4088 // Converts a streamable value to an std::string.  A NULL pointer is
4089 // converted to "(null)".  When the input value is a ::string,
4090 // ::std::string, ::wstring, or ::std::wstring object, each NUL
4091 // character in it is replaced with "\\0".
4092 template <typename T>
4093 std::string StreamableToString(const T& streamable) {
4094   return (Message() << streamable).GetString();
4095 }
4096 
4097 }  // namespace internal
4098 }  // namespace testing
4099 
4100 #endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
4101 // Copyright 2005, Google Inc.
4102 // All rights reserved.
4103 //
4104 // Redistribution and use in source and binary forms, with or without
4105 // modification, are permitted provided that the following conditions are
4106 // met:
4107 //
4108 //     * Redistributions of source code must retain the above copyright
4109 // notice, this list of conditions and the following disclaimer.
4110 //     * Redistributions in binary form must reproduce the above
4111 // copyright notice, this list of conditions and the following disclaimer
4112 // in the documentation and/or other materials provided with the
4113 // distribution.
4114 //     * Neither the name of Google Inc. nor the names of its
4115 // contributors may be used to endorse or promote products derived from
4116 // this software without specific prior written permission.
4117 //
4118 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4119 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4120 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4121 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4122 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4123 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4124 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4125 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4126 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4127 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4128 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4129 //
4130 // Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
4131 //
4132 // The Google C++ Testing Framework (Google Test)
4133 //
4134 // This header file declares the String class and functions used internally by
4135 // Google Test.  They are subject to change without notice. They should not used
4136 // by code external to Google Test.
4137 //
4138 // This header file is #included by <gtest/internal/gtest-internal.h>.
4139 // It should not be #included by other files.
4140 
4141 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
4142 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
4143 
4144 #ifdef __BORLANDC__
4145 // string.h is not guaranteed to provide strcpy on C++ Builder.
4146 # include <mem.h>
4147 #endif
4148 
4149 #include <string.h>
4150 #include <string>
4151 
4152 
4153 namespace testing {
4154 namespace internal {
4155 
4156 // String - an abstract class holding static string utilities.
4157 class GTEST_API_ String {
4158  public:
4159   // Static utility methods
4160 
4161   // Clones a 0-terminated C string, allocating memory using new.  The
4162   // caller is responsible for deleting the return value using
4163   // delete[].  Returns the cloned string, or NULL if the input is
4164   // NULL.
4165   //
4166   // This is different from strdup() in string.h, which allocates
4167   // memory using malloc().
4168   static const char* CloneCString(const char* c_str);
4169 
4170 #if GTEST_OS_WINDOWS_MOBILE
4171   // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
4172   // able to pass strings to Win32 APIs on CE we need to convert them
4173   // to 'Unicode', UTF-16.
4174 
4175   // Creates a UTF-16 wide string from the given ANSI string, allocating
4176   // memory using new. The caller is responsible for deleting the return
4177   // value using delete[]. Returns the wide string, or NULL if the
4178   // input is NULL.
4179   //
4180   // The wide string is created using the ANSI codepage (CP_ACP) to
4181   // match the behaviour of the ANSI versions of Win32 calls and the
4182   // C runtime.
4183   static LPCWSTR AnsiToUtf16(const char* c_str);
4184 
4185   // Creates an ANSI string from the given wide string, allocating
4186   // memory using new. The caller is responsible for deleting the return
4187   // value using delete[]. Returns the ANSI string, or NULL if the
4188   // input is NULL.
4189   //
4190   // The returned string is created using the ANSI codepage (CP_ACP) to
4191   // match the behaviour of the ANSI versions of Win32 calls and the
4192   // C runtime.
4193   static const char* Utf16ToAnsi(LPCWSTR utf16_str);
4194 #endif
4195 
4196   // Compares two C strings.  Returns true iff they have the same content.
4197   //
4198   // Unlike strcmp(), this function can handle NULL argument(s).  A
4199   // NULL C string is considered different to any non-NULL C string,
4200   // including the empty string.
4201   static bool CStringEquals(const char* lhs, const char* rhs);
4202 
4203   // Converts a wide C string to a String using the UTF-8 encoding.
4204   // NULL will be converted to "(null)".  If an error occurred during
4205   // the conversion, "(failed to convert from wide string)" is
4206   // returned.
4207   static std::string ShowWideCString(const wchar_t* wide_c_str);
4208 
4209   // Compares two wide C strings.  Returns true iff they have the same
4210   // content.
4211   //
4212   // Unlike wcscmp(), this function can handle NULL argument(s).  A
4213   // NULL C string is considered different to any non-NULL C string,
4214   // including the empty string.
4215   static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
4216 
4217   // Compares two C strings, ignoring case.  Returns true iff they
4218   // have the same content.
4219   //
4220   // Unlike strcasecmp(), this function can handle NULL argument(s).
4221   // A NULL C string is considered different to any non-NULL C string,
4222   // including the empty string.
4223   static bool CaseInsensitiveCStringEquals(const char* lhs,
4224                                            const char* rhs);
4225 
4226   // Compares two wide C strings, ignoring case.  Returns true iff they
4227   // have the same content.
4228   //
4229   // Unlike wcscasecmp(), this function can handle NULL argument(s).
4230   // A NULL C string is considered different to any non-NULL wide C string,
4231   // including the empty string.
4232   // NB: The implementations on different platforms slightly differ.
4233   // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
4234   // environment variable. On GNU platform this method uses wcscasecmp
4235   // which compares according to LC_CTYPE category of the current locale.
4236   // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
4237   // current locale.
4238   static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
4239                                                const wchar_t* rhs);
4240 
4241   // Returns true iff the given string ends with the given suffix, ignoring
4242   // case. Any string is considered to end with an empty suffix.
4243   static bool EndsWithCaseInsensitive(
4244       const std::string& str, const std::string& suffix);
4245 
4246   // Formats an int value as "%02d".
4247   static std::string FormatIntWidth2(int value);  // "%02d" for width == 2
4248 
4249   // Formats an int value as "%X".
4250   static std::string FormatHexInt(int value);
4251 
4252   // Formats a byte as "%02X".
4253   static std::string FormatByte(unsigned char value);
4254 
4255  private:
4256   String();  // Not meant to be instantiated.
4257 };  // class String
4258 
4259 // Gets the content of the stringstream's buffer as an std::string.  Each '\0'
4260 // character in the buffer is replaced with "\\0".
4261 GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
4262 
4263 }  // namespace internal
4264 }  // namespace testing
4265 
4266 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
4267 // Copyright 2008, Google Inc.
4268 // All rights reserved.
4269 //
4270 // Redistribution and use in source and binary forms, with or without
4271 // modification, are permitted provided that the following conditions are
4272 // met:
4273 //
4274 //     * Redistributions of source code must retain the above copyright
4275 // notice, this list of conditions and the following disclaimer.
4276 //     * Redistributions in binary form must reproduce the above
4277 // copyright notice, this list of conditions and the following disclaimer
4278 // in the documentation and/or other materials provided with the
4279 // distribution.
4280 //     * Neither the name of Google Inc. nor the names of its
4281 // contributors may be used to endorse or promote products derived from
4282 // this software without specific prior written permission.
4283 //
4284 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4285 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4286 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4287 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4288 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4289 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4290 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4291 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4292 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4293 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4294 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4295 //
4296 // Author: keith.ray@gmail.com (Keith Ray)
4297 //
4298 // Google Test filepath utilities
4299 //
4300 // This header file declares classes and functions used internally by
4301 // Google Test.  They are subject to change without notice.
4302 //
4303 // This file is #included in <gtest/internal/gtest-internal.h>.
4304 // Do not include this header file separately!
4305 
4306 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
4307 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
4308 
4309 
4310 namespace testing {
4311 namespace internal {
4312 
4313 // FilePath - a class for file and directory pathname manipulation which
4314 // handles platform-specific conventions (like the pathname separator).
4315 // Used for helper functions for naming files in a directory for xml output.
4316 // Except for Set methods, all methods are const or static, which provides an
4317 // "immutable value object" -- useful for peace of mind.
4318 // A FilePath with a value ending in a path separator ("like/this/") represents
4319 // a directory, otherwise it is assumed to represent a file. In either case,
4320 // it may or may not represent an actual file or directory in the file system.
4321 // Names are NOT checked for syntax correctness -- no checking for illegal
4322 // characters, malformed paths, etc.
4323 
4324 class GTEST_API_ FilePath {
4325  public:
4326   FilePath() : pathname_("") { }
4327   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
4328 
4329   explicit FilePath(const std::string& pathname) : pathname_(pathname) {
4330     Normalize();
4331   }
4332 
4333   FilePath& operator=(const FilePath& rhs) {
4334     Set(rhs);
4335     return *this;
4336   }
4337 
4338   void Set(const FilePath& rhs) {
4339     pathname_ = rhs.pathname_;
4340   }
4341 
4342   const std::string& string() const { return pathname_; }
4343   const char* c_str() const { return pathname_.c_str(); }
4344 
4345   // Returns the current working directory, or "" if unsuccessful.
4346   static FilePath GetCurrentDir();
4347 
4348   // Given directory = "dir", base_name = "test", number = 0,
4349   // extension = "xml", returns "dir/test.xml". If number is greater
4350   // than zero (e.g., 12), returns "dir/test_12.xml".
4351   // On Windows platform, uses \ as the separator rather than /.
4352   static FilePath MakeFileName(const FilePath& directory,
4353                                const FilePath& base_name,
4354                                int number,
4355                                const char* extension);
4356 
4357   // Given directory = "dir", relative_path = "test.xml",
4358   // returns "dir/test.xml".
4359   // On Windows, uses \ as the separator rather than /.
4360   static FilePath ConcatPaths(const FilePath& directory,
4361                               const FilePath& relative_path);
4362 
4363   // Returns a pathname for a file that does not currently exist. The pathname
4364   // will be directory/base_name.extension or
4365   // directory/base_name_<number>.extension if directory/base_name.extension
4366   // already exists. The number will be incremented until a pathname is found
4367   // that does not already exist.
4368   // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
4369   // There could be a race condition if two or more processes are calling this
4370   // function at the same time -- they could both pick the same filename.
4371   static FilePath GenerateUniqueFileName(const FilePath& directory,
4372                                          const FilePath& base_name,
4373                                          const char* extension);
4374 
4375   // Returns true iff the path is "".
4376   bool IsEmpty() const { return pathname_.empty(); }
4377 
4378   // If input name has a trailing separator character, removes it and returns
4379   // the name, otherwise return the name string unmodified.
4380   // On Windows platform, uses \ as the separator, other platforms use /.
4381   FilePath RemoveTrailingPathSeparator() const;
4382 
4383   // Returns a copy of the FilePath with the directory part removed.
4384   // Example: FilePath("path/to/file").RemoveDirectoryName() returns
4385   // FilePath("file"). If there is no directory part ("just_a_file"), it returns
4386   // the FilePath unmodified. If there is no file part ("just_a_dir/") it
4387   // returns an empty FilePath ("").
4388   // On Windows platform, '\' is the path separator, otherwise it is '/'.
4389   FilePath RemoveDirectoryName() const;
4390 
4391   // RemoveFileName returns the directory path with the filename removed.
4392   // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
4393   // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
4394   // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
4395   // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
4396   // On Windows platform, '\' is the path separator, otherwise it is '/'.
4397   FilePath RemoveFileName() const;
4398 
4399   // Returns a copy of the FilePath with the case-insensitive extension removed.
4400   // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
4401   // FilePath("dir/file"). If a case-insensitive extension is not
4402   // found, returns a copy of the original FilePath.
4403   FilePath RemoveExtension(const char* extension) const;
4404 
4405   // Creates directories so that path exists. Returns true if successful or if
4406   // the directories already exist; returns false if unable to create
4407   // directories for any reason. Will also return false if the FilePath does
4408   // not represent a directory (that is, it doesn't end with a path separator).
4409   bool CreateDirectoriesRecursively() const;
4410 
4411   // Create the directory so that path exists. Returns true if successful or
4412   // if the directory already exists; returns false if unable to create the
4413   // directory for any reason, including if the parent directory does not
4414   // exist. Not named "CreateDirectory" because that's a macro on Windows.
4415   bool CreateFolder() const;
4416 
4417   // Returns true if FilePath describes something in the file-system,
4418   // either a file, directory, or whatever, and that something exists.
4419   bool FileOrDirectoryExists() const;
4420 
4421   // Returns true if pathname describes a directory in the file-system
4422   // that exists.
4423   bool DirectoryExists() const;
4424 
4425   // Returns true if FilePath ends with a path separator, which indicates that
4426   // it is intended to represent a directory. Returns false otherwise.
4427   // This does NOT check that a directory (or file) actually exists.
4428   bool IsDirectory() const;
4429 
4430   // Returns true if pathname describes a root directory. (Windows has one
4431   // root directory per disk drive.)
4432   bool IsRootDirectory() const;
4433 
4434   // Returns true if pathname describes an absolute path.
4435   bool IsAbsolutePath() const;
4436 
4437  private:
4438   // Replaces multiple consecutive separators with a single separator.
4439   // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
4440   // redundancies that might be in a pathname involving "." or "..".
4441   //
4442   // A pathname with multiple consecutive separators may occur either through
4443   // user error or as a result of some scripts or APIs that generate a pathname
4444   // with a trailing separator. On other platforms the same API or script
4445   // may NOT generate a pathname with a trailing "/". Then elsewhere that
4446   // pathname may have another "/" and pathname components added to it,
4447   // without checking for the separator already being there.
4448   // The script language and operating system may allow paths like "foo//bar"
4449   // but some of the functions in FilePath will not handle that correctly. In
4450   // particular, RemoveTrailingPathSeparator() only removes one separator, and
4451   // it is called in CreateDirectoriesRecursively() assuming that it will change
4452   // a pathname from directory syntax (trailing separator) to filename syntax.
4453   //
4454   // On Windows this method also replaces the alternate path separator '/' with
4455   // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
4456   // "bar\\foo".
4457 
4458   void Normalize();
4459 
4460   // Returns a pointer to the last occurence of a valid path separator in
4461   // the FilePath. On Windows, for example, both '/' and '\' are valid path
4462   // separators. Returns NULL if no path separator was found.
4463   const char* FindLastPathSeparator() const;
4464 
4465   std::string pathname_;
4466 };  // class FilePath
4467 
4468 }  // namespace internal
4469 }  // namespace testing
4470 
4471 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
4472 // This file was GENERATED by command:
4473 //     pump.py gtest-type-util.h.pump
4474 // DO NOT EDIT BY HAND!!!
4475 
4476 // Copyright 2008 Google Inc.
4477 // All Rights Reserved.
4478 //
4479 // Redistribution and use in source and binary forms, with or without
4480 // modification, are permitted provided that the following conditions are
4481 // met:
4482 //
4483 //     * Redistributions of source code must retain the above copyright
4484 // notice, this list of conditions and the following disclaimer.
4485 //     * Redistributions in binary form must reproduce the above
4486 // copyright notice, this list of conditions and the following disclaimer
4487 // in the documentation and/or other materials provided with the
4488 // distribution.
4489 //     * Neither the name of Google Inc. nor the names of its
4490 // contributors may be used to endorse or promote products derived from
4491 // this software without specific prior written permission.
4492 //
4493 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4494 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4495 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4496 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4497 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4498 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4499 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4500 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4501 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4502 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4503 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4504 //
4505 // Author: wan@google.com (Zhanyong Wan)
4506 
4507 // Type utilities needed for implementing typed and type-parameterized
4508 // tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
4509 //
4510 // Currently we support at most 50 types in a list, and at most 50
4511 // type-parameterized tests in one type-parameterized test case.
4512 // Please contact googletestframework@googlegroups.com if you need
4513 // more.
4514 
4515 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
4516 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
4517 
4518 
4519 // #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
4520 // libstdc++ (which is where cxxabi.h comes from).
4521 # if GTEST_HAS_CXXABI_H_
4522 #  include <cxxabi.h>
4523 # elif defined(__HP_aCC)
4524 #  include <acxx_demangle.h>
4525 # endif  // GTEST_HASH_CXXABI_H_
4526 
4527 namespace testing {
4528 namespace internal {
4529 
4530 // GetTypeName<T>() returns a human-readable name of type T.
4531 // NB: This function is also used in Google Mock, so don't move it inside of
4532 // the typed-test-only section below.
4533 template <typename T>
4534 std::string GetTypeName() {
4535 # if GTEST_HAS_RTTI
4536 
4537   const char* const name = typeid(T).name();
4538 #  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
4539   int status = 0;
4540   // gcc's implementation of typeid(T).name() mangles the type name,
4541   // so we have to demangle it.
4542 #   if GTEST_HAS_CXXABI_H_
4543   using abi::__cxa_demangle;
4544 #   endif  // GTEST_HAS_CXXABI_H_
4545   char* const readable_name = __cxa_demangle(name, 0, 0, &status);
4546   const std::string name_str(status == 0 ? readable_name : name);
4547   free(readable_name);
4548   return name_str;
4549 #  else
4550   return name;
4551 #  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC
4552 
4553 # else
4554 
4555   return "<type>";
4556 
4557 # endif  // GTEST_HAS_RTTI
4558 }
4559 
4560 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
4561 
4562 // AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
4563 // type.  This can be used as a compile-time assertion to ensure that
4564 // two types are equal.
4565 
4566 template <typename T1, typename T2>
4567 struct AssertTypeEq;
4568 
4569 template <typename T>
4570 struct AssertTypeEq<T, T> {
4571   typedef bool type;
4572 };
4573 
4574 // A unique type used as the default value for the arguments of class
4575 // template Types.  This allows us to simulate variadic templates
4576 // (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
4577 // support directly.
4578 struct None {};
4579 
4580 // The following family of struct and struct templates are used to
4581 // represent type lists.  In particular, TypesN<T1, T2, ..., TN>
4582 // represents a type list with N types (T1, T2, ..., and TN) in it.
4583 // Except for Types0, every struct in the family has two member types:
4584 // Head for the first type in the list, and Tail for the rest of the
4585 // list.
4586 
4587 // The empty type list.
4588 struct Types0 {};
4589 
4590 
4591 }  // namespace internal
4592 
4593 // We don't want to require the users to write TypesN<...> directly,
4594 // as that would require them to count the length.  Types<...> is much
4595 // easier to write, but generates horrible messages when there is a
4596 // compiler error, as gcc insists on printing out each template
4597 // argument, even if it has the default value (this means Types<int>
4598 // will appear as Types<int, None, None, ..., None> in the compiler
4599 // errors).
4600 //
4601 // Our solution is to combine the best part of the two approaches: a
4602 // user would write Types<T1, ..., TN>, and Google Test will translate
4603 // that to TypesN<T1, ..., TN> internally to make error messages
4604 // readable.  The translation is done by the 'type' member of the
4605 // Types template.
4606 template <typename... T>
4607 struct Types;
4608 
4609 template <>
4610 struct Types<> {
4611   typedef internal::Types0 type;
4612 };
4613 
4614 template <typename T1, typename... T>
4615 struct Types<T1, T...> {
4616   struct type
4617   {
4618       typedef T1 Head;
4619       typedef typename Types<T...>::type Tail;
4620   };
4621 };
4622 
4623 namespace internal {
4624 
4625 # define GTEST_TEMPLATE_ template <typename T_> class
4626 
4627 // The template "selector" struct TemplateSel<Tmpl> is used to
4628 // represent Tmpl, which must be a class template with one type
4629 // parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined
4630 // as the type Tmpl<T>.  This allows us to actually instantiate the
4631 // template "selected" by TemplateSel<Tmpl>.
4632 //
4633 // This trick is necessary for simulating typedef for class templates,
4634 // which C++ doesn't support directly.
4635 template <GTEST_TEMPLATE_ Tmpl>
4636 struct TemplateSel {
4637   template <typename T>
4638   struct Bind {
4639     typedef Tmpl<T> type;
4640   };
4641 };
4642 
4643 # define GTEST_BIND_(TmplSel, T) \
4644   TmplSel::template Bind<T>::type
4645 
4646 // A unique struct template used as the default value for the
4647 // arguments of class template Templates.  This allows us to simulate
4648 // variadic templates (e.g. Templates<int>, Templates<int, double>,
4649 // and etc), which C++ doesn't support directly.
4650 template <typename T>
4651 struct NoneT {};
4652 
4653 // The following family of struct and struct templates are used to
4654 // represent template lists.  In particular, TemplatesN<T1, T2, ...,
4655 // TN> represents a list of N templates (T1, T2, ..., and TN).  Except
4656 // for Templates0, every struct in the family has two member types:
4657 // Head for the selector of the first template in the list, and Tail
4658 // for the rest of the list.
4659 
4660 // The empty template list.
4661 struct Templates0 {};
4662 
4663 
4664 // We don't want to require the users to write TemplatesN<...> directly,
4665 // as that would require them to count the length.  Templates<...> is much
4666 // easier to write, but generates horrible messages when there is a
4667 // compiler error, as gcc insists on printing out each template
4668 // argument, even if it has the default value (this means Templates<list>
4669 // will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
4670 // errors).
4671 //
4672 // Our solution is to combine the best part of the two approaches: a
4673 // user would write Templates<T1, ..., TN>, and Google Test will translate
4674 // that to TemplatesN<T1, ..., TN> internally to make error messages
4675 // readable.  The translation is done by the 'type' member of the
4676 // Templates template.
4677 template <GTEST_TEMPLATE_ ... T>
4678 struct Templates;
4679 
4680 template <>
4681 struct Templates<> {
4682   typedef Templates0 type;
4683 };
4684 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ ... T>
4685 struct Templates<T1, T...> {
4686   struct type
4687   {
4688       typedef TemplateSel<T1> Head;
4689       typedef typename Templates<T...>::type Tail;
4690   };
4691 };
4692 
4693 // The TypeList template makes it possible to use either a single type
4694 // or a Types<...> list in TYPED_TEST_CASE() and
4695 // INSTANTIATE_TYPED_TEST_CASE_P().
4696 
4697 template <typename T>
4698 struct TypeList {
4699   typedef typename Types<T>::type type;
4700 };
4701 
4702 template <typename... T>
4703 struct TypeList<Types<T...> > {
4704   typedef typename Types<T...>::type type;
4705 };
4706 
4707 #endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
4708 
4709 }  // namespace internal
4710 }  // namespace testing
4711 
4712 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
4713 
4714 // Due to C++ preprocessor weirdness, we need double indirection to
4715 // concatenate two tokens when one of them is __LINE__.  Writing
4716 //
4717 //   foo ## __LINE__
4718 //
4719 // will result in the token foo__LINE__, instead of foo followed by
4720 // the current line number.  For more details, see
4721 // http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
4722 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
4723 #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
4724 
4725 class ProtocolMessage;
4726 namespace proto2 { class Message; }
4727 
4728 namespace testing {
4729 
4730 // Forward declarations.
4731 
4732 class AssertionResult;                 // Result of an assertion.
4733 class Message;                         // Represents a failure message.
4734 class Test;                            // Represents a test.
4735 class TestInfo;                        // Information about a test.
4736 class TestPartResult;                  // Result of a test part.
4737 class UnitTest;                        // A collection of test cases.
4738 
4739 template <typename T>
4740 ::std::string PrintToString(const T& value);
4741 
4742 namespace internal {
4743 
4744 struct TraceInfo;                      // Information about a trace point.
4745 class ScopedTrace;                     // Implements scoped trace.
4746 class TestInfoImpl;                    // Opaque implementation of TestInfo
4747 class UnitTestImpl;                    // Opaque implementation of UnitTest
4748 
4749 // The text used in failure messages to indicate the start of the
4750 // stack trace.
4751 GTEST_API_ extern const char kStackTraceMarker[];
4752 
4753 // Two overloaded helpers for checking at compile time whether an
4754 // expression is a null pointer literal (i.e. NULL or any 0-valued
4755 // compile-time integral constant).  Their return values have
4756 // different sizes, so we can use sizeof() to test which version is
4757 // picked by the compiler.  These helpers have no implementations, as
4758 // we only need their signatures.
4759 //
4760 // Given IsNullLiteralHelper(x), the compiler will pick the first
4761 // version if x can be implicitly converted to Secret*, and pick the
4762 // second version otherwise.  Since Secret is a secret and incomplete
4763 // type, the only expression a user can write that has type Secret* is
4764 // a null pointer literal.  Therefore, we know that x is a null
4765 // pointer literal if and only if the first version is picked by the
4766 // compiler.
4767 char IsNullLiteralHelper(Secret* p);
4768 char (&IsNullLiteralHelper(...))[2];  // NOLINT
4769 
4770 // A compile-time bool constant that is true if and only if x is a
4771 // null pointer literal (i.e. NULL or any 0-valued compile-time
4772 // integral constant).
4773 #ifdef GTEST_ELLIPSIS_NEEDS_POD_
4774 // We lose support for NULL detection where the compiler doesn't like
4775 // passing non-POD classes through ellipsis (...).
4776 # define GTEST_IS_NULL_LITERAL_(x) false
4777 #else
4778 # define GTEST_IS_NULL_LITERAL_(x) \
4779     (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
4780 #endif  // GTEST_ELLIPSIS_NEEDS_POD_
4781 
4782 // Appends the user-supplied message to the Google-Test-generated message.
4783 GTEST_API_ std::string AppendUserMessage(
4784     const std::string& gtest_msg, const Message& user_msg);
4785 
4786 #if GTEST_HAS_EXCEPTIONS
4787 
4788 // This exception is thrown by (and only by) a failed Google Test
4789 // assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
4790 // are enabled).  We derive it from std::runtime_error, which is for
4791 // errors presumably detectable only at run time.  Since
4792 // std::runtime_error inherits from std::exception, many testing
4793 // frameworks know how to extract and print the message inside it.
4794 class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
4795  public:
4796   explicit GoogleTestFailureException(const TestPartResult& failure);
4797 };
4798 
4799 #endif  // GTEST_HAS_EXCEPTIONS
4800 
4801 // A helper class for creating scoped traces in user programs.
4802 class GTEST_API_ ScopedTrace {
4803  public:
4804   // The c'tor pushes the given source file location and message onto
4805   // a trace stack maintained by Google Test.
4806   ScopedTrace(const char* file, int line, const Message& message);
4807 
4808   // The d'tor pops the info pushed by the c'tor.
4809   //
4810   // Note that the d'tor is not virtual in order to be efficient.
4811   // Don't inherit from ScopedTrace!
4812   ~ScopedTrace();
4813 
4814  private:
4815   GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
4816 } GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its
4817                             // c'tor and d'tor.  Therefore it doesn't
4818                             // need to be used otherwise.
4819 
4820 namespace edit_distance {
4821 // Returns the optimal edits to go from 'left' to 'right'.
4822 // All edits cost the same, with replace having lower priority than
4823 // add/remove.
4824 // Simple implementation of the Wagner–Fischer algorithm.
4825 // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
4826 enum EditType { kMatch, kAdd, kRemove, kReplace };
4827 GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
4828     const std::vector<size_t>& left, const std::vector<size_t>& right);
4829 
4830 // Same as above, but the input is represented as strings.
4831 GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
4832     const std::vector<std::string>& left,
4833     const std::vector<std::string>& right);
4834 
4835 // Create a diff of the input strings in Unified diff format.
4836 GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
4837                                          const std::vector<std::string>& right,
4838                                          size_t context = 2);
4839 
4840 }  // namespace edit_distance
4841 
4842 // Calculate the diff between 'left' and 'right' and return it in unified diff
4843 // format.
4844 // If not null, stores in 'total_line_count' the total number of lines found
4845 // in left + right.
4846 GTEST_API_ std::string DiffStrings(const std::string& left,
4847                                    const std::string& right,
4848                                    size_t* total_line_count);
4849 
4850 // Constructs and returns the message for an equality assertion
4851 // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
4852 //
4853 // The first four parameters are the expressions used in the assertion
4854 // and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
4855 // where foo is 5 and bar is 6, we have:
4856 //
4857 //   expected_expression: "foo"
4858 //   actual_expression:   "bar"
4859 //   expected_value:      "5"
4860 //   actual_value:        "6"
4861 //
4862 // The ignoring_case parameter is true iff the assertion is a
4863 // *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
4864 // be inserted into the message.
4865 GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
4866                                      const char* actual_expression,
4867                                      const std::string& expected_value,
4868                                      const std::string& actual_value,
4869                                      bool ignoring_case);
4870 
4871 // Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
4872 GTEST_API_ std::string GetBoolAssertionFailureMessage(
4873     const AssertionResult& assertion_result,
4874     const char* expression_text,
4875     const char* actual_predicate_value,
4876     const char* expected_predicate_value);
4877 
4878 // This template class represents an IEEE floating-point number
4879 // (either single-precision or double-precision, depending on the
4880 // template parameters).
4881 //
4882 // The purpose of this class is to do more sophisticated number
4883 // comparison.  (Due to round-off error, etc, it's very unlikely that
4884 // two floating-points will be equal exactly.  Hence a naive
4885 // comparison by the == operation often doesn't work.)
4886 //
4887 // Format of IEEE floating-point:
4888 //
4889 //   The most-significant bit being the leftmost, an IEEE
4890 //   floating-point looks like
4891 //
4892 //     sign_bit exponent_bits fraction_bits
4893 //
4894 //   Here, sign_bit is a single bit that designates the sign of the
4895 //   number.
4896 //
4897 //   For float, there are 8 exponent bits and 23 fraction bits.
4898 //
4899 //   For double, there are 11 exponent bits and 52 fraction bits.
4900 //
4901 //   More details can be found at
4902 //   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
4903 //
4904 // Template parameter:
4905 //
4906 //   RawType: the raw floating-point type (either float or double)
4907 template <typename RawType>
4908 class FloatingPoint {
4909  public:
4910   // Defines the unsigned integer type that has the same size as the
4911   // floating point number.
4912   typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
4913 
4914   // Constants.
4915 
4916   // # of bits in a number.
4917   static const size_t kBitCount = 8*sizeof(RawType);
4918 
4919   // # of fraction bits in a number.
4920   static const size_t kFractionBitCount =
4921     std::numeric_limits<RawType>::digits - 1;
4922 
4923   // # of exponent bits in a number.
4924   static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
4925 
4926   // The mask for the sign bit.
4927   static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
4928 
4929   // The mask for the fraction bits.
4930   static const Bits kFractionBitMask =
4931     ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
4932 
4933   // The mask for the exponent bits.
4934   static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
4935 
4936   // How many ULP's (Units in the Last Place) we want to tolerate when
4937   // comparing two numbers.  The larger the value, the more error we
4938   // allow.  A 0 value means that two numbers must be exactly the same
4939   // to be considered equal.
4940   //
4941   // The maximum error of a single floating-point operation is 0.5
4942   // units in the last place.  On Intel CPU's, all floating-point
4943   // calculations are done with 80-bit precision, while double has 64
4944   // bits.  Therefore, 4 should be enough for ordinary use.
4945   //
4946   // See the following article for more details on ULP:
4947   // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
4948   static const size_t kMaxUlps = 4;
4949 
4950   // Constructs a FloatingPoint from a raw floating-point number.
4951   //
4952   // On an Intel CPU, passing a non-normalized NAN (Not a Number)
4953   // around may change its bits, although the new value is guaranteed
4954   // to be also a NAN.  Therefore, don't expect this constructor to
4955   // preserve the bits in x when x is a NAN.
4956   explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
4957 
4958   // Static methods
4959 
4960   // Reinterprets a bit pattern as a floating-point number.
4961   //
4962   // This function is needed to test the AlmostEquals() method.
4963   static RawType ReinterpretBits(const Bits bits) {
4964     FloatingPoint fp(0);
4965     fp.u_.bits_ = bits;
4966     return fp.u_.value_;
4967   }
4968 
4969   // Returns the floating-point number that represent positive infinity.
4970   static RawType Infinity() {
4971     return ReinterpretBits(kExponentBitMask);
4972   }
4973 
4974   // Returns the maximum representable finite floating-point number.
4975   static RawType Max();
4976 
4977   // Non-static methods
4978 
4979   // Returns the bits that represents this number.
4980   const Bits &bits() const { return u_.bits_; }
4981 
4982   // Returns the exponent bits of this number.
4983   Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
4984 
4985   // Returns the fraction bits of this number.
4986   Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
4987 
4988   // Returns the sign bit of this number.
4989   Bits sign_bit() const { return kSignBitMask & u_.bits_; }
4990 
4991   // Returns true iff this is NAN (not a number).
4992   bool is_nan() const {
4993     // It's a NAN if the exponent bits are all ones and the fraction
4994     // bits are not entirely zeros.
4995     return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
4996   }
4997 
4998   // Returns true iff this number is at most kMaxUlps ULP's away from
4999   // rhs.  In particular, this function:
5000   //
5001   //   - returns false if either number is (or both are) NAN.
5002   //   - treats really large numbers as almost equal to infinity.
5003   //   - thinks +0.0 and -0.0 are 0 DLP's apart.
5004   bool AlmostEquals(const FloatingPoint& rhs) const {
5005     // The IEEE standard says that any comparison operation involving
5006     // a NAN must return false.
5007     if (is_nan() || rhs.is_nan()) return false;
5008 
5009     return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
5010         <= kMaxUlps;
5011   }
5012 
5013  private:
5014   // The data type used to store the actual floating-point number.
5015   union FloatingPointUnion {
5016     RawType value_;  // The raw floating-point number.
5017     Bits bits_;      // The bits that represent the number.
5018   };
5019 
5020   // Converts an integer from the sign-and-magnitude representation to
5021   // the biased representation.  More precisely, let N be 2 to the
5022   // power of (kBitCount - 1), an integer x is represented by the
5023   // unsigned number x + N.
5024   //
5025   // For instance,
5026   //
5027   //   -N + 1 (the most negative number representable using
5028   //          sign-and-magnitude) is represented by 1;
5029   //   0      is represented by N; and
5030   //   N - 1  (the biggest number representable using
5031   //          sign-and-magnitude) is represented by 2N - 1.
5032   //
5033   // Read http://en.wikipedia.org/wiki/Signed_number_representations
5034   // for more details on signed number representations.
5035   static Bits SignAndMagnitudeToBiased(const Bits &sam) {
5036     if (kSignBitMask & sam) {
5037       // sam represents a negative number.
5038       return ~sam + 1;
5039     } else {
5040       // sam represents a positive number.
5041       return kSignBitMask | sam;
5042     }
5043   }
5044 
5045   // Given two numbers in the sign-and-magnitude representation,
5046   // returns the distance between them as an unsigned number.
5047   static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
5048                                                      const Bits &sam2) {
5049     const Bits biased1 = SignAndMagnitudeToBiased(sam1);
5050     const Bits biased2 = SignAndMagnitudeToBiased(sam2);
5051     return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
5052   }
5053 
5054   FloatingPointUnion u_;
5055 };
5056 
5057 // We cannot use std::numeric_limits<T>::max() as it clashes with the max()
5058 // macro defined by <windows.h>.
5059 template <>
5060 inline float FloatingPoint<float>::Max() { return FLT_MAX; }
5061 template <>
5062 inline double FloatingPoint<double>::Max() { return DBL_MAX; }
5063 
5064 // Typedefs the instances of the FloatingPoint template class that we
5065 // care to use.
5066 typedef FloatingPoint<float> Float;
5067 typedef FloatingPoint<double> Double;
5068 
5069 // In order to catch the mistake of putting tests that use different
5070 // test fixture classes in the same test case, we need to assign
5071 // unique IDs to fixture classes and compare them.  The TypeId type is
5072 // used to hold such IDs.  The user should treat TypeId as an opaque
5073 // type: the only operation allowed on TypeId values is to compare
5074 // them for equality using the == operator.
5075 typedef const void* TypeId;
5076 
5077 template <typename T>
5078 class TypeIdHelper {
5079  public:
5080   // dummy_ must not have a const type.  Otherwise an overly eager
5081   // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
5082   // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
5083   static bool dummy_;
5084 };
5085 
5086 template <typename T>
5087 bool TypeIdHelper<T>::dummy_ = false;
5088 
5089 // GetTypeId<T>() returns the ID of type T.  Different values will be
5090 // returned for different types.  Calling the function twice with the
5091 // same type argument is guaranteed to return the same ID.
5092 template <typename T>
5093 TypeId GetTypeId() {
5094   // The compiler is required to allocate a different
5095   // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
5096   // the template.  Therefore, the address of dummy_ is guaranteed to
5097   // be unique.
5098   return &(TypeIdHelper<T>::dummy_);
5099 }
5100 
5101 // Returns the type ID of ::testing::Test.  Always call this instead
5102 // of GetTypeId< ::testing::Test>() to get the type ID of
5103 // ::testing::Test, as the latter may give the wrong result due to a
5104 // suspected linker bug when compiling Google Test as a Mac OS X
5105 // framework.
5106 GTEST_API_ TypeId GetTestTypeId();
5107 
5108 // Defines the abstract factory interface that creates instances
5109 // of a Test object.
5110 class TestFactoryBase {
5111  public:
5112   virtual ~TestFactoryBase() {}
5113 
5114   // Creates a test instance to run. The instance is both created and destroyed
5115   // within TestInfoImpl::Run()
5116   virtual Test* CreateTest() = 0;
5117 
5118  protected:
5119   TestFactoryBase() {}
5120 
5121  private:
5122   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
5123 };
5124 
5125 // This class provides implementation of TeastFactoryBase interface.
5126 // It is used in TEST and TEST_F macros.
5127 template <class TestClass>
5128 class TestFactoryImpl : public TestFactoryBase {
5129  public:
5130   virtual Test* CreateTest() { return new TestClass; }
5131 };
5132 
5133 #if GTEST_OS_WINDOWS
5134 
5135 // Predicate-formatters for implementing the HRESULT checking macros
5136 // {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
5137 // We pass a long instead of HRESULT to avoid causing an
5138 // include dependency for the HRESULT type.
5139 GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
5140                                             long hr);  // NOLINT
5141 GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
5142                                             long hr);  // NOLINT
5143 
5144 #endif  // GTEST_OS_WINDOWS
5145 
5146 // Types of SetUpTestCase() and TearDownTestCase() functions.
5147 typedef void (*SetUpTestCaseFunc)();
5148 typedef void (*TearDownTestCaseFunc)();
5149 
5150 struct CodeLocation {
5151   CodeLocation(const string& a_file, int a_line) : file(a_file), line(a_line) {}
5152 
5153   string file;
5154   int line;
5155 };
5156 
5157 // Creates a new TestInfo object and registers it with Google Test;
5158 // returns the created object.
5159 //
5160 // Arguments:
5161 //
5162 //   test_case_name:   name of the test case
5163 //   name:             name of the test
5164 //   type_param        the name of the test's type parameter, or NULL if
5165 //                     this is not a typed or a type-parameterized test.
5166 //   value_param       text representation of the test's value parameter,
5167 //                     or NULL if this is not a type-parameterized test.
5168 //   code_location:    code location where the test is defined
5169 //   fixture_class_id: ID of the test fixture class
5170 //   set_up_tc:        pointer to the function that sets up the test case
5171 //   tear_down_tc:     pointer to the function that tears down the test case
5172 //   factory:          pointer to the factory that creates a test object.
5173 //                     The newly created TestInfo instance will assume
5174 //                     ownership of the factory object.
5175 GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
5176     const char* test_case_name,
5177     const char* name,
5178     const char* type_param,
5179     const char* value_param,
5180     CodeLocation code_location,
5181     TypeId fixture_class_id,
5182     SetUpTestCaseFunc set_up_tc,
5183     TearDownTestCaseFunc tear_down_tc,
5184     TestFactoryBase* factory);
5185 
5186 // If *pstr starts with the given prefix, modifies *pstr to be right
5187 // past the prefix and returns true; otherwise leaves *pstr unchanged
5188 // and returns false.  None of pstr, *pstr, and prefix can be NULL.
5189 GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
5190 
5191 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
5192 
5193 // State of the definition of a type-parameterized test case.
5194 class GTEST_API_ TypedTestCasePState {
5195  public:
5196   TypedTestCasePState() : registered_(false) {}
5197 
5198   // Adds the given test name to defined_test_names_ and return true
5199   // if the test case hasn't been registered; otherwise aborts the
5200   // program.
5201   bool AddTestName(const char* file, int line, const char* case_name,
5202                    const char* test_name) {
5203     if (registered_) {
5204       fprintf(stderr, "%s Test %s must be defined before "
5205               "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
5206               FormatFileLocation(file, line).c_str(), test_name, case_name);
5207       fflush(stderr);
5208       posix::Abort();
5209     }
5210     registered_tests_.insert(
5211         ::std::make_pair(test_name, CodeLocation(file, line)));
5212     return true;
5213   }
5214 
5215   bool TestExists(const std::string& test_name) const {
5216     return registered_tests_.count(test_name) > 0;
5217   }
5218 
5219   const CodeLocation& GetCodeLocation(const std::string& test_name) const {
5220     RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
5221     GTEST_CHECK_(it != registered_tests_.end());
5222     return it->second;
5223   }
5224 
5225   // Verifies that registered_tests match the test names in
5226   // defined_test_names_; returns registered_tests if successful, or
5227   // aborts the program otherwise.
5228   const char* VerifyRegisteredTestNames(
5229       const char* file, int line, const char* registered_tests);
5230 
5231  private:
5232   typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
5233 
5234   bool registered_;
5235   RegisteredTestsMap registered_tests_;
5236 };
5237 
5238 // Skips to the first non-space char after the first comma in 'str';
5239 // returns NULL if no comma is found in 'str'.
5240 inline const char* SkipComma(const char* str) {
5241   const char* comma = strchr(str, ',');
5242   if (comma == NULL) {
5243     return NULL;
5244   }
5245   while (IsSpace(*(++comma))) {}
5246   return comma;
5247 }
5248 
5249 // Returns the prefix of 'str' before the first comma in it; returns
5250 // the entire string if it contains no comma.
5251 inline std::string GetPrefixUntilComma(const char* str) {
5252   const char* comma = strchr(str, ',');
5253   return comma == NULL ? str : std::string(str, comma);
5254 }
5255 
5256 // Splits a given string on a given delimiter, populating a given
5257 // vector with the fields.
5258 void SplitString(const ::std::string& str, char delimiter,
5259                  ::std::vector< ::std::string>* dest);
5260 
5261 // TypeParameterizedTest<Fixture, TestSel, Types>::Register()
5262 // registers a list of type-parameterized tests with Google Test.  The
5263 // return value is insignificant - we just need to return something
5264 // such that we can call this function in a namespace scope.
5265 //
5266 // Implementation note: The GTEST_TEMPLATE_ macro declares a template
5267 // template parameter.  It's defined in gtest-type-util.h.
5268 template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
5269 class TypeParameterizedTest {
5270  public:
5271   // 'index' is the index of the test in the type list 'Types'
5272   // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase,
5273   // Types).  Valid values for 'index' are [0, N - 1] where N is the
5274   // length of Types.
5275   static bool Register(const char* prefix,
5276                        CodeLocation code_location,
5277                        const char* case_name, const char* test_names,
5278                        int index) {
5279     typedef typename Types::Head Type;
5280     typedef Fixture<Type> FixtureClass;
5281     typedef typename GTEST_BIND_(TestSel, Type) TestClass;
5282 
5283     // First, registers the first type-parameterized test in the type
5284     // list.
5285     MakeAndRegisterTestInfo(
5286         (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + "/"
5287          + StreamableToString(index)).c_str(),
5288         StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
5289         GetTypeName<Type>().c_str(),
5290         NULL,  // No value parameter.
5291         code_location,
5292         GetTypeId<FixtureClass>(),
5293         TestClass::SetUpTestCase,
5294         TestClass::TearDownTestCase,
5295         new TestFactoryImpl<TestClass>);
5296 
5297     // Next, recurses (at compile time) with the tail of the type list.
5298     return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>
5299         ::Register(prefix, code_location, case_name, test_names, index + 1);
5300   }
5301 };
5302 
5303 // The base case for the compile time recursion.
5304 template <GTEST_TEMPLATE_ Fixture, class TestSel>
5305 class TypeParameterizedTest<Fixture, TestSel, Types0> {
5306  public:
5307   static bool Register(const char* /*prefix*/, CodeLocation,
5308                        const char* /*case_name*/, const char* /*test_names*/,
5309                        int /*index*/) {
5310     return true;
5311   }
5312 };
5313 
5314 // TypeParameterizedTestCase<Fixture, Tests, Types>::Register()
5315 // registers *all combinations* of 'Tests' and 'Types' with Google
5316 // Test.  The return value is insignificant - we just need to return
5317 // something such that we can call this function in a namespace scope.
5318 template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
5319 class TypeParameterizedTestCase {
5320  public:
5321   static bool Register(const char* prefix, CodeLocation code_location,
5322                        const TypedTestCasePState* state,
5323                        const char* case_name, const char* test_names) {
5324     std::string test_name = StripTrailingSpaces(
5325         GetPrefixUntilComma(test_names));
5326     if (!state->TestExists(test_name)) {
5327       fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
5328               case_name, test_name.c_str(),
5329               FormatFileLocation(code_location.file.c_str(),
5330                                  code_location.line).c_str());
5331       fflush(stderr);
5332       posix::Abort();
5333     }
5334     const CodeLocation& test_location = state->GetCodeLocation(test_name);
5335 
5336     typedef typename Tests::Head Head;
5337 
5338     // First, register the first test in 'Test' for each type in 'Types'.
5339     TypeParameterizedTest<Fixture, Head, Types>::Register(
5340         prefix, test_location, case_name, test_names, 0);
5341 
5342     // Next, recurses (at compile time) with the tail of the test list.
5343     return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>
5344         ::Register(prefix, code_location, state,
5345                    case_name, SkipComma(test_names));
5346   }
5347 };
5348 
5349 // The base case for the compile time recursion.
5350 template <GTEST_TEMPLATE_ Fixture, typename Types>
5351 class TypeParameterizedTestCase<Fixture, Templates0, Types> {
5352  public:
5353   static bool Register(const char* /*prefix*/, CodeLocation,
5354                        const TypedTestCasePState* /*state*/,
5355                        const char* /*case_name*/, const char* /*test_names*/) {
5356     return true;
5357   }
5358 };
5359 
5360 #endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
5361 
5362 // Returns the current OS stack trace as an std::string.
5363 //
5364 // The maximum number of stack frames to be included is specified by
5365 // the gtest_stack_trace_depth flag.  The skip_count parameter
5366 // specifies the number of top frames to be skipped, which doesn't
5367 // count against the number of frames to be included.
5368 //
5369 // For example, if Foo() calls Bar(), which in turn calls
5370 // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
5371 // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
5372 GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
5373     UnitTest* unit_test, int skip_count);
5374 
5375 // Helpers for suppressing warnings on unreachable code or constant
5376 // condition.
5377 
5378 // Always returns true.
5379 GTEST_API_ bool AlwaysTrue();
5380 
5381 // Always returns false.
5382 inline bool AlwaysFalse() { return !AlwaysTrue(); }
5383 
5384 // Helper for suppressing false warning from Clang on a const char*
5385 // variable declared in a conditional expression always being NULL in
5386 // the else branch.
5387 struct GTEST_API_ ConstCharPtr {
5388   ConstCharPtr(const char* str) : value(str) {}
5389   operator bool() const { return true; }
5390   const char* value;
5391 };
5392 
5393 // A simple Linear Congruential Generator for generating random
5394 // numbers with a uniform distribution.  Unlike rand() and srand(), it
5395 // doesn't use global state (and therefore can't interfere with user
5396 // code).  Unlike rand_r(), it's portable.  An LCG isn't very random,
5397 // but it's good enough for our purposes.
5398 class GTEST_API_ Random {
5399  public:
5400   static const UInt32 kMaxRange = 1u << 31;
5401 
5402   explicit Random(UInt32 seed) : state_(seed) {}
5403 
5404   void Reseed(UInt32 seed) { state_ = seed; }
5405 
5406   // Generates a random number from [0, range).  Crashes if 'range' is
5407   // 0 or greater than kMaxRange.
5408   UInt32 Generate(UInt32 range);
5409 
5410  private:
5411   UInt32 state_;
5412   GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
5413 };
5414 
5415 // Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
5416 // compiler error iff T1 and T2 are different types.
5417 template <typename T1, typename T2>
5418 struct CompileAssertTypesEqual;
5419 
5420 template <typename T>
5421 struct CompileAssertTypesEqual<T, T> {
5422 };
5423 
5424 // Removes the reference from a type if it is a reference type,
5425 // otherwise leaves it unchanged.  This is the same as
5426 // tr1::remove_reference, which is not widely available yet.
5427 template <typename T>
5428 struct RemoveReference { typedef T type; };  // NOLINT
5429 template <typename T>
5430 struct RemoveReference<T&> { typedef T type; };  // NOLINT
5431 
5432 // A handy wrapper around RemoveReference that works when the argument
5433 // T depends on template parameters.
5434 #define GTEST_REMOVE_REFERENCE_(T) \
5435     typename ::testing::internal::RemoveReference<T>::type
5436 
5437 // Removes const from a type if it is a const type, otherwise leaves
5438 // it unchanged.  This is the same as tr1::remove_const, which is not
5439 // widely available yet.
5440 template <typename T>
5441 struct RemoveConst { typedef T type; };  // NOLINT
5442 template <typename T>
5443 struct RemoveConst<const T> { typedef T type; };  // NOLINT
5444 
5445 // MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
5446 // definition to fail to remove the const in 'const int[3]' and 'const
5447 // char[3][4]'.  The following specialization works around the bug.
5448 template <typename T, size_t N>
5449 struct RemoveConst<const T[N]> {
5450   typedef typename RemoveConst<T>::type type[N];
5451 };
5452 
5453 #if defined(_MSC_VER) && _MSC_VER < 1400
5454 // This is the only specialization that allows VC++ 7.1 to remove const in
5455 // 'const int[3] and 'const int[3][4]'.  However, it causes trouble with GCC
5456 // and thus needs to be conditionally compiled.
5457 template <typename T, size_t N>
5458 struct RemoveConst<T[N]> {
5459   typedef typename RemoveConst<T>::type type[N];
5460 };
5461 #endif
5462 
5463 // A handy wrapper around RemoveConst that works when the argument
5464 // T depends on template parameters.
5465 #define GTEST_REMOVE_CONST_(T) \
5466     typename ::testing::internal::RemoveConst<T>::type
5467 
5468 // Turns const U&, U&, const U, and U all into U.
5469 #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
5470     GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
5471 
5472 // Adds reference to a type if it is not a reference type,
5473 // otherwise leaves it unchanged.  This is the same as
5474 // tr1::add_reference, which is not widely available yet.
5475 template <typename T>
5476 struct AddReference { typedef T& type; };  // NOLINT
5477 template <typename T>
5478 struct AddReference<T&> { typedef T& type; };  // NOLINT
5479 
5480 // A handy wrapper around AddReference that works when the argument T
5481 // depends on template parameters.
5482 #define GTEST_ADD_REFERENCE_(T) \
5483     typename ::testing::internal::AddReference<T>::type
5484 
5485 // Adds a reference to const on top of T as necessary.  For example,
5486 // it transforms
5487 //
5488 //   char         ==> const char&
5489 //   const char   ==> const char&
5490 //   char&        ==> const char&
5491 //   const char&  ==> const char&
5492 //
5493 // The argument T must depend on some template parameters.
5494 #define GTEST_REFERENCE_TO_CONST_(T) \
5495     GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
5496 
5497 // ImplicitlyConvertible<From, To>::value is a compile-time bool
5498 // constant that's true iff type From can be implicitly converted to
5499 // type To.
5500 template <typename From, typename To>
5501 class ImplicitlyConvertible {
5502  private:
5503   // We need the following helper functions only for their types.
5504   // They have no implementations.
5505 
5506   // MakeFrom() is an expression whose type is From.  We cannot simply
5507   // use From(), as the type From may not have a public default
5508   // constructor.
5509   static typename AddReference<From>::type MakeFrom();
5510 
5511   // These two functions are overloaded.  Given an expression
5512   // Helper(x), the compiler will pick the first version if x can be
5513   // implicitly converted to type To; otherwise it will pick the
5514   // second version.
5515   //
5516   // The first version returns a value of size 1, and the second
5517   // version returns a value of size 2.  Therefore, by checking the
5518   // size of Helper(x), which can be done at compile time, we can tell
5519   // which version of Helper() is used, and hence whether x can be
5520   // implicitly converted to type To.
5521   static char Helper(To);
5522   static char (&Helper(...))[2];  // NOLINT
5523 
5524   // We have to put the 'public' section after the 'private' section,
5525   // or MSVC refuses to compile the code.
5526  public:
5527 #if defined(__BORLANDC__)
5528   // C++Builder cannot use member overload resolution during template
5529   // instantiation.  The simplest workaround is to use its C++0x type traits
5530   // functions (C++Builder 2009 and above only).
5531   static const bool value = __is_convertible(From, To);
5532 #else
5533   // MSVC warns about implicitly converting from double to int for
5534   // possible loss of data, so we need to temporarily disable the
5535   // warning.
5536   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244)
5537   static const bool value =
5538       sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
5539   GTEST_DISABLE_MSC_WARNINGS_POP_()
5540 #endif  // __BORLANDC__
5541 };
5542 template <typename From, typename To>
5543 const bool ImplicitlyConvertible<From, To>::value;
5544 
5545 // IsAProtocolMessage<T>::value is a compile-time bool constant that's
5546 // true iff T is type ProtocolMessage, proto2::Message, or a subclass
5547 // of those.
5548 template <typename T>
5549 struct IsAProtocolMessage
5550     : public bool_constant<
5551   ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||
5552   ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {
5553 };
5554 
5555 // When the compiler sees expression IsContainerTest<C>(0), if C is an
5556 // STL-style container class, the first overload of IsContainerTest
5557 // will be viable (since both C::iterator* and C::const_iterator* are
5558 // valid types and NULL can be implicitly converted to them).  It will
5559 // be picked over the second overload as 'int' is a perfect match for
5560 // the type of argument 0.  If C::iterator or C::const_iterator is not
5561 // a valid type, the first overload is not viable, and the second
5562 // overload will be picked.  Therefore, we can determine whether C is
5563 // a container class by checking the type of IsContainerTest<C>(0).
5564 // The value of the expression is insignificant.
5565 //
5566 // Note that we look for both C::iterator and C::const_iterator.  The
5567 // reason is that C++ injects the name of a class as a member of the
5568 // class itself (e.g. you can refer to class iterator as either
5569 // 'iterator' or 'iterator::iterator').  If we look for C::iterator
5570 // only, for example, we would mistakenly think that a class named
5571 // iterator is an STL container.
5572 //
5573 // Also note that the simpler approach of overloading
5574 // IsContainerTest(typename C::const_iterator*) and
5575 // IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
5576 typedef int IsContainer;
5577 template <class C>
5578 IsContainer IsContainerTest(int /* dummy */,
5579                             typename C::iterator* /* it */ = NULL,
5580                             typename C::const_iterator* /* const_it */ = NULL) {
5581   return 0;
5582 }
5583 
5584 typedef char IsNotContainer;
5585 template <class C>
5586 IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
5587 
5588 // EnableIf<condition>::type is void when 'Cond' is true, and
5589 // undefined when 'Cond' is false.  To use SFINAE to make a function
5590 // overload only apply when a particular expression is true, add
5591 // "typename EnableIf<expression>::type* = 0" as the last parameter.
5592 template<bool> struct EnableIf;
5593 template<> struct EnableIf<true> { typedef void type; };  // NOLINT
5594 
5595 // Utilities for native arrays.
5596 
5597 // ArrayEq() compares two k-dimensional native arrays using the
5598 // elements' operator==, where k can be any integer >= 0.  When k is
5599 // 0, ArrayEq() degenerates into comparing a single pair of values.
5600 
5601 template <typename T, typename U>
5602 bool ArrayEq(const T* lhs, size_t size, const U* rhs);
5603 
5604 // This generic version is used when k is 0.
5605 template <typename T, typename U>
5606 inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
5607 
5608 // This overload is used when k >= 1.
5609 template <typename T, typename U, size_t N>
5610 inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
5611   return internal::ArrayEq(lhs, N, rhs);
5612 }
5613 
5614 // This helper reduces code bloat.  If we instead put its logic inside
5615 // the previous ArrayEq() function, arrays with different sizes would
5616 // lead to different copies of the template code.
5617 template <typename T, typename U>
5618 bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
5619   for (size_t i = 0; i != size; i++) {
5620     if (!internal::ArrayEq(lhs[i], rhs[i]))
5621       return false;
5622   }
5623   return true;
5624 }
5625 
5626 // Finds the first element in the iterator range [begin, end) that
5627 // equals elem.  Element may be a native array type itself.
5628 template <typename Iter, typename Element>
5629 Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
5630   for (Iter it = begin; it != end; ++it) {
5631     if (internal::ArrayEq(*it, elem))
5632       return it;
5633   }
5634   return end;
5635 }
5636 
5637 // CopyArray() copies a k-dimensional native array using the elements'
5638 // operator=, where k can be any integer >= 0.  When k is 0,
5639 // CopyArray() degenerates into copying a single value.
5640 
5641 template <typename T, typename U>
5642 void CopyArray(const T* from, size_t size, U* to);
5643 
5644 // This generic version is used when k is 0.
5645 template <typename T, typename U>
5646 inline void CopyArray(const T& from, U* to) { *to = from; }
5647 
5648 // This overload is used when k >= 1.
5649 template <typename T, typename U, size_t N>
5650 inline void CopyArray(const T(&from)[N], U(*to)[N]) {
5651   internal::CopyArray(from, N, *to);
5652 }
5653 
5654 // This helper reduces code bloat.  If we instead put its logic inside
5655 // the previous CopyArray() function, arrays with different sizes
5656 // would lead to different copies of the template code.
5657 template <typename T, typename U>
5658 void CopyArray(const T* from, size_t size, U* to) {
5659   for (size_t i = 0; i != size; i++) {
5660     internal::CopyArray(from[i], to + i);
5661   }
5662 }
5663 
5664 // The relation between an NativeArray object (see below) and the
5665 // native array it represents.
5666 // We use 2 different structs to allow non-copyable types to be used, as long
5667 // as RelationToSourceReference() is passed.
5668 struct RelationToSourceReference {};
5669 struct RelationToSourceCopy {};
5670 
5671 // Adapts a native array to a read-only STL-style container.  Instead
5672 // of the complete STL container concept, this adaptor only implements
5673 // members useful for Google Mock's container matchers.  New members
5674 // should be added as needed.  To simplify the implementation, we only
5675 // support Element being a raw type (i.e. having no top-level const or
5676 // reference modifier).  It's the client's responsibility to satisfy
5677 // this requirement.  Element can be an array type itself (hence
5678 // multi-dimensional arrays are supported).
5679 template <typename Element>
5680 class NativeArray {
5681  public:
5682   // STL-style container typedefs.
5683   typedef Element value_type;
5684   typedef Element* iterator;
5685   typedef const Element* const_iterator;
5686 
5687   // Constructs from a native array. References the source.
5688   NativeArray(const Element* array, size_t count, RelationToSourceReference) {
5689     InitRef(array, count);
5690   }
5691 
5692   // Constructs from a native array. Copies the source.
5693   NativeArray(const Element* array, size_t count, RelationToSourceCopy) {
5694     InitCopy(array, count);
5695   }
5696 
5697   // Copy constructor.
5698   NativeArray(const NativeArray& rhs) {
5699     (this->*rhs.clone_)(rhs.array_, rhs.size_);
5700   }
5701 
5702   ~NativeArray() {
5703     if (clone_ != &NativeArray::InitRef)
5704       delete[] array_;
5705   }
5706 
5707   // STL-style container methods.
5708   size_t size() const { return size_; }
5709   const_iterator begin() const { return array_; }
5710   const_iterator end() const { return array_ + size_; }
5711   bool operator==(const NativeArray& rhs) const {
5712     return size() == rhs.size() &&
5713         ArrayEq(begin(), size(), rhs.begin());
5714   }
5715 
5716  private:
5717   enum {
5718     kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
5719         Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value,
5720   };
5721 
5722   // Initializes this object with a copy of the input.
5723   void InitCopy(const Element* array, size_t a_size) {
5724     Element* const copy = new Element[a_size];
5725     CopyArray(array, a_size, copy);
5726     array_ = copy;
5727     size_ = a_size;
5728     clone_ = &NativeArray::InitCopy;
5729   }
5730 
5731   // Initializes this object with a reference of the input.
5732   void InitRef(const Element* array, size_t a_size) {
5733     array_ = array;
5734     size_ = a_size;
5735     clone_ = &NativeArray::InitRef;
5736   }
5737 
5738   const Element* array_;
5739   size_t size_;
5740   void (NativeArray::*clone_)(const Element*, size_t);
5741 
5742   GTEST_DISALLOW_ASSIGN_(NativeArray);
5743 };
5744 
5745 }  // namespace internal
5746 }  // namespace testing
5747 
5748 #define GTEST_MESSAGE_AT_(file, line, message, result_type) \
5749   ::testing::internal::AssertHelper(result_type, file, line, message) \
5750     = ::testing::Message()
5751 
5752 #define GTEST_MESSAGE_(message, result_type) \
5753   GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
5754 
5755 #define GTEST_FATAL_FAILURE_(message) \
5756   return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
5757 
5758 #define GTEST_NONFATAL_FAILURE_(message) \
5759   GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
5760 
5761 #define GTEST_SUCCESS_(message) \
5762   GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
5763 
5764 // Suppresses MSVC warnings 4072 (unreachable code) for the code following
5765 // statement if it returns or throws (or doesn't return or throw in some
5766 // situations).
5767 #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
5768   if (::testing::internal::AlwaysTrue()) { statement; }
5769 
5770 #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
5771   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
5772   if (::testing::internal::ConstCharPtr gtest_msg = "") { \
5773     bool gtest_caught_expected = false; \
5774     try { \
5775       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
5776     } \
5777     catch (expected_exception const&) { \
5778       gtest_caught_expected = true; \
5779     } \
5780     catch (...) { \
5781       gtest_msg.value = \
5782           "Expected: " #statement " throws an exception of type " \
5783           #expected_exception ".\n  Actual: it throws a different type."; \
5784       goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
5785     } \
5786     if (!gtest_caught_expected) { \
5787       gtest_msg.value = \
5788           "Expected: " #statement " throws an exception of type " \
5789           #expected_exception ".\n  Actual: it throws nothing."; \
5790       goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
5791     } \
5792   } else \
5793     GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
5794       fail(gtest_msg.value)
5795 
5796 #define GTEST_TEST_NO_THROW_(statement, fail) \
5797   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
5798   if (::testing::internal::AlwaysTrue()) { \
5799     try { \
5800       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
5801     } \
5802     catch (...) { \
5803       goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
5804     } \
5805   } else \
5806     GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
5807       fail("Expected: " #statement " doesn't throw an exception.\n" \
5808            "  Actual: it throws.")
5809 
5810 #define GTEST_TEST_ANY_THROW_(statement, fail) \
5811   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
5812   if (::testing::internal::AlwaysTrue()) { \
5813     bool gtest_caught_any = false; \
5814     try { \
5815       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
5816     } \
5817     catch (...) { \
5818       gtest_caught_any = true; \
5819     } \
5820     if (!gtest_caught_any) { \
5821       goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
5822     } \
5823   } else \
5824     GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
5825       fail("Expected: " #statement " throws an exception.\n" \
5826            "  Actual: it doesn't.")
5827 
5828 
5829 // Implements Boolean test assertions such as EXPECT_TRUE. expression can be
5830 // either a boolean expression or an AssertionResult. text is a textual
5831 // represenation of expression as it was passed into the EXPECT_TRUE.
5832 #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
5833   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
5834   if (const ::testing::AssertionResult gtest_ar_ = \
5835       ::testing::AssertionResult(expression)) \
5836     ; \
5837   else \
5838     fail(::testing::internal::GetBoolAssertionFailureMessage(\
5839         gtest_ar_, text, #actual, #expected).c_str())
5840 
5841 #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
5842   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
5843   if (::testing::internal::AlwaysTrue()) { \
5844     ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
5845     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
5846     if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
5847       goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
5848     } \
5849   } else \
5850     GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
5851       fail("Expected: " #statement " doesn't generate new fatal " \
5852            "failures in the current thread.\n" \
5853            "  Actual: it does.")
5854 
5855 // Expands to the name of the class that implements the given test.
5856 #define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
5857   test_case_name##_##test_name##_Test
5858 
5859 // Helper macro for defining tests.
5860 #define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\
5861 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
5862  public:\
5863   GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
5864  private:\
5865   virtual void TestBody();\
5866   static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
5867   GTEST_DISALLOW_COPY_AND_ASSIGN_(\
5868       GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
5869 };\
5870 \
5871 ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
5872   ::test_info_ =\
5873     ::testing::internal::MakeAndRegisterTestInfo(\
5874         #test_case_name, #test_name, NULL, NULL, \
5875         ::testing::internal::CodeLocation(__FILE__, __LINE__), \
5876         (parent_id), \
5877         parent_class::SetUpTestCase, \
5878         parent_class::TearDownTestCase, \
5879         new ::testing::internal::TestFactoryImpl<\
5880             GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
5881 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
5882 
5883 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
5884 
5885 // Copyright 2005, Google Inc.
5886 // All rights reserved.
5887 //
5888 // Redistribution and use in source and binary forms, with or without
5889 // modification, are permitted provided that the following conditions are
5890 // met:
5891 //
5892 //     * Redistributions of source code must retain the above copyright
5893 // notice, this list of conditions and the following disclaimer.
5894 //     * Redistributions in binary form must reproduce the above
5895 // copyright notice, this list of conditions and the following disclaimer
5896 // in the documentation and/or other materials provided with the
5897 // distribution.
5898 //     * Neither the name of Google Inc. nor the names of its
5899 // contributors may be used to endorse or promote products derived from
5900 // this software without specific prior written permission.
5901 //
5902 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5903 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5904 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
5905 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
5906 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5907 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5908 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5909 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5910 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5911 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5912 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5913 //
5914 // Author: wan@google.com (Zhanyong Wan)
5915 //
5916 // The Google C++ Testing Framework (Google Test)
5917 //
5918 // This header file defines the public API for death tests.  It is
5919 // #included by gtest.h so a user doesn't need to include this
5920 // directly.
5921 
5922 #ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
5923 #define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
5924 
5925 // Copyright 2005, Google Inc.
5926 // All rights reserved.
5927 //
5928 // Redistribution and use in source and binary forms, with or without
5929 // modification, are permitted provided that the following conditions are
5930 // met:
5931 //
5932 //     * Redistributions of source code must retain the above copyright
5933 // notice, this list of conditions and the following disclaimer.
5934 //     * Redistributions in binary form must reproduce the above
5935 // copyright notice, this list of conditions and the following disclaimer
5936 // in the documentation and/or other materials provided with the
5937 // distribution.
5938 //     * Neither the name of Google Inc. nor the names of its
5939 // contributors may be used to endorse or promote products derived from
5940 // this software without specific prior written permission.
5941 //
5942 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5943 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5944 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
5945 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
5946 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5947 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5948 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5949 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5950 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5951 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5952 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5953 //
5954 // Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
5955 //
5956 // The Google C++ Testing Framework (Google Test)
5957 //
5958 // This header file defines internal utilities needed for implementing
5959 // death tests.  They are subject to change without notice.
5960 
5961 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
5962 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
5963 
5964 
5965 #include <stdio.h>
5966 
5967 namespace testing {
5968 namespace internal {
5969 
5970 GTEST_DECLARE_string_(internal_run_death_test);
5971 
5972 // Names of the flags (needed for parsing Google Test flags).
5973 const char kDeathTestStyleFlag[] = "death_test_style";
5974 const char kDeathTestUseFork[] = "death_test_use_fork";
5975 const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
5976 
5977 #if GTEST_HAS_DEATH_TEST
5978 
5979 // DeathTest is a class that hides much of the complexity of the
5980 // GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method
5981 // returns a concrete class that depends on the prevailing death test
5982 // style, as defined by the --gtest_death_test_style and/or
5983 // --gtest_internal_run_death_test flags.
5984 
5985 // In describing the results of death tests, these terms are used with
5986 // the corresponding definitions:
5987 //
5988 // exit status:  The integer exit information in the format specified
5989 //               by wait(2)
5990 // exit code:    The integer code passed to exit(3), _exit(2), or
5991 //               returned from main()
5992 class GTEST_API_ DeathTest {
5993  public:
5994   // Create returns false if there was an error determining the
5995   // appropriate action to take for the current death test; for example,
5996   // if the gtest_death_test_style flag is set to an invalid value.
5997   // The LastMessage method will return a more detailed message in that
5998   // case.  Otherwise, the DeathTest pointer pointed to by the "test"
5999   // argument is set.  If the death test should be skipped, the pointer
6000   // is set to NULL; otherwise, it is set to the address of a new concrete
6001   // DeathTest object that controls the execution of the current test.
6002   static bool Create(const char* statement, const RE* regex,
6003                      const char* file, int line, DeathTest** test);
6004   DeathTest();
6005   virtual ~DeathTest() { }
6006 
6007   // A helper class that aborts a death test when it's deleted.
6008   class ReturnSentinel {
6009    public:
6010     explicit ReturnSentinel(DeathTest* test) : test_(test) { }
6011     ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
6012    private:
6013     DeathTest* const test_;
6014     GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
6015   } GTEST_ATTRIBUTE_UNUSED_;
6016 
6017   // An enumeration of possible roles that may be taken when a death
6018   // test is encountered.  EXECUTE means that the death test logic should
6019   // be executed immediately.  OVERSEE means that the program should prepare
6020   // the appropriate environment for a child process to execute the death
6021   // test, then wait for it to complete.
6022   enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
6023 
6024   // An enumeration of the three reasons that a test might be aborted.
6025   enum AbortReason {
6026     TEST_ENCOUNTERED_RETURN_STATEMENT,
6027     TEST_THREW_EXCEPTION,
6028     TEST_DID_NOT_DIE
6029   };
6030 
6031   // Assumes one of the above roles.
6032   virtual TestRole AssumeRole() = 0;
6033 
6034   // Waits for the death test to finish and returns its status.
6035   virtual int Wait() = 0;
6036 
6037   // Returns true if the death test passed; that is, the test process
6038   // exited during the test, its exit status matches a user-supplied
6039   // predicate, and its stderr output matches a user-supplied regular
6040   // expression.
6041   // The user-supplied predicate may be a macro expression rather
6042   // than a function pointer or functor, or else Wait and Passed could
6043   // be combined.
6044   virtual bool Passed(bool exit_status_ok) = 0;
6045 
6046   // Signals that the death test did not die as expected.
6047   virtual void Abort(AbortReason reason) = 0;
6048 
6049   // Returns a human-readable outcome message regarding the outcome of
6050   // the last death test.
6051   static const char* LastMessage();
6052 
6053   static void set_last_death_test_message(const std::string& message);
6054 
6055  private:
6056   // A string containing a description of the outcome of the last death test.
6057   static std::string last_death_test_message_;
6058 
6059   GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
6060 };
6061 
6062 // Factory interface for death tests.  May be mocked out for testing.
6063 class DeathTestFactory {
6064  public:
6065   virtual ~DeathTestFactory() { }
6066   virtual bool Create(const char* statement, const RE* regex,
6067                       const char* file, int line, DeathTest** test) = 0;
6068 };
6069 
6070 // A concrete DeathTestFactory implementation for normal use.
6071 class DefaultDeathTestFactory : public DeathTestFactory {
6072  public:
6073   virtual bool Create(const char* statement, const RE* regex,
6074                       const char* file, int line, DeathTest** test);
6075 };
6076 
6077 // Returns true if exit_status describes a process that was terminated
6078 // by a signal, or exited normally with a nonzero exit code.
6079 GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
6080 
6081 // Traps C++ exceptions escaping statement and reports them as test
6082 // failures. Note that trapping SEH exceptions is not implemented here.
6083 # if GTEST_HAS_EXCEPTIONS
6084 #  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
6085   try { \
6086     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
6087   } catch (const ::std::exception& gtest_exception) { \
6088     fprintf(\
6089         stderr, \
6090         "\n%s: Caught std::exception-derived exception escaping the " \
6091         "death test statement. Exception message: %s\n", \
6092         ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
6093         gtest_exception.what()); \
6094     fflush(stderr); \
6095     death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
6096   } catch (...) { \
6097     death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
6098   }
6099 
6100 # else
6101 #  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
6102   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
6103 
6104 # endif
6105 
6106 // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
6107 // ASSERT_EXIT*, and EXPECT_EXIT*.
6108 # define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
6109   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
6110   if (::testing::internal::AlwaysTrue()) { \
6111     const ::testing::internal::RE& gtest_regex = (regex); \
6112     ::testing::internal::DeathTest* gtest_dt; \
6113     if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
6114         __FILE__, __LINE__, &gtest_dt)) { \
6115       goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
6116     } \
6117     if (gtest_dt != NULL) { \
6118       ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
6119           gtest_dt_ptr(gtest_dt); \
6120       switch (gtest_dt->AssumeRole()) { \
6121         case ::testing::internal::DeathTest::OVERSEE_TEST: \
6122           if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
6123             goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
6124           } \
6125           break; \
6126         case ::testing::internal::DeathTest::EXECUTE_TEST: { \
6127           ::testing::internal::DeathTest::ReturnSentinel \
6128               gtest_sentinel(gtest_dt); \
6129           GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
6130           gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
6131           break; \
6132         } \
6133         default: \
6134           break; \
6135       } \
6136     } \
6137   } else \
6138     GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
6139       fail(::testing::internal::DeathTest::LastMessage())
6140 // The symbol "fail" here expands to something into which a message
6141 // can be streamed.
6142 
6143 // This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
6144 // NDEBUG mode. In this case we need the statements to be executed, the regex is
6145 // ignored, and the macro must accept a streamed message even though the message
6146 // is never printed.
6147 # define GTEST_EXECUTE_STATEMENT_(statement, regex) \
6148   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
6149   if (::testing::internal::AlwaysTrue()) { \
6150      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
6151   } else \
6152     ::testing::Message()
6153 
6154 // A class representing the parsed contents of the
6155 // --gtest_internal_run_death_test flag, as it existed when
6156 // RUN_ALL_TESTS was called.
6157 class InternalRunDeathTestFlag {
6158  public:
6159   InternalRunDeathTestFlag(const std::string& a_file,
6160                            int a_line,
6161                            int an_index,
6162                            int a_write_fd)
6163       : file_(a_file), line_(a_line), index_(an_index),
6164         write_fd_(a_write_fd) {}
6165 
6166   ~InternalRunDeathTestFlag() {
6167     if (write_fd_ >= 0)
6168       posix::Close(write_fd_);
6169   }
6170 
6171   const std::string& file() const { return file_; }
6172   int line() const { return line_; }
6173   int index() const { return index_; }
6174   int write_fd() const { return write_fd_; }
6175 
6176  private:
6177   std::string file_;
6178   int line_;
6179   int index_;
6180   int write_fd_;
6181 
6182   GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
6183 };
6184 
6185 // Returns a newly created InternalRunDeathTestFlag object with fields
6186 // initialized from the GTEST_FLAG(internal_run_death_test) flag if
6187 // the flag is specified; otherwise returns NULL.
6188 InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
6189 
6190 #else  // GTEST_HAS_DEATH_TEST
6191 
6192 // This macro is used for implementing macros such as
6193 // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
6194 // death tests are not supported. Those macros must compile on such systems
6195 // iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
6196 // systems that support death tests. This allows one to write such a macro
6197 // on a system that does not support death tests and be sure that it will
6198 // compile on a death-test supporting system.
6199 //
6200 // Parameters:
6201 //   statement -  A statement that a macro such as EXPECT_DEATH would test
6202 //                for program termination. This macro has to make sure this
6203 //                statement is compiled but not executed, to ensure that
6204 //                EXPECT_DEATH_IF_SUPPORTED compiles with a certain
6205 //                parameter iff EXPECT_DEATH compiles with it.
6206 //   regex     -  A regex that a macro such as EXPECT_DEATH would use to test
6207 //                the output of statement.  This parameter has to be
6208 //                compiled but not evaluated by this macro, to ensure that
6209 //                this macro only accepts expressions that a macro such as
6210 //                EXPECT_DEATH would accept.
6211 //   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
6212 //                and a return statement for ASSERT_DEATH_IF_SUPPORTED.
6213 //                This ensures that ASSERT_DEATH_IF_SUPPORTED will not
6214 //                compile inside functions where ASSERT_DEATH doesn't
6215 //                compile.
6216 //
6217 //  The branch that has an always false condition is used to ensure that
6218 //  statement and regex are compiled (and thus syntactically correct) but
6219 //  never executed. The unreachable code macro protects the terminator
6220 //  statement from generating an 'unreachable code' warning in case
6221 //  statement unconditionally returns or throws. The Message constructor at
6222 //  the end allows the syntax of streaming additional messages into the
6223 //  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
6224 # define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
6225     GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
6226     if (::testing::internal::AlwaysTrue()) { \
6227       GTEST_LOG_(WARNING) \
6228           << "Death tests are not supported on this platform.\n" \
6229           << "Statement '" #statement "' cannot be verified."; \
6230     } else if (::testing::internal::AlwaysFalse()) { \
6231       ::testing::internal::RE::PartialMatch(".*", (regex)); \
6232       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
6233       terminator; \
6234     } else \
6235       ::testing::Message()
6236 
6237 #endif  // GTEST_HAS_DEATH_TEST
6238 
6239 }  // namespace internal
6240 }  // namespace testing
6241 
6242 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
6243 
6244 namespace testing {
6245 
6246 // This flag controls the style of death tests.  Valid values are "threadsafe",
6247 // meaning that the death test child process will re-execute the test binary
6248 // from the start, running only a single death test, or "fast",
6249 // meaning that the child process will execute the test logic immediately
6250 // after forking.
6251 GTEST_DECLARE_string_(death_test_style);
6252 
6253 #if GTEST_HAS_DEATH_TEST
6254 
6255 namespace internal {
6256 
6257 // Returns a Boolean value indicating whether the caller is currently
6258 // executing in the context of the death test child process.  Tools such as
6259 // Valgrind heap checkers may need this to modify their behavior in death
6260 // tests.  IMPORTANT: This is an internal utility.  Using it may break the
6261 // implementation of death tests.  User code MUST NOT use it.
6262 GTEST_API_ bool InDeathTestChild();
6263 
6264 }  // namespace internal
6265 
6266 // The following macros are useful for writing death tests.
6267 
6268 // Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
6269 // executed:
6270 //
6271 //   1. It generates a warning if there is more than one active
6272 //   thread.  This is because it's safe to fork() or clone() only
6273 //   when there is a single thread.
6274 //
6275 //   2. The parent process clone()s a sub-process and runs the death
6276 //   test in it; the sub-process exits with code 0 at the end of the
6277 //   death test, if it hasn't exited already.
6278 //
6279 //   3. The parent process waits for the sub-process to terminate.
6280 //
6281 //   4. The parent process checks the exit code and error message of
6282 //   the sub-process.
6283 //
6284 // Examples:
6285 //
6286 //   ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
6287 //   for (int i = 0; i < 5; i++) {
6288 //     EXPECT_DEATH(server.ProcessRequest(i),
6289 //                  "Invalid request .* in ProcessRequest()")
6290 //                  << "Failed to die on request " << i;
6291 //   }
6292 //
6293 //   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
6294 //
6295 //   bool KilledBySIGHUP(int exit_code) {
6296 //     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
6297 //   }
6298 //
6299 //   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
6300 //
6301 // On the regular expressions used in death tests:
6302 //
6303 //   On POSIX-compliant systems (*nix), we use the <regex.h> library,
6304 //   which uses the POSIX extended regex syntax.
6305 //
6306 //   On other platforms (e.g. Windows), we only support a simple regex
6307 //   syntax implemented as part of Google Test.  This limited
6308 //   implementation should be enough most of the time when writing
6309 //   death tests; though it lacks many features you can find in PCRE
6310 //   or POSIX extended regex syntax.  For example, we don't support
6311 //   union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
6312 //   repetition count ("x{5,7}"), among others.
6313 //
6314 //   Below is the syntax that we do support.  We chose it to be a
6315 //   subset of both PCRE and POSIX extended regex, so it's easy to
6316 //   learn wherever you come from.  In the following: 'A' denotes a
6317 //   literal character, period (.), or a single \\ escape sequence;
6318 //   'x' and 'y' denote regular expressions; 'm' and 'n' are for
6319 //   natural numbers.
6320 //
6321 //     c     matches any literal character c
6322 //     \\d   matches any decimal digit
6323 //     \\D   matches any character that's not a decimal digit
6324 //     \\f   matches \f
6325 //     \\n   matches \n
6326 //     \\r   matches \r
6327 //     \\s   matches any ASCII whitespace, including \n
6328 //     \\S   matches any character that's not a whitespace
6329 //     \\t   matches \t
6330 //     \\v   matches \v
6331 //     \\w   matches any letter, _, or decimal digit
6332 //     \\W   matches any character that \\w doesn't match
6333 //     \\c   matches any literal character c, which must be a punctuation
6334 //     .     matches any single character except \n
6335 //     A?    matches 0 or 1 occurrences of A
6336 //     A*    matches 0 or many occurrences of A
6337 //     A+    matches 1 or many occurrences of A
6338 //     ^     matches the beginning of a string (not that of each line)
6339 //     $     matches the end of a string (not that of each line)
6340 //     xy    matches x followed by y
6341 //
6342 //   If you accidentally use PCRE or POSIX extended regex features
6343 //   not implemented by us, you will get a run-time failure.  In that
6344 //   case, please try to rewrite your regular expression within the
6345 //   above syntax.
6346 //
6347 //   This implementation is *not* meant to be as highly tuned or robust
6348 //   as a compiled regex library, but should perform well enough for a
6349 //   death test, which already incurs significant overhead by launching
6350 //   a child process.
6351 //
6352 // Known caveats:
6353 //
6354 //   A "threadsafe" style death test obtains the path to the test
6355 //   program from argv[0] and re-executes it in the sub-process.  For
6356 //   simplicity, the current implementation doesn't search the PATH
6357 //   when launching the sub-process.  This means that the user must
6358 //   invoke the test program via a path that contains at least one
6359 //   path separator (e.g. path/to/foo_test and
6360 //   /absolute/path/to/bar_test are fine, but foo_test is not).  This
6361 //   is rarely a problem as people usually don't put the test binary
6362 //   directory in PATH.
6363 //
6364 // TODO(wan@google.com): make thread-safe death tests search the PATH.
6365 
6366 // Asserts that a given statement causes the program to exit, with an
6367 // integer exit status that satisfies predicate, and emitting error output
6368 // that matches regex.
6369 # define ASSERT_EXIT(statement, predicate, regex) \
6370     GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
6371 
6372 // Like ASSERT_EXIT, but continues on to successive tests in the
6373 // test case, if any:
6374 # define EXPECT_EXIT(statement, predicate, regex) \
6375     GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
6376 
6377 // Asserts that a given statement causes the program to exit, either by
6378 // explicitly exiting with a nonzero exit code or being killed by a
6379 // signal, and emitting error output that matches regex.
6380 # define ASSERT_DEATH(statement, regex) \
6381     ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
6382 
6383 // Like ASSERT_DEATH, but continues on to successive tests in the
6384 // test case, if any:
6385 # define EXPECT_DEATH(statement, regex) \
6386     EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
6387 
6388 // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
6389 
6390 // Tests that an exit code describes a normal exit with a given exit code.
6391 class GTEST_API_ ExitedWithCode {
6392  public:
6393   explicit ExitedWithCode(int exit_code);
6394   bool operator()(int exit_status) const;
6395  private:
6396   // No implementation - assignment is unsupported.
6397   void operator=(const ExitedWithCode& other);
6398 
6399   const int exit_code_;
6400 };
6401 
6402 # if !GTEST_OS_WINDOWS
6403 // Tests that an exit code describes an exit due to termination by a
6404 // given signal.
6405 class GTEST_API_ KilledBySignal {
6406  public:
6407   explicit KilledBySignal(int signum);
6408   bool operator()(int exit_status) const;
6409  private:
6410   const int signum_;
6411 };
6412 # endif  // !GTEST_OS_WINDOWS
6413 
6414 // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
6415 // The death testing framework causes this to have interesting semantics,
6416 // since the sideeffects of the call are only visible in opt mode, and not
6417 // in debug mode.
6418 //
6419 // In practice, this can be used to test functions that utilize the
6420 // LOG(DFATAL) macro using the following style:
6421 //
6422 // int DieInDebugOr12(int* sideeffect) {
6423 //   if (sideeffect) {
6424 //     *sideeffect = 12;
6425 //   }
6426 //   LOG(DFATAL) << "death";
6427 //   return 12;
6428 // }
6429 //
6430 // TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
6431 //   int sideeffect = 0;
6432 //   // Only asserts in dbg.
6433 //   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
6434 //
6435 // #ifdef NDEBUG
6436 //   // opt-mode has sideeffect visible.
6437 //   EXPECT_EQ(12, sideeffect);
6438 // #else
6439 //   // dbg-mode no visible sideeffect.
6440 //   EXPECT_EQ(0, sideeffect);
6441 // #endif
6442 // }
6443 //
6444 // This will assert that DieInDebugReturn12InOpt() crashes in debug
6445 // mode, usually due to a DCHECK or LOG(DFATAL), but returns the
6446 // appropriate fallback value (12 in this case) in opt mode. If you
6447 // need to test that a function has appropriate side-effects in opt
6448 // mode, include assertions against the side-effects.  A general
6449 // pattern for this is:
6450 //
6451 // EXPECT_DEBUG_DEATH({
6452 //   // Side-effects here will have an effect after this statement in
6453 //   // opt mode, but none in debug mode.
6454 //   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
6455 // }, "death");
6456 //
6457 # ifdef NDEBUG
6458 
6459 #  define EXPECT_DEBUG_DEATH(statement, regex) \
6460   GTEST_EXECUTE_STATEMENT_(statement, regex)
6461 
6462 #  define ASSERT_DEBUG_DEATH(statement, regex) \
6463   GTEST_EXECUTE_STATEMENT_(statement, regex)
6464 
6465 # else
6466 
6467 #  define EXPECT_DEBUG_DEATH(statement, regex) \
6468   EXPECT_DEATH(statement, regex)
6469 
6470 #  define ASSERT_DEBUG_DEATH(statement, regex) \
6471   ASSERT_DEATH(statement, regex)
6472 
6473 # endif  // NDEBUG for EXPECT_DEBUG_DEATH
6474 #endif  // GTEST_HAS_DEATH_TEST
6475 
6476 // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
6477 // ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
6478 // death tests are supported; otherwise they just issue a warning.  This is
6479 // useful when you are combining death test assertions with normal test
6480 // assertions in one test.
6481 #if GTEST_HAS_DEATH_TEST
6482 # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
6483     EXPECT_DEATH(statement, regex)
6484 # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
6485     ASSERT_DEATH(statement, regex)
6486 #else
6487 # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
6488     GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
6489 # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
6490     GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
6491 #endif
6492 
6493 }  // namespace testing
6494 
6495 #endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
6496 // This file was GENERATED by command:
6497 //     pump.py gtest-param-test.h.pump
6498 // DO NOT EDIT BY HAND!!!
6499 
6500 // Copyright 2008, Google Inc.
6501 // All rights reserved.
6502 //
6503 // Redistribution and use in source and binary forms, with or without
6504 // modification, are permitted provided that the following conditions are
6505 // met:
6506 //
6507 //     * Redistributions of source code must retain the above copyright
6508 // notice, this list of conditions and the following disclaimer.
6509 //     * Redistributions in binary form must reproduce the above
6510 // copyright notice, this list of conditions and the following disclaimer
6511 // in the documentation and/or other materials provided with the
6512 // distribution.
6513 //     * Neither the name of Google Inc. nor the names of its
6514 // contributors may be used to endorse or promote products derived from
6515 // this software without specific prior written permission.
6516 //
6517 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6518 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6519 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6520 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6521 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6522 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6523 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6524 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6525 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6526 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6527 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6528 //
6529 // Authors: vladl@google.com (Vlad Losev)
6530 //
6531 // Macros and functions for implementing parameterized tests
6532 // in Google C++ Testing Framework (Google Test)
6533 //
6534 // This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
6535 //
6536 #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
6537 #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
6538 
6539 
6540 // Value-parameterized tests allow you to test your code with different
6541 // parameters without writing multiple copies of the same test.
6542 //
6543 // Here is how you use value-parameterized tests:
6544 
6545 #if 0
6546 
6547 // To write value-parameterized tests, first you should define a fixture
6548 // class. It is usually derived from testing::TestWithParam<T> (see below for
6549 // another inheritance scheme that's sometimes useful in more complicated
6550 // class hierarchies), where the type of your parameter values.
6551 // TestWithParam<T> is itself derived from testing::Test. T can be any
6552 // copyable type. If it's a raw pointer, you are responsible for managing the
6553 // lifespan of the pointed values.
6554 
6555 class FooTest : public ::testing::TestWithParam<const char*> {
6556   // You can implement all the usual class fixture members here.
6557 };
6558 
6559 // Then, use the TEST_P macro to define as many parameterized tests
6560 // for this fixture as you want. The _P suffix is for "parameterized"
6561 // or "pattern", whichever you prefer to think.
6562 
6563 TEST_P(FooTest, DoesBlah) {
6564   // Inside a test, access the test parameter with the GetParam() method
6565   // of the TestWithParam<T> class:
6566   EXPECT_TRUE(foo.Blah(GetParam()));
6567   ...
6568 }
6569 
6570 TEST_P(FooTest, HasBlahBlah) {
6571   ...
6572 }
6573 
6574 // Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
6575 // case with any set of parameters you want. Google Test defines a number
6576 // of functions for generating test parameters. They return what we call
6577 // (surprise!) parameter generators. Here is a  summary of them, which
6578 // are all in the testing namespace:
6579 //
6580 //
6581 //  Range(begin, end [, step]) - Yields values {begin, begin+step,
6582 //                               begin+step+step, ...}. The values do not
6583 //                               include end. step defaults to 1.
6584 //  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.
6585 //  ValuesIn(container)        - Yields values from a C-style array, an STL
6586 //  ValuesIn(begin,end)          container, or an iterator range [begin, end).
6587 //  Bool()                     - Yields sequence {false, true}.
6588 //  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product
6589 //                               for the math savvy) of the values generated
6590 //                               by the N generators.
6591 //
6592 // For more details, see comments at the definitions of these functions below
6593 // in this file.
6594 //
6595 // The following statement will instantiate tests from the FooTest test case
6596 // each with parameter values "meeny", "miny", and "moe".
6597 
6598 INSTANTIATE_TEST_CASE_P(InstantiationName,
6599                         FooTest,
6600                         Values("meeny", "miny", "moe"));
6601 
6602 // To distinguish different instances of the pattern, (yes, you
6603 // can instantiate it more then once) the first argument to the
6604 // INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
6605 // actual test case name. Remember to pick unique prefixes for different
6606 // instantiations. The tests from the instantiation above will have
6607 // these names:
6608 //
6609 //    * InstantiationName/FooTest.DoesBlah/0 for "meeny"
6610 //    * InstantiationName/FooTest.DoesBlah/1 for "miny"
6611 //    * InstantiationName/FooTest.DoesBlah/2 for "moe"
6612 //    * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
6613 //    * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
6614 //    * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
6615 //
6616 // You can use these names in --gtest_filter.
6617 //
6618 // This statement will instantiate all tests from FooTest again, each
6619 // with parameter values "cat" and "dog":
6620 
6621 const char* pets[] = {"cat", "dog"};
6622 INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
6623 
6624 // The tests from the instantiation above will have these names:
6625 //
6626 //    * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
6627 //    * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
6628 //    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
6629 //    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
6630 //
6631 // Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
6632 // in the given test case, whether their definitions come before or
6633 // AFTER the INSTANTIATE_TEST_CASE_P statement.
6634 //
6635 // Please also note that generator expressions (including parameters to the
6636 // generators) are evaluated in InitGoogleTest(), after main() has started.
6637 // This allows the user on one hand, to adjust generator parameters in order
6638 // to dynamically determine a set of tests to run and on the other hand,
6639 // give the user a chance to inspect the generated tests with Google Test
6640 // reflection API before RUN_ALL_TESTS() is executed.
6641 //
6642 // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
6643 // for more examples.
6644 //
6645 // In the future, we plan to publish the API for defining new parameter
6646 // generators. But for now this interface remains part of the internal
6647 // implementation and is subject to change.
6648 //
6649 //
6650 // A parameterized test fixture must be derived from testing::Test and from
6651 // testing::WithParamInterface<T>, where T is the type of the parameter
6652 // values. Inheriting from TestWithParam<T> satisfies that requirement because
6653 // TestWithParam<T> inherits from both Test and WithParamInterface. In more
6654 // complicated hierarchies, however, it is occasionally useful to inherit
6655 // separately from Test and WithParamInterface. For example:
6656 
6657 class BaseTest : public ::testing::Test {
6658   // You can inherit all the usual members for a non-parameterized test
6659   // fixture here.
6660 };
6661 
6662 class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
6663   // The usual test fixture members go here too.
6664 };
6665 
6666 TEST_F(BaseTest, HasFoo) {
6667   // This is an ordinary non-parameterized test.
6668 }
6669 
6670 TEST_P(DerivedTest, DoesBlah) {
6671   // GetParam works just the same here as if you inherit from TestWithParam.
6672   EXPECT_TRUE(foo.Blah(GetParam()));
6673 }
6674 
6675 #endif  // 0
6676 
6677 
6678 #if !GTEST_OS_SYMBIAN
6679 # include <utility>
6680 #endif
6681 
6682 // scripts/fuse_gtest.py depends on gtest's own header being #included
6683 // *unconditionally*.  Therefore these #includes cannot be moved
6684 // inside #if GTEST_HAS_PARAM_TEST.
6685 // Copyright 2008 Google Inc.
6686 // All Rights Reserved.
6687 //
6688 // Redistribution and use in source and binary forms, with or without
6689 // modification, are permitted provided that the following conditions are
6690 // met:
6691 //
6692 //     * Redistributions of source code must retain the above copyright
6693 // notice, this list of conditions and the following disclaimer.
6694 //     * Redistributions in binary form must reproduce the above
6695 // copyright notice, this list of conditions and the following disclaimer
6696 // in the documentation and/or other materials provided with the
6697 // distribution.
6698 //     * Neither the name of Google Inc. nor the names of its
6699 // contributors may be used to endorse or promote products derived from
6700 // this software without specific prior written permission.
6701 //
6702 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6703 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6704 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6705 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6706 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6707 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6708 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6709 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6710 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6711 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6712 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6713 //
6714 // Author: vladl@google.com (Vlad Losev)
6715 
6716 // Type and function utilities for implementing parameterized tests.
6717 
6718 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
6719 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
6720 
6721 #include <ctype.h>
6722 
6723 #include <iterator>
6724 #include <set>
6725 #include <utility>
6726 #include <vector>
6727 
6728 // scripts/fuse_gtest.py depends on gtest's own header being #included
6729 // *unconditionally*.  Therefore these #includes cannot be moved
6730 // inside #if GTEST_HAS_PARAM_TEST.
6731 // Copyright 2003 Google Inc.
6732 // All rights reserved.
6733 //
6734 // Redistribution and use in source and binary forms, with or without
6735 // modification, are permitted provided that the following conditions are
6736 // met:
6737 //
6738 //     * Redistributions of source code must retain the above copyright
6739 // notice, this list of conditions and the following disclaimer.
6740 //     * Redistributions in binary form must reproduce the above
6741 // copyright notice, this list of conditions and the following disclaimer
6742 // in the documentation and/or other materials provided with the
6743 // distribution.
6744 //     * Neither the name of Google Inc. nor the names of its
6745 // contributors may be used to endorse or promote products derived from
6746 // this software without specific prior written permission.
6747 //
6748 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6749 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6750 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6751 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6752 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6753 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6754 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6755 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6756 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6757 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6758 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6759 //
6760 // Authors: Dan Egnor (egnor@google.com)
6761 //
6762 // A "smart" pointer type with reference tracking.  Every pointer to a
6763 // particular object is kept on a circular linked list.  When the last pointer
6764 // to an object is destroyed or reassigned, the object is deleted.
6765 //
6766 // Used properly, this deletes the object when the last reference goes away.
6767 // There are several caveats:
6768 // - Like all reference counting schemes, cycles lead to leaks.
6769 // - Each smart pointer is actually two pointers (8 bytes instead of 4).
6770 // - Every time a pointer is assigned, the entire list of pointers to that
6771 //   object is traversed.  This class is therefore NOT SUITABLE when there
6772 //   will often be more than two or three pointers to a particular object.
6773 // - References are only tracked as long as linked_ptr<> objects are copied.
6774 //   If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
6775 //   will happen (double deletion).
6776 //
6777 // A good use of this class is storing object references in STL containers.
6778 // You can safely put linked_ptr<> in a vector<>.
6779 // Other uses may not be as good.
6780 //
6781 // Note: If you use an incomplete type with linked_ptr<>, the class
6782 // *containing* linked_ptr<> must have a constructor and destructor (even
6783 // if they do nothing!).
6784 //
6785 // Bill Gibbons suggested we use something like this.
6786 //
6787 // Thread Safety:
6788 //   Unlike other linked_ptr implementations, in this implementation
6789 //   a linked_ptr object is thread-safe in the sense that:
6790 //     - it's safe to copy linked_ptr objects concurrently,
6791 //     - it's safe to copy *from* a linked_ptr and read its underlying
6792 //       raw pointer (e.g. via get()) concurrently, and
6793 //     - it's safe to write to two linked_ptrs that point to the same
6794 //       shared object concurrently.
6795 // TODO(wan@google.com): rename this to safe_linked_ptr to avoid
6796 // confusion with normal linked_ptr.
6797 
6798 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
6799 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
6800 
6801 #include <stdlib.h>
6802 #include <assert.h>
6803 
6804 
6805 namespace testing {
6806 namespace internal {
6807 
6808 // Protects copying of all linked_ptr objects.
6809 GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
6810 
6811 // This is used internally by all instances of linked_ptr<>.  It needs to be
6812 // a non-template class because different types of linked_ptr<> can refer to
6813 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
6814 // So, it needs to be possible for different types of linked_ptr to participate
6815 // in the same circular linked list, so we need a single class type here.
6816 //
6817 // DO NOT USE THIS CLASS DIRECTLY YOURSELF.  Use linked_ptr<T>.
6818 class linked_ptr_internal {
6819  public:
6820   // Create a new circle that includes only this instance.
6821   void join_new() {
6822     next_ = this;
6823   }
6824 
6825   // Many linked_ptr operations may change p.link_ for some linked_ptr
6826   // variable p in the same circle as this object.  Therefore we need
6827   // to prevent two such operations from occurring concurrently.
6828   //
6829   // Note that different types of linked_ptr objects can coexist in a
6830   // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
6831   // linked_ptr<Derived2>).  Therefore we must use a single mutex to
6832   // protect all linked_ptr objects.  This can create serious
6833   // contention in production code, but is acceptable in a testing
6834   // framework.
6835 
6836   // Join an existing circle.
6837   void join(linked_ptr_internal const* ptr)
6838       GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
6839     MutexLock lock(&g_linked_ptr_mutex);
6840 
6841     linked_ptr_internal const* p = ptr;
6842     while (p->next_ != ptr) {
6843       assert(p->next_ != this &&
6844              "Trying to join() a linked ring we are already in. "
6845              "Is GMock thread safety enabled?");
6846       p = p->next_;
6847     }
6848     p->next_ = this;
6849     next_ = ptr;
6850   }
6851 
6852   // Leave whatever circle we're part of.  Returns true if we were the
6853   // last member of the circle.  Once this is done, you can join() another.
6854   bool depart()
6855       GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {
6856     MutexLock lock(&g_linked_ptr_mutex);
6857 
6858     if (next_ == this) return true;
6859     linked_ptr_internal const* p = next_;
6860     while (p->next_ != this) {
6861       assert(p->next_ != next_ &&
6862              "Trying to depart() a linked ring we are not in. "
6863              "Is GMock thread safety enabled?");
6864       p = p->next_;
6865     }
6866     p->next_ = next_;
6867     return false;
6868   }
6869 
6870  private:
6871   mutable linked_ptr_internal const* next_;
6872 };
6873 
6874 template <typename T>
6875 class linked_ptr {
6876  public:
6877   typedef T element_type;
6878 
6879   // Take over ownership of a raw pointer.  This should happen as soon as
6880   // possible after the object is created.
6881   explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
6882   ~linked_ptr() { depart(); }
6883 
6884   // Copy an existing linked_ptr<>, adding ourselves to the list of references.
6885   template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
6886   linked_ptr(linked_ptr const& ptr) {  // NOLINT
6887     assert(&ptr != this);
6888     copy(&ptr);
6889   }
6890 
6891   // Assignment releases the old value and acquires the new.
6892   template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
6893     depart();
6894     copy(&ptr);
6895     return *this;
6896   }
6897 
6898   linked_ptr& operator=(linked_ptr const& ptr) {
6899     if (&ptr != this) {
6900       depart();
6901       copy(&ptr);
6902     }
6903     return *this;
6904   }
6905 
6906   // Smart pointer members.
6907   void reset(T* ptr = NULL) {
6908     depart();
6909     capture(ptr);
6910   }
6911   T* get() const { return value_; }
6912   T* operator->() const { return value_; }
6913   T& operator*() const { return *value_; }
6914 
6915   bool operator==(T* p) const { return value_ == p; }
6916   bool operator!=(T* p) const { return value_ != p; }
6917   template <typename U>
6918   bool operator==(linked_ptr<U> const& ptr) const {
6919     return value_ == ptr.get();
6920   }
6921   template <typename U>
6922   bool operator!=(linked_ptr<U> const& ptr) const {
6923     return value_ != ptr.get();
6924   }
6925 
6926  private:
6927   template <typename U>
6928   friend class linked_ptr;
6929 
6930   T* value_;
6931   linked_ptr_internal link_;
6932 
6933   void depart() {
6934     if (link_.depart()) delete value_;
6935   }
6936 
6937   void capture(T* ptr) {
6938     value_ = ptr;
6939     link_.join_new();
6940   }
6941 
6942   template <typename U> void copy(linked_ptr<U> const* ptr) {
6943     value_ = ptr->get();
6944     if (value_)
6945       link_.join(&ptr->link_);
6946     else
6947       link_.join_new();
6948   }
6949 };
6950 
6951 template<typename T> inline
6952 bool operator==(T* ptr, const linked_ptr<T>& x) {
6953   return ptr == x.get();
6954 }
6955 
6956 template<typename T> inline
6957 bool operator!=(T* ptr, const linked_ptr<T>& x) {
6958   return ptr != x.get();
6959 }
6960 
6961 // A function to convert T* into linked_ptr<T>
6962 // Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
6963 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
6964 template <typename T>
6965 linked_ptr<T> make_linked_ptr(T* ptr) {
6966   return linked_ptr<T>(ptr);
6967 }
6968 
6969 }  // namespace internal
6970 }  // namespace testing
6971 
6972 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
6973 // Copyright 2007, Google Inc.
6974 // All rights reserved.
6975 //
6976 // Redistribution and use in source and binary forms, with or without
6977 // modification, are permitted provided that the following conditions are
6978 // met:
6979 //
6980 //     * Redistributions of source code must retain the above copyright
6981 // notice, this list of conditions and the following disclaimer.
6982 //     * Redistributions in binary form must reproduce the above
6983 // copyright notice, this list of conditions and the following disclaimer
6984 // in the documentation and/or other materials provided with the
6985 // distribution.
6986 //     * Neither the name of Google Inc. nor the names of its
6987 // contributors may be used to endorse or promote products derived from
6988 // this software without specific prior written permission.
6989 //
6990 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6991 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6992 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6993 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6994 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6995 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6996 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6997 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6998 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6999 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7000 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7001 //
7002 // Author: wan@google.com (Zhanyong Wan)
7003 
7004 // Google Test - The Google C++ Testing Framework
7005 //
7006 // This file implements a universal value printer that can print a
7007 // value of any type T:
7008 //
7009 //   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
7010 //
7011 // A user can teach this function how to print a class type T by
7012 // defining either operator<<() or PrintTo() in the namespace that
7013 // defines T.  More specifically, the FIRST defined function in the
7014 // following list will be used (assuming T is defined in namespace
7015 // foo):
7016 //
7017 //   1. foo::PrintTo(const T&, ostream*)
7018 //   2. operator<<(ostream&, const T&) defined in either foo or the
7019 //      global namespace.
7020 //
7021 // If none of the above is defined, it will print the debug string of
7022 // the value if it is a protocol buffer, or print the raw bytes in the
7023 // value otherwise.
7024 //
7025 // To aid debugging: when T is a reference type, the address of the
7026 // value is also printed; when T is a (const) char pointer, both the
7027 // pointer value and the NUL-terminated string it points to are
7028 // printed.
7029 //
7030 // We also provide some convenient wrappers:
7031 //
7032 //   // Prints a value to a string.  For a (const or not) char
7033 //   // pointer, the NUL-terminated string (but not the pointer) is
7034 //   // printed.
7035 //   std::string ::testing::PrintToString(const T& value);
7036 //
7037 //   // Prints a value tersely: for a reference type, the referenced
7038 //   // value (but not the address) is printed; for a (const or not) char
7039 //   // pointer, the NUL-terminated string (but not the pointer) is
7040 //   // printed.
7041 //   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
7042 //
7043 //   // Prints value using the type inferred by the compiler.  The difference
7044 //   // from UniversalTersePrint() is that this function prints both the
7045 //   // pointer and the NUL-terminated string for a (const or not) char pointer.
7046 //   void ::testing::internal::UniversalPrint(const T& value, ostream*);
7047 //
7048 //   // Prints the fields of a tuple tersely to a string vector, one
7049 //   // element for each field. Tuple support must be enabled in
7050 //   // gtest-port.h.
7051 //   std::vector<string> UniversalTersePrintTupleFieldsToStrings(
7052 //       const Tuple& value);
7053 //
7054 // Known limitation:
7055 //
7056 // The print primitives print the elements of an STL-style container
7057 // using the compiler-inferred type of *iter where iter is a
7058 // const_iterator of the container.  When const_iterator is an input
7059 // iterator but not a forward iterator, this inferred type may not
7060 // match value_type, and the print output may be incorrect.  In
7061 // practice, this is rarely a problem as for most containers
7062 // const_iterator is a forward iterator.  We'll fix this if there's an
7063 // actual need for it.  Note that this fix cannot rely on value_type
7064 // being defined as many user-defined container types don't have
7065 // value_type.
7066 
7067 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
7068 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
7069 
7070 #include <ostream>  // NOLINT
7071 #include <sstream>
7072 #include <string>
7073 #include <utility>
7074 #include <vector>
7075 
7076 #if GTEST_HAS_STD_TUPLE_
7077 # include <tuple>
7078 #endif
7079 
7080 namespace testing {
7081 
7082 // Definitions in the 'internal' and 'internal2' name spaces are
7083 // subject to change without notice.  DO NOT USE THEM IN USER CODE!
7084 namespace internal2 {
7085 
7086 // Prints the given number of bytes in the given object to the given
7087 // ostream.
7088 GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
7089                                      size_t count,
7090                                      ::std::ostream* os);
7091 
7092 // For selecting which printer to use when a given type has neither <<
7093 // nor PrintTo().
7094 enum TypeKind {
7095   kProtobuf,              // a protobuf type
7096   kConvertibleToInteger,  // a type implicitly convertible to BiggestInt
7097                           // (e.g. a named or unnamed enum type)
7098   kOtherType              // anything else
7099 };
7100 
7101 // TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
7102 // by the universal printer to print a value of type T when neither
7103 // operator<< nor PrintTo() is defined for T, where kTypeKind is the
7104 // "kind" of T as defined by enum TypeKind.
7105 template <typename T, TypeKind kTypeKind>
7106 class TypeWithoutFormatter {
7107  public:
7108   // This default version is called when kTypeKind is kOtherType.
7109   static void PrintValue(const T& value, ::std::ostream* os) {
7110     PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
7111                          sizeof(value), os);
7112   }
7113 };
7114 
7115 // We print a protobuf using its ShortDebugString() when the string
7116 // doesn't exceed this many characters; otherwise we print it using
7117 // DebugString() for better readability.
7118 const size_t kProtobufOneLinerMaxLength = 50;
7119 
7120 template <typename T>
7121 class TypeWithoutFormatter<T, kProtobuf> {
7122  public:
7123   static void PrintValue(const T& value, ::std::ostream* os) {
7124     const ::testing::internal::string short_str = value.ShortDebugString();
7125     const ::testing::internal::string pretty_str =
7126         short_str.length() <= kProtobufOneLinerMaxLength ?
7127         short_str : ("\n" + value.DebugString());
7128     *os << ("<" + pretty_str + ">");
7129   }
7130 };
7131 
7132 template <typename T>
7133 class TypeWithoutFormatter<T, kConvertibleToInteger> {
7134  public:
7135   // Since T has no << operator or PrintTo() but can be implicitly
7136   // converted to BiggestInt, we print it as a BiggestInt.
7137   //
7138   // Most likely T is an enum type (either named or unnamed), in which
7139   // case printing it as an integer is the desired behavior.  In case
7140   // T is not an enum, printing it as an integer is the best we can do
7141   // given that it has no user-defined printer.
7142   static void PrintValue(const T& value, ::std::ostream* os) {
7143     const internal::BiggestInt kBigInt = value;
7144     *os << kBigInt;
7145   }
7146 };
7147 
7148 // Prints the given value to the given ostream.  If the value is a
7149 // protocol message, its debug string is printed; if it's an enum or
7150 // of a type implicitly convertible to BiggestInt, it's printed as an
7151 // integer; otherwise the bytes in the value are printed.  This is
7152 // what UniversalPrinter<T>::Print() does when it knows nothing about
7153 // type T and T has neither << operator nor PrintTo().
7154 //
7155 // A user can override this behavior for a class type Foo by defining
7156 // a << operator in the namespace where Foo is defined.
7157 //
7158 // We put this operator in namespace 'internal2' instead of 'internal'
7159 // to simplify the implementation, as much code in 'internal' needs to
7160 // use << in STL, which would conflict with our own << were it defined
7161 // in 'internal'.
7162 //
7163 // Note that this operator<< takes a generic std::basic_ostream<Char,
7164 // CharTraits> type instead of the more restricted std::ostream.  If
7165 // we define it to take an std::ostream instead, we'll get an
7166 // "ambiguous overloads" compiler error when trying to print a type
7167 // Foo that supports streaming to std::basic_ostream<Char,
7168 // CharTraits>, as the compiler cannot tell whether
7169 // operator<<(std::ostream&, const T&) or
7170 // operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
7171 // specific.
7172 template <typename Char, typename CharTraits, typename T>
7173 ::std::basic_ostream<Char, CharTraits>& operator<<(
7174     ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
7175   TypeWithoutFormatter<T,
7176       (internal::IsAProtocolMessage<T>::value ? kProtobuf :
7177        internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
7178        kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
7179   return os;
7180 }
7181 
7182 }  // namespace internal2
7183 }  // namespace testing
7184 
7185 // This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
7186 // magic needed for implementing UniversalPrinter won't work.
7187 namespace testing_internal {
7188 
7189 // Used to print a value that is not an STL-style container when the
7190 // user doesn't define PrintTo() for it.
7191 template <typename T>
7192 void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
7193   // With the following statement, during unqualified name lookup,
7194   // testing::internal2::operator<< appears as if it was declared in
7195   // the nearest enclosing namespace that contains both
7196   // ::testing_internal and ::testing::internal2, i.e. the global
7197   // namespace.  For more details, refer to the C++ Standard section
7198   // 7.3.4-1 [namespace.udir].  This allows us to fall back onto
7199   // testing::internal2::operator<< in case T doesn't come with a <<
7200   // operator.
7201   //
7202   // We cannot write 'using ::testing::internal2::operator<<;', which
7203   // gcc 3.3 fails to compile due to a compiler bug.
7204   using namespace ::testing::internal2;  // NOLINT
7205 
7206   // Assuming T is defined in namespace foo, in the next statement,
7207   // the compiler will consider all of:
7208   //
7209   //   1. foo::operator<< (thanks to Koenig look-up),
7210   //   2. ::operator<< (as the current namespace is enclosed in ::),
7211   //   3. testing::internal2::operator<< (thanks to the using statement above).
7212   //
7213   // The operator<< whose type matches T best will be picked.
7214   //
7215   // We deliberately allow #2 to be a candidate, as sometimes it's
7216   // impossible to define #1 (e.g. when foo is ::std, defining
7217   // anything in it is undefined behavior unless you are a compiler
7218   // vendor.).
7219   *os << value;
7220 }
7221 
7222 }  // namespace testing_internal
7223 
7224 namespace testing {
7225 namespace internal {
7226 
7227 // FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
7228 // value of type ToPrint that is an operand of a comparison assertion
7229 // (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in
7230 // the comparison, and is used to help determine the best way to
7231 // format the value.  In particular, when the value is a C string
7232 // (char pointer) and the other operand is an STL string object, we
7233 // want to format the C string as a string, since we know it is
7234 // compared by value with the string object.  If the value is a char
7235 // pointer but the other operand is not an STL string object, we don't
7236 // know whether the pointer is supposed to point to a NUL-terminated
7237 // string, and thus want to print it as a pointer to be safe.
7238 //
7239 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
7240 
7241 // The default case.
7242 template <typename ToPrint, typename OtherOperand>
7243 class FormatForComparison {
7244  public:
7245   static ::std::string Format(const ToPrint& value) {
7246     return ::testing::PrintToString(value);
7247   }
7248 };
7249 
7250 // Array.
7251 template <typename ToPrint, size_t N, typename OtherOperand>
7252 class FormatForComparison<ToPrint[N], OtherOperand> {
7253  public:
7254   static ::std::string Format(const ToPrint* value) {
7255     return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
7256   }
7257 };
7258 
7259 // By default, print C string as pointers to be safe, as we don't know
7260 // whether they actually point to a NUL-terminated string.
7261 
7262 #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \
7263   template <typename OtherOperand>                                      \
7264   class FormatForComparison<CharType*, OtherOperand> {                  \
7265    public:                                                              \
7266     static ::std::string Format(CharType* value) {                      \
7267       return ::testing::PrintToString(static_cast<const void*>(value)); \
7268     }                                                                   \
7269   }
7270 
7271 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
7272 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
7273 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
7274 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
7275 
7276 #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
7277 
7278 // If a C string is compared with an STL string object, we know it's meant
7279 // to point to a NUL-terminated string, and thus can print it as a string.
7280 
7281 #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
7282   template <>                                                           \
7283   class FormatForComparison<CharType*, OtherStringType> {               \
7284    public:                                                              \
7285     static ::std::string Format(CharType* value) {                      \
7286       return ::testing::PrintToString(value);                           \
7287     }                                                                   \
7288   }
7289 
7290 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
7291 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
7292 
7293 #if GTEST_HAS_GLOBAL_STRING
7294 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);
7295 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);
7296 #endif
7297 
7298 #if GTEST_HAS_GLOBAL_WSTRING
7299 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);
7300 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);
7301 #endif
7302 
7303 #if GTEST_HAS_STD_WSTRING
7304 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
7305 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
7306 #endif
7307 
7308 #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
7309 
7310 // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
7311 // operand to be used in a failure message.  The type (but not value)
7312 // of the other operand may affect the format.  This allows us to
7313 // print a char* as a raw pointer when it is compared against another
7314 // char* or void*, and print it as a C string when it is compared
7315 // against an std::string object, for example.
7316 //
7317 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
7318 template <typename T1, typename T2>
7319 std::string FormatForComparisonFailureMessage(
7320     const T1& value, const T2& /* other_operand */) {
7321   return FormatForComparison<T1, T2>::Format(value);
7322 }
7323 
7324 // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
7325 // value to the given ostream.  The caller must ensure that
7326 // 'ostream_ptr' is not NULL, or the behavior is undefined.
7327 //
7328 // We define UniversalPrinter as a class template (as opposed to a
7329 // function template), as we need to partially specialize it for
7330 // reference types, which cannot be done with function templates.
7331 template <typename T>
7332 class UniversalPrinter;
7333 
7334 template <typename T>
7335 void UniversalPrint(const T& value, ::std::ostream* os);
7336 
7337 // Used to print an STL-style container when the user doesn't define
7338 // a PrintTo() for it.
7339 template <typename C>
7340 void DefaultPrintTo(IsContainer /* dummy */,
7341                     false_type /* is not a pointer */,
7342                     const C& container, ::std::ostream* os) {
7343   const size_t kMaxCount = 32;  // The maximum number of elements to print.
7344   *os << '{';
7345   size_t count = 0;
7346   for (typename C::const_iterator it = container.begin();
7347        it != container.end(); ++it, ++count) {
7348     if (count > 0) {
7349       *os << ',';
7350       if (count == kMaxCount) {  // Enough has been printed.
7351         *os << " ...";
7352         break;
7353       }
7354     }
7355     *os << ' ';
7356     // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
7357     // handle *it being a native array.
7358     internal::UniversalPrint(*it, os);
7359   }
7360 
7361   if (count > 0) {
7362     *os << ' ';
7363   }
7364   *os << '}';
7365 }
7366 
7367 // Used to print a pointer that is neither a char pointer nor a member
7368 // pointer, when the user doesn't define PrintTo() for it.  (A member
7369 // variable pointer or member function pointer doesn't really point to
7370 // a location in the address space.  Their representation is
7371 // implementation-defined.  Therefore they will be printed as raw
7372 // bytes.)
7373 template <typename T>
7374 void DefaultPrintTo(IsNotContainer /* dummy */,
7375                     true_type /* is a pointer */,
7376                     T* p, ::std::ostream* os) {
7377   if (p == NULL) {
7378     *os << "NULL";
7379   } else {
7380     // C++ doesn't allow casting from a function pointer to any object
7381     // pointer.
7382     //
7383     // IsTrue() silences warnings: "Condition is always true",
7384     // "unreachable code".
7385     if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
7386       // T is not a function type.  We just call << to print p,
7387       // relying on ADL to pick up user-defined << for their pointer
7388       // types, if any.
7389       *os << p;
7390     } else {
7391       // T is a function type, so '*os << p' doesn't do what we want
7392       // (it just prints p as bool).  We want to print p as a const
7393       // void*.  However, we cannot cast it to const void* directly,
7394       // even using reinterpret_cast, as earlier versions of gcc
7395       // (e.g. 3.4.5) cannot compile the cast when p is a function
7396       // pointer.  Casting to UInt64 first solves the problem.
7397       *os << reinterpret_cast<const void*>(
7398           reinterpret_cast<internal::UInt64>(p));
7399     }
7400   }
7401 }
7402 
7403 // Used to print a non-container, non-pointer value when the user
7404 // doesn't define PrintTo() for it.
7405 template <typename T>
7406 void DefaultPrintTo(IsNotContainer /* dummy */,
7407                     false_type /* is not a pointer */,
7408                     const T& value, ::std::ostream* os) {
7409   ::testing_internal::DefaultPrintNonContainerTo(value, os);
7410 }
7411 
7412 // Prints the given value using the << operator if it has one;
7413 // otherwise prints the bytes in it.  This is what
7414 // UniversalPrinter<T>::Print() does when PrintTo() is not specialized
7415 // or overloaded for type T.
7416 //
7417 // A user can override this behavior for a class type Foo by defining
7418 // an overload of PrintTo() in the namespace where Foo is defined.  We
7419 // give the user this option as sometimes defining a << operator for
7420 // Foo is not desirable (e.g. the coding style may prevent doing it,
7421 // or there is already a << operator but it doesn't do what the user
7422 // wants).
7423 template <typename T>
7424 void PrintTo(const T& value, ::std::ostream* os) {
7425   // DefaultPrintTo() is overloaded.  The type of its first two
7426   // arguments determine which version will be picked.  If T is an
7427   // STL-style container, the version for container will be called; if
7428   // T is a pointer, the pointer version will be called; otherwise the
7429   // generic version will be called.
7430   //
7431   // Note that we check for container types here, prior to we check
7432   // for protocol message types in our operator<<.  The rationale is:
7433   //
7434   // For protocol messages, we want to give people a chance to
7435   // override Google Mock's format by defining a PrintTo() or
7436   // operator<<.  For STL containers, other formats can be
7437   // incompatible with Google Mock's format for the container
7438   // elements; therefore we check for container types here to ensure
7439   // that our format is used.
7440   //
7441   // The second argument of DefaultPrintTo() is needed to bypass a bug
7442   // in Symbian's C++ compiler that prevents it from picking the right
7443   // overload between:
7444   //
7445   //   PrintTo(const T& x, ...);
7446   //   PrintTo(T* x, ...);
7447   DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
7448 }
7449 
7450 // The following list of PrintTo() overloads tells
7451 // UniversalPrinter<T>::Print() how to print standard types (built-in
7452 // types, strings, plain arrays, and pointers).
7453 
7454 // Overloads for various char types.
7455 GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
7456 GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
7457 inline void PrintTo(char c, ::std::ostream* os) {
7458   // When printing a plain char, we always treat it as unsigned.  This
7459   // way, the output won't be affected by whether the compiler thinks
7460   // char is signed or not.
7461   PrintTo(static_cast<unsigned char>(c), os);
7462 }
7463 
7464 // Overloads for other simple built-in types.
7465 inline void PrintTo(bool x, ::std::ostream* os) {
7466   *os << (x ? "true" : "false");
7467 }
7468 
7469 // Overload for wchar_t type.
7470 // Prints a wchar_t as a symbol if it is printable or as its internal
7471 // code otherwise and also as its decimal code (except for L'\0').
7472 // The L'\0' char is printed as "L'\\0'". The decimal code is printed
7473 // as signed integer when wchar_t is implemented by the compiler
7474 // as a signed type and is printed as an unsigned integer when wchar_t
7475 // is implemented as an unsigned type.
7476 GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
7477 
7478 // Overloads for C strings.
7479 GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
7480 inline void PrintTo(char* s, ::std::ostream* os) {
7481   PrintTo(ImplicitCast_<const char*>(s), os);
7482 }
7483 
7484 // signed/unsigned char is often used for representing binary data, so
7485 // we print pointers to it as void* to be safe.
7486 inline void PrintTo(const signed char* s, ::std::ostream* os) {
7487   PrintTo(ImplicitCast_<const void*>(s), os);
7488 }
7489 inline void PrintTo(signed char* s, ::std::ostream* os) {
7490   PrintTo(ImplicitCast_<const void*>(s), os);
7491 }
7492 inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
7493   PrintTo(ImplicitCast_<const void*>(s), os);
7494 }
7495 inline void PrintTo(unsigned char* s, ::std::ostream* os) {
7496   PrintTo(ImplicitCast_<const void*>(s), os);
7497 }
7498 
7499 // MSVC can be configured to define wchar_t as a typedef of unsigned
7500 // short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
7501 // type.  When wchar_t is a typedef, defining an overload for const
7502 // wchar_t* would cause unsigned short* be printed as a wide string,
7503 // possibly causing invalid memory accesses.
7504 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
7505 // Overloads for wide C strings
7506 GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
7507 inline void PrintTo(wchar_t* s, ::std::ostream* os) {
7508   PrintTo(ImplicitCast_<const wchar_t*>(s), os);
7509 }
7510 #endif
7511 
7512 // Overload for C arrays.  Multi-dimensional arrays are printed
7513 // properly.
7514 
7515 // Prints the given number of elements in an array, without printing
7516 // the curly braces.
7517 template <typename T>
7518 void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
7519   UniversalPrint(a[0], os);
7520   for (size_t i = 1; i != count; i++) {
7521     *os << ", ";
7522     UniversalPrint(a[i], os);
7523   }
7524 }
7525 
7526 // Overloads for ::string and ::std::string.
7527 #if GTEST_HAS_GLOBAL_STRING
7528 GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
7529 inline void PrintTo(const ::string& s, ::std::ostream* os) {
7530   PrintStringTo(s, os);
7531 }
7532 #endif  // GTEST_HAS_GLOBAL_STRING
7533 
7534 GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
7535 inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
7536   PrintStringTo(s, os);
7537 }
7538 
7539 // Overloads for ::wstring and ::std::wstring.
7540 #if GTEST_HAS_GLOBAL_WSTRING
7541 GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
7542 inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
7543   PrintWideStringTo(s, os);
7544 }
7545 #endif  // GTEST_HAS_GLOBAL_WSTRING
7546 
7547 #if GTEST_HAS_STD_WSTRING
7548 GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
7549 inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
7550   PrintWideStringTo(s, os);
7551 }
7552 #endif  // GTEST_HAS_STD_WSTRING
7553 
7554 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
7555 // Helper function for printing a tuple.  T must be instantiated with
7556 // a tuple type.
7557 template <typename T>
7558 void PrintTupleTo(const T& t, ::std::ostream* os);
7559 #endif  // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
7560 
7561 #if GTEST_HAS_TR1_TUPLE
7562 // Overload for ::std::tr1::tuple.  Needed for printing function arguments,
7563 // which are packed as tuples.
7564 
7565 // Overloaded PrintTo() for tuples of various arities.  We support
7566 // tuples of up-to 10 fields.  The following implementation works
7567 // regardless of whether tr1::tuple is implemented using the
7568 // non-standard variadic template feature or not.
7569 
7570 inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
7571   PrintTupleTo(t, os);
7572 }
7573 
7574 template <typename T1>
7575 void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
7576   PrintTupleTo(t, os);
7577 }
7578 
7579 template <typename T1, typename T2>
7580 void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
7581   PrintTupleTo(t, os);
7582 }
7583 
7584 template <typename T1, typename T2, typename T3>
7585 void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
7586   PrintTupleTo(t, os);
7587 }
7588 
7589 template <typename T1, typename T2, typename T3, typename T4>
7590 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
7591   PrintTupleTo(t, os);
7592 }
7593 
7594 template <typename T1, typename T2, typename T3, typename T4, typename T5>
7595 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
7596              ::std::ostream* os) {
7597   PrintTupleTo(t, os);
7598 }
7599 
7600 template <typename T1, typename T2, typename T3, typename T4, typename T5,
7601           typename T6>
7602 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
7603              ::std::ostream* os) {
7604   PrintTupleTo(t, os);
7605 }
7606 
7607 template <typename T1, typename T2, typename T3, typename T4, typename T5,
7608           typename T6, typename T7>
7609 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
7610              ::std::ostream* os) {
7611   PrintTupleTo(t, os);
7612 }
7613 
7614 template <typename T1, typename T2, typename T3, typename T4, typename T5,
7615           typename T6, typename T7, typename T8>
7616 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
7617              ::std::ostream* os) {
7618   PrintTupleTo(t, os);
7619 }
7620 
7621 template <typename T1, typename T2, typename T3, typename T4, typename T5,
7622           typename T6, typename T7, typename T8, typename T9>
7623 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
7624              ::std::ostream* os) {
7625   PrintTupleTo(t, os);
7626 }
7627 
7628 template <typename T1, typename T2, typename T3, typename T4, typename T5,
7629           typename T6, typename T7, typename T8, typename T9, typename T10>
7630 void PrintTo(
7631     const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
7632     ::std::ostream* os) {
7633   PrintTupleTo(t, os);
7634 }
7635 #endif  // GTEST_HAS_TR1_TUPLE
7636 
7637 #if GTEST_HAS_STD_TUPLE_
7638 template <typename... Types>
7639 void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
7640   PrintTupleTo(t, os);
7641 }
7642 #endif  // GTEST_HAS_STD_TUPLE_
7643 
7644 // Overload for std::pair.
7645 template <typename T1, typename T2>
7646 void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
7647   *os << '(';
7648   // We cannot use UniversalPrint(value.first, os) here, as T1 may be
7649   // a reference type.  The same for printing value.second.
7650   UniversalPrinter<T1>::Print(value.first, os);
7651   *os << ", ";
7652   UniversalPrinter<T2>::Print(value.second, os);
7653   *os << ')';
7654 }
7655 
7656 // Implements printing a non-reference type T by letting the compiler
7657 // pick the right overload of PrintTo() for T.
7658 template <typename T>
7659 class UniversalPrinter {
7660  public:
7661   // MSVC warns about adding const to a function type, so we want to
7662   // disable the warning.
7663   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
7664 
7665   // Note: we deliberately don't call this PrintTo(), as that name
7666   // conflicts with ::testing::internal::PrintTo in the body of the
7667   // function.
7668   static void Print(const T& value, ::std::ostream* os) {
7669     // By default, ::testing::internal::PrintTo() is used for printing
7670     // the value.
7671     //
7672     // Thanks to Koenig look-up, if T is a class and has its own
7673     // PrintTo() function defined in its namespace, that function will
7674     // be visible here.  Since it is more specific than the generic ones
7675     // in ::testing::internal, it will be picked by the compiler in the
7676     // following statement - exactly what we want.
7677     PrintTo(value, os);
7678   }
7679 
7680   GTEST_DISABLE_MSC_WARNINGS_POP_()
7681 };
7682 
7683 // UniversalPrintArray(begin, len, os) prints an array of 'len'
7684 // elements, starting at address 'begin'.
7685 template <typename T>
7686 void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
7687   if (len == 0) {
7688     *os << "{}";
7689   } else {
7690     *os << "{ ";
7691     const size_t kThreshold = 18;
7692     const size_t kChunkSize = 8;
7693     // If the array has more than kThreshold elements, we'll have to
7694     // omit some details by printing only the first and the last
7695     // kChunkSize elements.
7696     // TODO(wan@google.com): let the user control the threshold using a flag.
7697     if (len <= kThreshold) {
7698       PrintRawArrayTo(begin, len, os);
7699     } else {
7700       PrintRawArrayTo(begin, kChunkSize, os);
7701       *os << ", ..., ";
7702       PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
7703     }
7704     *os << " }";
7705   }
7706 }
7707 // This overload prints a (const) char array compactly.
7708 GTEST_API_ void UniversalPrintArray(
7709     const char* begin, size_t len, ::std::ostream* os);
7710 
7711 // This overload prints a (const) wchar_t array compactly.
7712 GTEST_API_ void UniversalPrintArray(
7713     const wchar_t* begin, size_t len, ::std::ostream* os);
7714 
7715 // Implements printing an array type T[N].
7716 template <typename T, size_t N>
7717 class UniversalPrinter<T[N]> {
7718  public:
7719   // Prints the given array, omitting some elements when there are too
7720   // many.
7721   static void Print(const T (&a)[N], ::std::ostream* os) {
7722     UniversalPrintArray(a, N, os);
7723   }
7724 };
7725 
7726 // Implements printing a reference type T&.
7727 template <typename T>
7728 class UniversalPrinter<T&> {
7729  public:
7730   // MSVC warns about adding const to a function type, so we want to
7731   // disable the warning.
7732   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
7733 
7734   static void Print(const T& value, ::std::ostream* os) {
7735     // Prints the address of the value.  We use reinterpret_cast here
7736     // as static_cast doesn't compile when T is a function type.
7737     *os << "@" << reinterpret_cast<const void*>(&value) << " ";
7738 
7739     // Then prints the value itself.
7740     UniversalPrint(value, os);
7741   }
7742 
7743   GTEST_DISABLE_MSC_WARNINGS_POP_()
7744 };
7745 
7746 // Prints a value tersely: for a reference type, the referenced value
7747 // (but not the address) is printed; for a (const) char pointer, the
7748 // NUL-terminated string (but not the pointer) is printed.
7749 
7750 template <typename T>
7751 class UniversalTersePrinter {
7752  public:
7753   static void Print(const T& value, ::std::ostream* os) {
7754     UniversalPrint(value, os);
7755   }
7756 };
7757 template <typename T>
7758 class UniversalTersePrinter<T&> {
7759  public:
7760   static void Print(const T& value, ::std::ostream* os) {
7761     UniversalPrint(value, os);
7762   }
7763 };
7764 template <typename T, size_t N>
7765 class UniversalTersePrinter<T[N]> {
7766  public:
7767   static void Print(const T (&value)[N], ::std::ostream* os) {
7768     UniversalPrinter<T[N]>::Print(value, os);
7769   }
7770 };
7771 template <>
7772 class UniversalTersePrinter<const char*> {
7773  public:
7774   static void Print(const char* str, ::std::ostream* os) {
7775     if (str == NULL) {
7776       *os << "NULL";
7777     } else {
7778       UniversalPrint(string(str), os);
7779     }
7780   }
7781 };
7782 template <>
7783 class UniversalTersePrinter<char*> {
7784  public:
7785   static void Print(char* str, ::std::ostream* os) {
7786     UniversalTersePrinter<const char*>::Print(str, os);
7787   }
7788 };
7789 
7790 #if GTEST_HAS_STD_WSTRING
7791 template <>
7792 class UniversalTersePrinter<const wchar_t*> {
7793  public:
7794   static void Print(const wchar_t* str, ::std::ostream* os) {
7795     if (str == NULL) {
7796       *os << "NULL";
7797     } else {
7798       UniversalPrint(::std::wstring(str), os);
7799     }
7800   }
7801 };
7802 #endif
7803 
7804 template <>
7805 class UniversalTersePrinter<wchar_t*> {
7806  public:
7807   static void Print(wchar_t* str, ::std::ostream* os) {
7808     UniversalTersePrinter<const wchar_t*>::Print(str, os);
7809   }
7810 };
7811 
7812 template <typename T>
7813 void UniversalTersePrint(const T& value, ::std::ostream* os) {
7814   UniversalTersePrinter<T>::Print(value, os);
7815 }
7816 
7817 // Prints a value using the type inferred by the compiler.  The
7818 // difference between this and UniversalTersePrint() is that for a
7819 // (const) char pointer, this prints both the pointer and the
7820 // NUL-terminated string.
7821 template <typename T>
7822 void UniversalPrint(const T& value, ::std::ostream* os) {
7823   // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
7824   // UniversalPrinter with T directly.
7825   typedef T T1;
7826   UniversalPrinter<T1>::Print(value, os);
7827 }
7828 
7829 typedef ::std::vector<string> Strings;
7830 
7831 // TuplePolicy<TupleT> must provide:
7832 // - tuple_size
7833 //     size of tuple TupleT.
7834 // - get<size_t I>(const TupleT& t)
7835 //     static function extracting element I of tuple TupleT.
7836 // - tuple_element<size_t I>::type
7837 //     type of element I of tuple TupleT.
7838 template <typename TupleT>
7839 struct TuplePolicy;
7840 
7841 #if GTEST_HAS_TR1_TUPLE
7842 template <typename TupleT>
7843 struct TuplePolicy {
7844   typedef TupleT Tuple;
7845   static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;
7846 
7847   template <size_t I>
7848   struct tuple_element : ::std::tr1::tuple_element<I, Tuple> {};
7849 
7850   template <size_t I>
7851   static typename AddReference<
7852       const typename ::std::tr1::tuple_element<I, Tuple>::type>::type get(
7853       const Tuple& tuple) {
7854     return ::std::tr1::get<I>(tuple);
7855   }
7856 };
7857 template <typename TupleT>
7858 const size_t TuplePolicy<TupleT>::tuple_size;
7859 #endif  // GTEST_HAS_TR1_TUPLE
7860 
7861 #if GTEST_HAS_STD_TUPLE_
7862 template <typename... Types>
7863 struct TuplePolicy< ::std::tuple<Types...> > {
7864   typedef ::std::tuple<Types...> Tuple;
7865   static const size_t tuple_size = ::std::tuple_size<Tuple>::value;
7866 
7867   template <size_t I>
7868   struct tuple_element : ::std::tuple_element<I, Tuple> {};
7869 
7870   template <size_t I>
7871   static const typename ::std::tuple_element<I, Tuple>::type& get(
7872       const Tuple& tuple) {
7873     return ::std::get<I>(tuple);
7874   }
7875 };
7876 template <typename... Types>
7877 const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;
7878 #endif  // GTEST_HAS_STD_TUPLE_
7879 
7880 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
7881 // This helper template allows PrintTo() for tuples and
7882 // UniversalTersePrintTupleFieldsToStrings() to be defined by
7883 // induction on the number of tuple fields.  The idea is that
7884 // TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
7885 // fields in tuple t, and can be defined in terms of
7886 // TuplePrefixPrinter<N - 1>.
7887 //
7888 // The inductive case.
7889 template <size_t N>
7890 struct TuplePrefixPrinter {
7891   // Prints the first N fields of a tuple.
7892   template <typename Tuple>
7893   static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
7894     TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
7895     GTEST_INTENTIONAL_CONST_COND_PUSH_()
7896     if (N > 1) {
7897     GTEST_INTENTIONAL_CONST_COND_POP_()
7898       *os << ", ";
7899     }
7900     UniversalPrinter<
7901         typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type>
7902         ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);
7903   }
7904 
7905   // Tersely prints the first N fields of a tuple to a string vector,
7906   // one element for each field.
7907   template <typename Tuple>
7908   static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
7909     TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
7910     ::std::stringstream ss;
7911     UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);
7912     strings->push_back(ss.str());
7913   }
7914 };
7915 
7916 // Base case.
7917 template <>
7918 struct TuplePrefixPrinter<0> {
7919   template <typename Tuple>
7920   static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
7921 
7922   template <typename Tuple>
7923   static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
7924 };
7925 
7926 // Helper function for printing a tuple.
7927 // Tuple must be either std::tr1::tuple or std::tuple type.
7928 template <typename Tuple>
7929 void PrintTupleTo(const Tuple& t, ::std::ostream* os) {
7930   *os << "(";
7931   TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);
7932   *os << ")";
7933 }
7934 
7935 // Prints the fields of a tuple tersely to a string vector, one
7936 // element for each field.  See the comment before
7937 // UniversalTersePrint() for how we define "tersely".
7938 template <typename Tuple>
7939 Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
7940   Strings result;
7941   TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::
7942       TersePrintPrefixToStrings(value, &result);
7943   return result;
7944 }
7945 #endif  // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
7946 
7947 }  // namespace internal
7948 
7949 template <typename T>
7950 ::std::string PrintToString(const T& value) {
7951   ::std::stringstream ss;
7952   internal::UniversalTersePrinter<T>::Print(value, &ss);
7953   return ss.str();
7954 }
7955 
7956 }  // namespace testing
7957 
7958 // Include any custom printer added by the local installation.
7959 // We must include this header at the end to make sure it can use the
7960 // declarations from this file.
7961 // Copyright 2015, Google Inc.
7962 // All rights reserved.
7963 //
7964 // Redistribution and use in source and binary forms, with or without
7965 // modification, are permitted provided that the following conditions are
7966 // met:
7967 //
7968 //     * Redistributions of source code must retain the above copyright
7969 // notice, this list of conditions and the following disclaimer.
7970 //     * Redistributions in binary form must reproduce the above
7971 // copyright notice, this list of conditions and the following disclaimer
7972 // in the documentation and/or other materials provided with the
7973 // distribution.
7974 //     * Neither the name of Google Inc. nor the names of its
7975 // contributors may be used to endorse or promote products derived from
7976 // this software without specific prior written permission.
7977 //
7978 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7979 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7980 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7981 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7982 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7983 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7984 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7985 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7986 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7987 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7988 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7989 //
7990 // This file provides an injection point for custom printers in a local
7991 // installation of gTest.
7992 // It will be included from gtest-printers.h and the overrides in this file
7993 // will be visible to everyone.
7994 // See documentation at gtest/gtest-printers.h for details on how to define a
7995 // custom printer.
7996 //
7997 // ** Custom implementation starts here **
7998 
7999 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8000 #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8001 
8002 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8003 
8004 #endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8005 
8006 #if GTEST_HAS_PARAM_TEST
8007 
8008 namespace testing {
8009 
8010 // Input to a parameterized test name generator, describing a test parameter.
8011 // Consists of the parameter value and the integer parameter index.
8012 template <class ParamType>
8013 struct TestParamInfo {
8014   TestParamInfo(const ParamType& a_param, size_t an_index) :
8015     param(a_param),
8016     index(an_index) {}
8017   ParamType param;
8018   size_t index;
8019 };
8020 
8021 // A builtin parameterized test name generator which returns the result of
8022 // testing::PrintToString.
8023 struct PrintToStringParamName {
8024   template <class ParamType>
8025   std::string operator()(const TestParamInfo<ParamType>& info) const {
8026     return PrintToString(info.param);
8027   }
8028 };
8029 
8030 namespace internal {
8031 
8032 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8033 //
8034 // Outputs a message explaining invalid registration of different
8035 // fixture class for the same test case. This may happen when
8036 // TEST_P macro is used to define two tests with the same name
8037 // but in different namespaces.
8038 GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
8039                                           CodeLocation code_location);
8040 
8041 template <typename> class ParamGeneratorInterface;
8042 template <typename> class ParamGenerator;
8043 
8044 // Interface for iterating over elements provided by an implementation
8045 // of ParamGeneratorInterface<T>.
8046 template <typename T>
8047 class ParamIteratorInterface {
8048  public:
8049   virtual ~ParamIteratorInterface() {}
8050   // A pointer to the base generator instance.
8051   // Used only for the purposes of iterator comparison
8052   // to make sure that two iterators belong to the same generator.
8053   virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
8054   // Advances iterator to point to the next element
8055   // provided by the generator. The caller is responsible
8056   // for not calling Advance() on an iterator equal to
8057   // BaseGenerator()->End().
8058   virtual void Advance() = 0;
8059   // Clones the iterator object. Used for implementing copy semantics
8060   // of ParamIterator<T>.
8061   virtual ParamIteratorInterface* Clone() const = 0;
8062   // Dereferences the current iterator and provides (read-only) access
8063   // to the pointed value. It is the caller's responsibility not to call
8064   // Current() on an iterator equal to BaseGenerator()->End().
8065   // Used for implementing ParamGenerator<T>::operator*().
8066   virtual const T* Current() const = 0;
8067   // Determines whether the given iterator and other point to the same
8068   // element in the sequence generated by the generator.
8069   // Used for implementing ParamGenerator<T>::operator==().
8070   virtual bool Equals(const ParamIteratorInterface& other) const = 0;
8071 };
8072 
8073 // Class iterating over elements provided by an implementation of
8074 // ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
8075 // and implements the const forward iterator concept.
8076 template <typename T>
8077 class ParamIterator {
8078  public:
8079   typedef T value_type;
8080   typedef const T& reference;
8081   typedef ptrdiff_t difference_type;
8082 
8083   // ParamIterator assumes ownership of the impl_ pointer.
8084   ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
8085   ParamIterator& operator=(const ParamIterator& other) {
8086     if (this != &other)
8087       impl_.reset(other.impl_->Clone());
8088     return *this;
8089   }
8090 
8091   const T& operator*() const { return *impl_->Current(); }
8092   const T* operator->() const { return impl_->Current(); }
8093   // Prefix version of operator++.
8094   ParamIterator& operator++() {
8095     impl_->Advance();
8096     return *this;
8097   }
8098   // Postfix version of operator++.
8099   ParamIterator operator++(int /*unused*/) {
8100     ParamIteratorInterface<T>* clone = impl_->Clone();
8101     impl_->Advance();
8102     return ParamIterator(clone);
8103   }
8104   bool operator==(const ParamIterator& other) const {
8105     return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
8106   }
8107   bool operator!=(const ParamIterator& other) const {
8108     return !(*this == other);
8109   }
8110 
8111  private:
8112   friend class ParamGenerator<T>;
8113   explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
8114   scoped_ptr<ParamIteratorInterface<T> > impl_;
8115 };
8116 
8117 // ParamGeneratorInterface<T> is the binary interface to access generators
8118 // defined in other translation units.
8119 template <typename T>
8120 class ParamGeneratorInterface {
8121  public:
8122   typedef T ParamType;
8123 
8124   virtual ~ParamGeneratorInterface() {}
8125 
8126   // Generator interface definition
8127   virtual ParamIteratorInterface<T>* Begin() const = 0;
8128   virtual ParamIteratorInterface<T>* End() const = 0;
8129 };
8130 
8131 // Wraps ParamGeneratorInterface<T> and provides general generator syntax
8132 // compatible with the STL Container concept.
8133 // This class implements copy initialization semantics and the contained
8134 // ParamGeneratorInterface<T> instance is shared among all copies
8135 // of the original object. This is possible because that instance is immutable.
8136 template<typename T>
8137 class ParamGenerator {
8138  public:
8139   typedef ParamIterator<T> iterator;
8140 
8141   explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
8142   ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
8143 
8144   ParamGenerator& operator=(const ParamGenerator& other) {
8145     impl_ = other.impl_;
8146     return *this;
8147   }
8148 
8149   iterator begin() const { return iterator(impl_->Begin()); }
8150   iterator end() const { return iterator(impl_->End()); }
8151 
8152  private:
8153   linked_ptr<const ParamGeneratorInterface<T> > impl_;
8154 };
8155 
8156 // Generates values from a range of two comparable values. Can be used to
8157 // generate sequences of user-defined types that implement operator+() and
8158 // operator<().
8159 // This class is used in the Range() function.
8160 template <typename T, typename IncrementT>
8161 class RangeGenerator : public ParamGeneratorInterface<T> {
8162  public:
8163   RangeGenerator(T begin, T end, IncrementT step)
8164       : begin_(begin), end_(end),
8165         step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
8166   virtual ~RangeGenerator() {}
8167 
8168   virtual ParamIteratorInterface<T>* Begin() const {
8169     return new Iterator(this, begin_, 0, step_);
8170   }
8171   virtual ParamIteratorInterface<T>* End() const {
8172     return new Iterator(this, end_, end_index_, step_);
8173   }
8174 
8175  private:
8176   class Iterator : public ParamIteratorInterface<T> {
8177    public:
8178     Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
8179              IncrementT step)
8180         : base_(base), value_(value), index_(index), step_(step) {}
8181     virtual ~Iterator() {}
8182 
8183     virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
8184       return base_;
8185     }
8186     virtual void Advance() {
8187       value_ = static_cast<T>(value_ + step_);
8188       index_++;
8189     }
8190     virtual ParamIteratorInterface<T>* Clone() const {
8191       return new Iterator(*this);
8192     }
8193     virtual const T* Current() const { return &value_; }
8194     virtual bool Equals(const ParamIteratorInterface<T>& other) const {
8195       // Having the same base generator guarantees that the other
8196       // iterator is of the same type and we can downcast.
8197       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
8198           << "The program attempted to compare iterators "
8199           << "from different generators." << std::endl;
8200       const int other_index =
8201           CheckedDowncastToActualType<const Iterator>(&other)->index_;
8202       return index_ == other_index;
8203     }
8204 
8205    private:
8206     Iterator(const Iterator& other)
8207         : ParamIteratorInterface<T>(),
8208           base_(other.base_), value_(other.value_), index_(other.index_),
8209           step_(other.step_) {}
8210 
8211     // No implementation - assignment is unsupported.
8212     void operator=(const Iterator& other);
8213 
8214     const ParamGeneratorInterface<T>* const base_;
8215     T value_;
8216     int index_;
8217     const IncrementT step_;
8218   };  // class RangeGenerator::Iterator
8219 
8220   static int CalculateEndIndex(const T& begin,
8221                                const T& end,
8222                                const IncrementT& step) {
8223     int end_index = 0;
8224     for (T i = begin; i < end; i = static_cast<T>(i + step))
8225       end_index++;
8226     return end_index;
8227   }
8228 
8229   // No implementation - assignment is unsupported.
8230   void operator=(const RangeGenerator& other);
8231 
8232   const T begin_;
8233   const T end_;
8234   const IncrementT step_;
8235   // The index for the end() iterator. All the elements in the generated
8236   // sequence are indexed (0-based) to aid iterator comparison.
8237   const int end_index_;
8238 };  // class RangeGenerator
8239 
8240 
8241 // Generates values from a pair of STL-style iterators. Used in the
8242 // ValuesIn() function. The elements are copied from the source range
8243 // since the source can be located on the stack, and the generator
8244 // is likely to persist beyond that stack frame.
8245 template <typename T>
8246 class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
8247  public:
8248   template <typename ForwardIterator>
8249   ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
8250       : container_(begin, end) {}
8251   virtual ~ValuesInIteratorRangeGenerator() {}
8252 
8253   virtual ParamIteratorInterface<T>* Begin() const {
8254     return new Iterator(this, container_.begin());
8255   }
8256   virtual ParamIteratorInterface<T>* End() const {
8257     return new Iterator(this, container_.end());
8258   }
8259 
8260  private:
8261   typedef typename ::std::vector<T> ContainerType;
8262 
8263   class Iterator : public ParamIteratorInterface<T> {
8264    public:
8265     Iterator(const ParamGeneratorInterface<T>* base,
8266              typename ContainerType::const_iterator iterator)
8267         : base_(base), iterator_(iterator) {}
8268     virtual ~Iterator() {}
8269 
8270     virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
8271       return base_;
8272     }
8273     virtual void Advance() {
8274       ++iterator_;
8275       value_.reset();
8276     }
8277     virtual ParamIteratorInterface<T>* Clone() const {
8278       return new Iterator(*this);
8279     }
8280     // We need to use cached value referenced by iterator_ because *iterator_
8281     // can return a temporary object (and of type other then T), so just
8282     // having "return &*iterator_;" doesn't work.
8283     // value_ is updated here and not in Advance() because Advance()
8284     // can advance iterator_ beyond the end of the range, and we cannot
8285     // detect that fact. The client code, on the other hand, is
8286     // responsible for not calling Current() on an out-of-range iterator.
8287     virtual const T* Current() const {
8288       if (value_.get() == NULL)
8289         value_.reset(new T(*iterator_));
8290       return value_.get();
8291     }
8292     virtual bool Equals(const ParamIteratorInterface<T>& other) const {
8293       // Having the same base generator guarantees that the other
8294       // iterator is of the same type and we can downcast.
8295       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
8296           << "The program attempted to compare iterators "
8297           << "from different generators." << std::endl;
8298       return iterator_ ==
8299           CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
8300     }
8301 
8302    private:
8303     Iterator(const Iterator& other)
8304           // The explicit constructor call suppresses a false warning
8305           // emitted by gcc when supplied with the -Wextra option.
8306         : ParamIteratorInterface<T>(),
8307           base_(other.base_),
8308           iterator_(other.iterator_) {}
8309 
8310     const ParamGeneratorInterface<T>* const base_;
8311     typename ContainerType::const_iterator iterator_;
8312     // A cached value of *iterator_. We keep it here to allow access by
8313     // pointer in the wrapping iterator's operator->().
8314     // value_ needs to be mutable to be accessed in Current().
8315     // Use of scoped_ptr helps manage cached value's lifetime,
8316     // which is bound by the lifespan of the iterator itself.
8317     mutable scoped_ptr<const T> value_;
8318   };  // class ValuesInIteratorRangeGenerator::Iterator
8319 
8320   // No implementation - assignment is unsupported.
8321   void operator=(const ValuesInIteratorRangeGenerator& other);
8322 
8323   const ContainerType container_;
8324 };  // class ValuesInIteratorRangeGenerator
8325 
8326 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8327 //
8328 // Default parameterized test name generator, returns a string containing the
8329 // integer test parameter index.
8330 template <class ParamType>
8331 std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
8332   Message name_stream;
8333   name_stream << info.index;
8334   return name_stream.GetString();
8335 }
8336 
8337 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8338 //
8339 // Parameterized test name overload helpers, which help the
8340 // INSTANTIATE_TEST_CASE_P macro choose between the default parameterized
8341 // test name generator and user param name generator.
8342 template <class ParamType, class ParamNameGenFunctor>
8343 ParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) {
8344   return func;
8345 }
8346 
8347 template <class ParamType>
8348 struct ParamNameGenFunc {
8349   typedef std::string Type(const TestParamInfo<ParamType>&);
8350 };
8351 
8352 template <class ParamType>
8353 typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
8354   return DefaultParamName;
8355 }
8356 
8357 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8358 //
8359 // Stores a parameter value and later creates tests parameterized with that
8360 // value.
8361 template <class TestClass>
8362 class ParameterizedTestFactory : public TestFactoryBase {
8363  public:
8364   typedef typename TestClass::ParamType ParamType;
8365   explicit ParameterizedTestFactory(ParamType parameter) :
8366       parameter_(parameter) {}
8367   virtual Test* CreateTest() {
8368     TestClass::SetParam(&parameter_);
8369     return new TestClass();
8370   }
8371 
8372  private:
8373   const ParamType parameter_;
8374 
8375   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
8376 };
8377 
8378 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8379 //
8380 // TestMetaFactoryBase is a base class for meta-factories that create
8381 // test factories for passing into MakeAndRegisterTestInfo function.
8382 template <class ParamType>
8383 class TestMetaFactoryBase {
8384  public:
8385   virtual ~TestMetaFactoryBase() {}
8386 
8387   virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
8388 };
8389 
8390 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8391 //
8392 // TestMetaFactory creates test factories for passing into
8393 // MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
8394 // ownership of test factory pointer, same factory object cannot be passed
8395 // into that method twice. But ParameterizedTestCaseInfo is going to call
8396 // it for each Test/Parameter value combination. Thus it needs meta factory
8397 // creator class.
8398 template <class TestCase>
8399 class TestMetaFactory
8400     : public TestMetaFactoryBase<typename TestCase::ParamType> {
8401  public:
8402   typedef typename TestCase::ParamType ParamType;
8403 
8404   TestMetaFactory() {}
8405 
8406   virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {
8407     return new ParameterizedTestFactory<TestCase>(parameter);
8408   }
8409 
8410  private:
8411   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
8412 };
8413 
8414 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8415 //
8416 // ParameterizedTestCaseInfoBase is a generic interface
8417 // to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase
8418 // accumulates test information provided by TEST_P macro invocations
8419 // and generators provided by INSTANTIATE_TEST_CASE_P macro invocations
8420 // and uses that information to register all resulting test instances
8421 // in RegisterTests method. The ParameterizeTestCaseRegistry class holds
8422 // a collection of pointers to the ParameterizedTestCaseInfo objects
8423 // and calls RegisterTests() on each of them when asked.
8424 class ParameterizedTestCaseInfoBase {
8425  public:
8426   virtual ~ParameterizedTestCaseInfoBase() {}
8427 
8428   // Base part of test case name for display purposes.
8429   virtual const string& GetTestCaseName() const = 0;
8430   // Test case id to verify identity.
8431   virtual TypeId GetTestCaseTypeId() const = 0;
8432   // UnitTest class invokes this method to register tests in this
8433   // test case right before running them in RUN_ALL_TESTS macro.
8434   // This method should not be called more then once on any single
8435   // instance of a ParameterizedTestCaseInfoBase derived class.
8436   virtual void RegisterTests() = 0;
8437 
8438  protected:
8439   ParameterizedTestCaseInfoBase() {}
8440 
8441  private:
8442   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);
8443 };
8444 
8445 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8446 //
8447 // ParameterizedTestCaseInfo accumulates tests obtained from TEST_P
8448 // macro invocations for a particular test case and generators
8449 // obtained from INSTANTIATE_TEST_CASE_P macro invocations for that
8450 // test case. It registers tests with all values generated by all
8451 // generators when asked.
8452 template <class TestCase>
8453 class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
8454  public:
8455   // ParamType and GeneratorCreationFunc are private types but are required
8456   // for declarations of public methods AddTestPattern() and
8457   // AddTestCaseInstantiation().
8458   typedef typename TestCase::ParamType ParamType;
8459   // A function that returns an instance of appropriate generator type.
8460   typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
8461   typedef typename ParamNameGenFunc<ParamType>::Type ParamNameGeneratorFunc;
8462 
8463   explicit ParameterizedTestCaseInfo(
8464       const char* name, CodeLocation code_location)
8465       : test_case_name_(name), code_location_(code_location) {}
8466 
8467   // Test case base name for display purposes.
8468   virtual const string& GetTestCaseName() const { return test_case_name_; }
8469   // Test case id to verify identity.
8470   virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
8471   // TEST_P macro uses AddTestPattern() to record information
8472   // about a single test in a LocalTestInfo structure.
8473   // test_case_name is the base name of the test case (without invocation
8474   // prefix). test_base_name is the name of an individual test without
8475   // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
8476   // test case base name and DoBar is test base name.
8477   void AddTestPattern(const char* test_case_name,
8478                       const char* test_base_name,
8479                       TestMetaFactoryBase<ParamType>* meta_factory) {
8480     tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
8481                                                        test_base_name,
8482                                                        meta_factory)));
8483   }
8484   // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
8485   // about a generator.
8486   int AddTestCaseInstantiation(const string& instantiation_name,
8487                                GeneratorCreationFunc* func,
8488                                ParamNameGeneratorFunc* name_func,
8489                                const char* file,
8490                                int line) {
8491     instantiations_.push_back(
8492         InstantiationInfo(instantiation_name, func, name_func, file, line));
8493     return 0;  // Return value used only to run this method in namespace scope.
8494   }
8495   // UnitTest class invokes this method to register tests in this test case
8496   // test cases right before running tests in RUN_ALL_TESTS macro.
8497   // This method should not be called more then once on any single
8498   // instance of a ParameterizedTestCaseInfoBase derived class.
8499   // UnitTest has a guard to prevent from calling this method more then once.
8500   virtual void RegisterTests() {
8501     for (typename TestInfoContainer::iterator test_it = tests_.begin();
8502          test_it != tests_.end(); ++test_it) {
8503       linked_ptr<TestInfo> test_info = *test_it;
8504       for (typename InstantiationContainer::iterator gen_it =
8505                instantiations_.begin(); gen_it != instantiations_.end();
8506                ++gen_it) {
8507         const string& instantiation_name = gen_it->name;
8508         ParamGenerator<ParamType> generator((*gen_it->generator)());
8509         ParamNameGeneratorFunc* name_func = gen_it->name_func;
8510         const char* file = gen_it->file;
8511         int line = gen_it->line;
8512 
8513         string test_case_name;
8514         if ( !instantiation_name.empty() )
8515           test_case_name = instantiation_name + "/";
8516         test_case_name += test_info->test_case_base_name;
8517 
8518         size_t i = 0;
8519         std::set<std::string> test_param_names;
8520         for (typename ParamGenerator<ParamType>::iterator param_it =
8521                  generator.begin();
8522              param_it != generator.end(); ++param_it, ++i) {
8523           Message test_name_stream;
8524 
8525           std::string param_name = name_func(
8526               TestParamInfo<ParamType>(*param_it, i));
8527 
8528           GTEST_CHECK_(IsValidParamName(param_name))
8529               << "Parameterized test name '" << param_name
8530               << "' is invalid, in " << file
8531               << " line " << line << std::endl;
8532 
8533           GTEST_CHECK_(test_param_names.count(param_name) == 0)
8534               << "Duplicate parameterized test name '" << param_name
8535               << "', in " << file << " line " << line << std::endl;
8536 
8537           test_param_names.insert(param_name);
8538 
8539           test_name_stream << test_info->test_base_name << "/" << param_name;
8540           MakeAndRegisterTestInfo(
8541               test_case_name.c_str(),
8542               test_name_stream.GetString().c_str(),
8543               NULL,  // No type parameter.
8544               PrintToString(*param_it).c_str(),
8545               code_location_,
8546               GetTestCaseTypeId(),
8547               TestCase::SetUpTestCase,
8548               TestCase::TearDownTestCase,
8549               test_info->test_meta_factory->CreateTestFactory(*param_it));
8550         }  // for param_it
8551       }  // for gen_it
8552     }  // for test_it
8553   }  // RegisterTests
8554 
8555  private:
8556   // LocalTestInfo structure keeps information about a single test registered
8557   // with TEST_P macro.
8558   struct TestInfo {
8559     TestInfo(const char* a_test_case_base_name,
8560              const char* a_test_base_name,
8561              TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
8562         test_case_base_name(a_test_case_base_name),
8563         test_base_name(a_test_base_name),
8564         test_meta_factory(a_test_meta_factory) {}
8565 
8566     const string test_case_base_name;
8567     const string test_base_name;
8568     const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
8569   };
8570   typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
8571   // Records data received from INSTANTIATE_TEST_CASE_P macros:
8572   //  <Instantiation name, Sequence generator creation function,
8573   //     Name generator function, Source file, Source line>
8574   struct InstantiationInfo {
8575       InstantiationInfo(const std::string &name_in,
8576                         GeneratorCreationFunc* generator_in,
8577                         ParamNameGeneratorFunc* name_func_in,
8578                         const char* file_in,
8579                         int line_in)
8580           : name(name_in),
8581             generator(generator_in),
8582             name_func(name_func_in),
8583             file(file_in),
8584             line(line_in) {}
8585 
8586       std::string name;
8587       GeneratorCreationFunc* generator;
8588       ParamNameGeneratorFunc* name_func;
8589       const char* file;
8590       int line;
8591   };
8592   typedef ::std::vector<InstantiationInfo> InstantiationContainer;
8593 
8594   static bool IsValidParamName(const std::string& name) {
8595     // Check for empty string
8596     if (name.empty())
8597       return false;
8598 
8599     // Check for invalid characters
8600     for (std::string::size_type index = 0; index < name.size(); ++index) {
8601       if (!isalnum(name[index]) && name[index] != '_')
8602         return false;
8603     }
8604 
8605     return true;
8606   }
8607 
8608   const string test_case_name_;
8609   CodeLocation code_location_;
8610   TestInfoContainer tests_;
8611   InstantiationContainer instantiations_;
8612 
8613   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);
8614 };  // class ParameterizedTestCaseInfo
8615 
8616 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
8617 //
8618 // ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase
8619 // classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P
8620 // macros use it to locate their corresponding ParameterizedTestCaseInfo
8621 // descriptors.
8622 class ParameterizedTestCaseRegistry {
8623  public:
8624   ParameterizedTestCaseRegistry() {}
8625   ~ParameterizedTestCaseRegistry() {
8626     for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
8627          it != test_case_infos_.end(); ++it) {
8628       delete *it;
8629     }
8630   }
8631 
8632   // Looks up or creates and returns a structure containing information about
8633   // tests and instantiations of a particular test case.
8634   template <class TestCase>
8635   ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
8636       const char* test_case_name,
8637       CodeLocation code_location) {
8638     ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;
8639     for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
8640          it != test_case_infos_.end(); ++it) {
8641       if ((*it)->GetTestCaseName() == test_case_name) {
8642         if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {
8643           // Complain about incorrect usage of Google Test facilities
8644           // and terminate the program since we cannot guaranty correct
8645           // test case setup and tear-down in this case.
8646           ReportInvalidTestCaseType(test_case_name, code_location);
8647           posix::Abort();
8648         } else {
8649           // At this point we are sure that the object we found is of the same
8650           // type we are looking for, so we downcast it to that type
8651           // without further checks.
8652           typed_test_info = CheckedDowncastToActualType<
8653               ParameterizedTestCaseInfo<TestCase> >(*it);
8654         }
8655         break;
8656       }
8657     }
8658     if (typed_test_info == NULL) {
8659       typed_test_info = new ParameterizedTestCaseInfo<TestCase>(
8660           test_case_name, code_location);
8661       test_case_infos_.push_back(typed_test_info);
8662     }
8663     return typed_test_info;
8664   }
8665   void RegisterTests() {
8666     for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
8667          it != test_case_infos_.end(); ++it) {
8668       (*it)->RegisterTests();
8669     }
8670   }
8671 
8672  private:
8673   typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;
8674 
8675   TestCaseInfoContainer test_case_infos_;
8676 
8677   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);
8678 };
8679 
8680 }  // namespace internal
8681 }  // namespace testing
8682 
8683 #endif  //  GTEST_HAS_PARAM_TEST
8684 
8685 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
8686 // This file was GENERATED by command:
8687 //     pump.py gtest-param-util-generated.h.pump
8688 // DO NOT EDIT BY HAND!!!
8689 
8690 // Copyright 2008 Google Inc.
8691 // All Rights Reserved.
8692 //
8693 // Redistribution and use in source and binary forms, with or without
8694 // modification, are permitted provided that the following conditions are
8695 // met:
8696 //
8697 //     * Redistributions of source code must retain the above copyright
8698 // notice, this list of conditions and the following disclaimer.
8699 //     * Redistributions in binary form must reproduce the above
8700 // copyright notice, this list of conditions and the following disclaimer
8701 // in the documentation and/or other materials provided with the
8702 // distribution.
8703 //     * Neither the name of Google Inc. nor the names of its
8704 // contributors may be used to endorse or promote products derived from
8705 // this software without specific prior written permission.
8706 //
8707 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
8708 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8709 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8710 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8711 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8712 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8713 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
8714 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
8715 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8716 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
8717 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8718 //
8719 // Author: vladl@google.com (Vlad Losev)
8720 
8721 // Type and function utilities for implementing parameterized tests.
8722 // This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
8723 //
8724 // Currently Google Test supports at most 50 arguments in Values,
8725 // and at most 10 arguments in Combine. Please contact
8726 // googletestframework@googlegroups.com if you need more.
8727 // Please note that the number of arguments to Combine is limited
8728 // by the maximum arity of the implementation of tuple which is
8729 // currently set at 10.
8730 
8731 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
8732 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
8733 
8734 // scripts/fuse_gtest.py depends on gtest's own header being #included
8735 // *unconditionally*.  Therefore these #includes cannot be moved
8736 // inside #if GTEST_HAS_PARAM_TEST.
8737 
8738 #if GTEST_HAS_PARAM_TEST
8739 
8740 namespace testing {
8741 
8742 // Forward declarations of ValuesIn(), which is implemented in
8743 // include/gtest/gtest-param-test.h.
8744 template <typename ForwardIterator>
8745 internal::ParamGenerator<
8746   typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
8747 ValuesIn(ForwardIterator begin, ForwardIterator end);
8748 
8749 template <typename T, size_t N>
8750 internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
8751 
8752 template <class Container>
8753 internal::ParamGenerator<typename Container::value_type> ValuesIn(
8754     const Container& container);
8755 
8756 namespace internal {
8757 
8758 // Used in the Values() function to provide polymorphic capabilities.
8759 template <typename T1>
8760 class ValueArray1 {
8761  public:
8762   explicit ValueArray1(T1 v1) : v1_(v1) {}
8763 
8764   template <typename T>
8765   operator ParamGenerator<T>() const {
8766     const T array[] = {static_cast<T>(v1_)};
8767     return ValuesIn(array);
8768   }
8769 
8770  private:
8771   // No implementation - assignment is unsupported.
8772   void operator=(const ValueArray1& other);
8773 
8774   const T1 v1_;
8775 };
8776 
8777 template <typename T1, typename T2>
8778 class ValueArray2 {
8779  public:
8780   ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}
8781 
8782   template <typename T>
8783   operator ParamGenerator<T>() const {
8784     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_)};
8785     return ValuesIn(array);
8786   }
8787 
8788  private:
8789   // No implementation - assignment is unsupported.
8790   void operator=(const ValueArray2& other);
8791 
8792   const T1 v1_;
8793   const T2 v2_;
8794 };
8795 
8796 template <typename T1, typename T2, typename T3>
8797 class ValueArray3 {
8798  public:
8799   ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}
8800 
8801   template <typename T>
8802   operator ParamGenerator<T>() const {
8803     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8804         static_cast<T>(v3_)};
8805     return ValuesIn(array);
8806   }
8807 
8808  private:
8809   // No implementation - assignment is unsupported.
8810   void operator=(const ValueArray3& other);
8811 
8812   const T1 v1_;
8813   const T2 v2_;
8814   const T3 v3_;
8815 };
8816 
8817 template <typename T1, typename T2, typename T3, typename T4>
8818 class ValueArray4 {
8819  public:
8820   ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),
8821       v4_(v4) {}
8822 
8823   template <typename T>
8824   operator ParamGenerator<T>() const {
8825     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8826         static_cast<T>(v3_), static_cast<T>(v4_)};
8827     return ValuesIn(array);
8828   }
8829 
8830  private:
8831   // No implementation - assignment is unsupported.
8832   void operator=(const ValueArray4& other);
8833 
8834   const T1 v1_;
8835   const T2 v2_;
8836   const T3 v3_;
8837   const T4 v4_;
8838 };
8839 
8840 template <typename T1, typename T2, typename T3, typename T4, typename T5>
8841 class ValueArray5 {
8842  public:
8843   ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3),
8844       v4_(v4), v5_(v5) {}
8845 
8846   template <typename T>
8847   operator ParamGenerator<T>() const {
8848     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8849         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_)};
8850     return ValuesIn(array);
8851   }
8852 
8853  private:
8854   // No implementation - assignment is unsupported.
8855   void operator=(const ValueArray5& other);
8856 
8857   const T1 v1_;
8858   const T2 v2_;
8859   const T3 v3_;
8860   const T4 v4_;
8861   const T5 v5_;
8862 };
8863 
8864 template <typename T1, typename T2, typename T3, typename T4, typename T5,
8865     typename T6>
8866 class ValueArray6 {
8867  public:
8868   ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),
8869       v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}
8870 
8871   template <typename T>
8872   operator ParamGenerator<T>() const {
8873     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8874         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
8875         static_cast<T>(v6_)};
8876     return ValuesIn(array);
8877   }
8878 
8879  private:
8880   // No implementation - assignment is unsupported.
8881   void operator=(const ValueArray6& other);
8882 
8883   const T1 v1_;
8884   const T2 v2_;
8885   const T3 v3_;
8886   const T4 v4_;
8887   const T5 v5_;
8888   const T6 v6_;
8889 };
8890 
8891 template <typename T1, typename T2, typename T3, typename T4, typename T5,
8892     typename T6, typename T7>
8893 class ValueArray7 {
8894  public:
8895   ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),
8896       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}
8897 
8898   template <typename T>
8899   operator ParamGenerator<T>() const {
8900     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8901         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
8902         static_cast<T>(v6_), static_cast<T>(v7_)};
8903     return ValuesIn(array);
8904   }
8905 
8906  private:
8907   // No implementation - assignment is unsupported.
8908   void operator=(const ValueArray7& other);
8909 
8910   const T1 v1_;
8911   const T2 v2_;
8912   const T3 v3_;
8913   const T4 v4_;
8914   const T5 v5_;
8915   const T6 v6_;
8916   const T7 v7_;
8917 };
8918 
8919 template <typename T1, typename T2, typename T3, typename T4, typename T5,
8920     typename T6, typename T7, typename T8>
8921 class ValueArray8 {
8922  public:
8923   ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
8924       T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
8925       v8_(v8) {}
8926 
8927   template <typename T>
8928   operator ParamGenerator<T>() const {
8929     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8930         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
8931         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_)};
8932     return ValuesIn(array);
8933   }
8934 
8935  private:
8936   // No implementation - assignment is unsupported.
8937   void operator=(const ValueArray8& other);
8938 
8939   const T1 v1_;
8940   const T2 v2_;
8941   const T3 v3_;
8942   const T4 v4_;
8943   const T5 v5_;
8944   const T6 v6_;
8945   const T7 v7_;
8946   const T8 v8_;
8947 };
8948 
8949 template <typename T1, typename T2, typename T3, typename T4, typename T5,
8950     typename T6, typename T7, typename T8, typename T9>
8951 class ValueArray9 {
8952  public:
8953   ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
8954       T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
8955       v8_(v8), v9_(v9) {}
8956 
8957   template <typename T>
8958   operator ParamGenerator<T>() const {
8959     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8960         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
8961         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
8962         static_cast<T>(v9_)};
8963     return ValuesIn(array);
8964   }
8965 
8966  private:
8967   // No implementation - assignment is unsupported.
8968   void operator=(const ValueArray9& other);
8969 
8970   const T1 v1_;
8971   const T2 v2_;
8972   const T3 v3_;
8973   const T4 v4_;
8974   const T5 v5_;
8975   const T6 v6_;
8976   const T7 v7_;
8977   const T8 v8_;
8978   const T9 v9_;
8979 };
8980 
8981 template <typename T1, typename T2, typename T3, typename T4, typename T5,
8982     typename T6, typename T7, typename T8, typename T9, typename T10>
8983 class ValueArray10 {
8984  public:
8985   ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
8986       T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
8987       v8_(v8), v9_(v9), v10_(v10) {}
8988 
8989   template <typename T>
8990   operator ParamGenerator<T>() const {
8991     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
8992         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
8993         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
8994         static_cast<T>(v9_), static_cast<T>(v10_)};
8995     return ValuesIn(array);
8996   }
8997 
8998  private:
8999   // No implementation - assignment is unsupported.
9000   void operator=(const ValueArray10& other);
9001 
9002   const T1 v1_;
9003   const T2 v2_;
9004   const T3 v3_;
9005   const T4 v4_;
9006   const T5 v5_;
9007   const T6 v6_;
9008   const T7 v7_;
9009   const T8 v8_;
9010   const T9 v9_;
9011   const T10 v10_;
9012 };
9013 
9014 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9015     typename T6, typename T7, typename T8, typename T9, typename T10,
9016     typename T11>
9017 class ValueArray11 {
9018  public:
9019   ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9020       T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
9021       v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}
9022 
9023   template <typename T>
9024   operator ParamGenerator<T>() const {
9025     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9026         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9027         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9028         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_)};
9029     return ValuesIn(array);
9030   }
9031 
9032  private:
9033   // No implementation - assignment is unsupported.
9034   void operator=(const ValueArray11& other);
9035 
9036   const T1 v1_;
9037   const T2 v2_;
9038   const T3 v3_;
9039   const T4 v4_;
9040   const T5 v5_;
9041   const T6 v6_;
9042   const T7 v7_;
9043   const T8 v8_;
9044   const T9 v9_;
9045   const T10 v10_;
9046   const T11 v11_;
9047 };
9048 
9049 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9050     typename T6, typename T7, typename T8, typename T9, typename T10,
9051     typename T11, typename T12>
9052 class ValueArray12 {
9053  public:
9054   ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9055       T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
9056       v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {}
9057 
9058   template <typename T>
9059   operator ParamGenerator<T>() const {
9060     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9061         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9062         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9063         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9064         static_cast<T>(v12_)};
9065     return ValuesIn(array);
9066   }
9067 
9068  private:
9069   // No implementation - assignment is unsupported.
9070   void operator=(const ValueArray12& other);
9071 
9072   const T1 v1_;
9073   const T2 v2_;
9074   const T3 v3_;
9075   const T4 v4_;
9076   const T5 v5_;
9077   const T6 v6_;
9078   const T7 v7_;
9079   const T8 v8_;
9080   const T9 v9_;
9081   const T10 v10_;
9082   const T11 v11_;
9083   const T12 v12_;
9084 };
9085 
9086 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9087     typename T6, typename T7, typename T8, typename T9, typename T10,
9088     typename T11, typename T12, typename T13>
9089 class ValueArray13 {
9090  public:
9091   ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9092       T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
9093       v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
9094       v12_(v12), v13_(v13) {}
9095 
9096   template <typename T>
9097   operator ParamGenerator<T>() const {
9098     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9099         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9100         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9101         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9102         static_cast<T>(v12_), static_cast<T>(v13_)};
9103     return ValuesIn(array);
9104   }
9105 
9106  private:
9107   // No implementation - assignment is unsupported.
9108   void operator=(const ValueArray13& other);
9109 
9110   const T1 v1_;
9111   const T2 v2_;
9112   const T3 v3_;
9113   const T4 v4_;
9114   const T5 v5_;
9115   const T6 v6_;
9116   const T7 v7_;
9117   const T8 v8_;
9118   const T9 v9_;
9119   const T10 v10_;
9120   const T11 v11_;
9121   const T12 v12_;
9122   const T13 v13_;
9123 };
9124 
9125 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9126     typename T6, typename T7, typename T8, typename T9, typename T10,
9127     typename T11, typename T12, typename T13, typename T14>
9128 class ValueArray14 {
9129  public:
9130   ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9131       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3),
9132       v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
9133       v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}
9134 
9135   template <typename T>
9136   operator ParamGenerator<T>() const {
9137     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9138         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9139         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9140         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9141         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_)};
9142     return ValuesIn(array);
9143   }
9144 
9145  private:
9146   // No implementation - assignment is unsupported.
9147   void operator=(const ValueArray14& other);
9148 
9149   const T1 v1_;
9150   const T2 v2_;
9151   const T3 v3_;
9152   const T4 v4_;
9153   const T5 v5_;
9154   const T6 v6_;
9155   const T7 v7_;
9156   const T8 v8_;
9157   const T9 v9_;
9158   const T10 v10_;
9159   const T11 v11_;
9160   const T12 v12_;
9161   const T13 v13_;
9162   const T14 v14_;
9163 };
9164 
9165 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9166     typename T6, typename T7, typename T8, typename T9, typename T10,
9167     typename T11, typename T12, typename T13, typename T14, typename T15>
9168 class ValueArray15 {
9169  public:
9170   ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9171       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2),
9172       v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
9173       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}
9174 
9175   template <typename T>
9176   operator ParamGenerator<T>() const {
9177     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9178         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9179         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9180         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9181         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9182         static_cast<T>(v15_)};
9183     return ValuesIn(array);
9184   }
9185 
9186  private:
9187   // No implementation - assignment is unsupported.
9188   void operator=(const ValueArray15& other);
9189 
9190   const T1 v1_;
9191   const T2 v2_;
9192   const T3 v3_;
9193   const T4 v4_;
9194   const T5 v5_;
9195   const T6 v6_;
9196   const T7 v7_;
9197   const T8 v8_;
9198   const T9 v9_;
9199   const T10 v10_;
9200   const T11 v11_;
9201   const T12 v12_;
9202   const T13 v13_;
9203   const T14 v14_;
9204   const T15 v15_;
9205 };
9206 
9207 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9208     typename T6, typename T7, typename T8, typename T9, typename T10,
9209     typename T11, typename T12, typename T13, typename T14, typename T15,
9210     typename T16>
9211 class ValueArray16 {
9212  public:
9213   ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9214       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1),
9215       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
9216       v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
9217       v16_(v16) {}
9218 
9219   template <typename T>
9220   operator ParamGenerator<T>() const {
9221     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9222         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9223         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9224         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9225         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9226         static_cast<T>(v15_), static_cast<T>(v16_)};
9227     return ValuesIn(array);
9228   }
9229 
9230  private:
9231   // No implementation - assignment is unsupported.
9232   void operator=(const ValueArray16& other);
9233 
9234   const T1 v1_;
9235   const T2 v2_;
9236   const T3 v3_;
9237   const T4 v4_;
9238   const T5 v5_;
9239   const T6 v6_;
9240   const T7 v7_;
9241   const T8 v8_;
9242   const T9 v9_;
9243   const T10 v10_;
9244   const T11 v11_;
9245   const T12 v12_;
9246   const T13 v13_;
9247   const T14 v14_;
9248   const T15 v15_;
9249   const T16 v16_;
9250 };
9251 
9252 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9253     typename T6, typename T7, typename T8, typename T9, typename T10,
9254     typename T11, typename T12, typename T13, typename T14, typename T15,
9255     typename T16, typename T17>
9256 class ValueArray17 {
9257  public:
9258   ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9259       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
9260       T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
9261       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
9262       v15_(v15), v16_(v16), v17_(v17) {}
9263 
9264   template <typename T>
9265   operator ParamGenerator<T>() const {
9266     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9267         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9268         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9269         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9270         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9271         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_)};
9272     return ValuesIn(array);
9273   }
9274 
9275  private:
9276   // No implementation - assignment is unsupported.
9277   void operator=(const ValueArray17& other);
9278 
9279   const T1 v1_;
9280   const T2 v2_;
9281   const T3 v3_;
9282   const T4 v4_;
9283   const T5 v5_;
9284   const T6 v6_;
9285   const T7 v7_;
9286   const T8 v8_;
9287   const T9 v9_;
9288   const T10 v10_;
9289   const T11 v11_;
9290   const T12 v12_;
9291   const T13 v13_;
9292   const T14 v14_;
9293   const T15 v15_;
9294   const T16 v16_;
9295   const T17 v17_;
9296 };
9297 
9298 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9299     typename T6, typename T7, typename T8, typename T9, typename T10,
9300     typename T11, typename T12, typename T13, typename T14, typename T15,
9301     typename T16, typename T17, typename T18>
9302 class ValueArray18 {
9303  public:
9304   ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9305       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9306       T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
9307       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
9308       v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}
9309 
9310   template <typename T>
9311   operator ParamGenerator<T>() const {
9312     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9313         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9314         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9315         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9316         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9317         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9318         static_cast<T>(v18_)};
9319     return ValuesIn(array);
9320   }
9321 
9322  private:
9323   // No implementation - assignment is unsupported.
9324   void operator=(const ValueArray18& other);
9325 
9326   const T1 v1_;
9327   const T2 v2_;
9328   const T3 v3_;
9329   const T4 v4_;
9330   const T5 v5_;
9331   const T6 v6_;
9332   const T7 v7_;
9333   const T8 v8_;
9334   const T9 v9_;
9335   const T10 v10_;
9336   const T11 v11_;
9337   const T12 v12_;
9338   const T13 v13_;
9339   const T14 v14_;
9340   const T15 v15_;
9341   const T16 v16_;
9342   const T17 v17_;
9343   const T18 v18_;
9344 };
9345 
9346 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9347     typename T6, typename T7, typename T8, typename T9, typename T10,
9348     typename T11, typename T12, typename T13, typename T14, typename T15,
9349     typename T16, typename T17, typename T18, typename T19>
9350 class ValueArray19 {
9351  public:
9352   ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9353       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9354       T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
9355       v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
9356       v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}
9357 
9358   template <typename T>
9359   operator ParamGenerator<T>() const {
9360     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9361         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9362         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9363         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9364         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9365         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9366         static_cast<T>(v18_), static_cast<T>(v19_)};
9367     return ValuesIn(array);
9368   }
9369 
9370  private:
9371   // No implementation - assignment is unsupported.
9372   void operator=(const ValueArray19& other);
9373 
9374   const T1 v1_;
9375   const T2 v2_;
9376   const T3 v3_;
9377   const T4 v4_;
9378   const T5 v5_;
9379   const T6 v6_;
9380   const T7 v7_;
9381   const T8 v8_;
9382   const T9 v9_;
9383   const T10 v10_;
9384   const T11 v11_;
9385   const T12 v12_;
9386   const T13 v13_;
9387   const T14 v14_;
9388   const T15 v15_;
9389   const T16 v16_;
9390   const T17 v17_;
9391   const T18 v18_;
9392   const T19 v19_;
9393 };
9394 
9395 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9396     typename T6, typename T7, typename T8, typename T9, typename T10,
9397     typename T11, typename T12, typename T13, typename T14, typename T15,
9398     typename T16, typename T17, typename T18, typename T19, typename T20>
9399 class ValueArray20 {
9400  public:
9401   ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9402       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9403       T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
9404       v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
9405       v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
9406       v19_(v19), v20_(v20) {}
9407 
9408   template <typename T>
9409   operator ParamGenerator<T>() const {
9410     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9411         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9412         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9413         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9414         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9415         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9416         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_)};
9417     return ValuesIn(array);
9418   }
9419 
9420  private:
9421   // No implementation - assignment is unsupported.
9422   void operator=(const ValueArray20& other);
9423 
9424   const T1 v1_;
9425   const T2 v2_;
9426   const T3 v3_;
9427   const T4 v4_;
9428   const T5 v5_;
9429   const T6 v6_;
9430   const T7 v7_;
9431   const T8 v8_;
9432   const T9 v9_;
9433   const T10 v10_;
9434   const T11 v11_;
9435   const T12 v12_;
9436   const T13 v13_;
9437   const T14 v14_;
9438   const T15 v15_;
9439   const T16 v16_;
9440   const T17 v17_;
9441   const T18 v18_;
9442   const T19 v19_;
9443   const T20 v20_;
9444 };
9445 
9446 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9447     typename T6, typename T7, typename T8, typename T9, typename T10,
9448     typename T11, typename T12, typename T13, typename T14, typename T15,
9449     typename T16, typename T17, typename T18, typename T19, typename T20,
9450     typename T21>
9451 class ValueArray21 {
9452  public:
9453   ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9454       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9455       T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
9456       v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
9457       v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
9458       v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}
9459 
9460   template <typename T>
9461   operator ParamGenerator<T>() const {
9462     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9463         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9464         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9465         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9466         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9467         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9468         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9469         static_cast<T>(v21_)};
9470     return ValuesIn(array);
9471   }
9472 
9473  private:
9474   // No implementation - assignment is unsupported.
9475   void operator=(const ValueArray21& other);
9476 
9477   const T1 v1_;
9478   const T2 v2_;
9479   const T3 v3_;
9480   const T4 v4_;
9481   const T5 v5_;
9482   const T6 v6_;
9483   const T7 v7_;
9484   const T8 v8_;
9485   const T9 v9_;
9486   const T10 v10_;
9487   const T11 v11_;
9488   const T12 v12_;
9489   const T13 v13_;
9490   const T14 v14_;
9491   const T15 v15_;
9492   const T16 v16_;
9493   const T17 v17_;
9494   const T18 v18_;
9495   const T19 v19_;
9496   const T20 v20_;
9497   const T21 v21_;
9498 };
9499 
9500 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9501     typename T6, typename T7, typename T8, typename T9, typename T10,
9502     typename T11, typename T12, typename T13, typename T14, typename T15,
9503     typename T16, typename T17, typename T18, typename T19, typename T20,
9504     typename T21, typename T22>
9505 class ValueArray22 {
9506  public:
9507   ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9508       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9509       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3),
9510       v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
9511       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
9512       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}
9513 
9514   template <typename T>
9515   operator ParamGenerator<T>() const {
9516     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9517         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9518         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9519         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9520         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9521         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9522         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9523         static_cast<T>(v21_), static_cast<T>(v22_)};
9524     return ValuesIn(array);
9525   }
9526 
9527  private:
9528   // No implementation - assignment is unsupported.
9529   void operator=(const ValueArray22& other);
9530 
9531   const T1 v1_;
9532   const T2 v2_;
9533   const T3 v3_;
9534   const T4 v4_;
9535   const T5 v5_;
9536   const T6 v6_;
9537   const T7 v7_;
9538   const T8 v8_;
9539   const T9 v9_;
9540   const T10 v10_;
9541   const T11 v11_;
9542   const T12 v12_;
9543   const T13 v13_;
9544   const T14 v14_;
9545   const T15 v15_;
9546   const T16 v16_;
9547   const T17 v17_;
9548   const T18 v18_;
9549   const T19 v19_;
9550   const T20 v20_;
9551   const T21 v21_;
9552   const T22 v22_;
9553 };
9554 
9555 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9556     typename T6, typename T7, typename T8, typename T9, typename T10,
9557     typename T11, typename T12, typename T13, typename T14, typename T15,
9558     typename T16, typename T17, typename T18, typename T19, typename T20,
9559     typename T21, typename T22, typename T23>
9560 class ValueArray23 {
9561  public:
9562   ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9563       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9564       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2),
9565       v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
9566       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
9567       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
9568       v23_(v23) {}
9569 
9570   template <typename T>
9571   operator ParamGenerator<T>() const {
9572     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9573         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9574         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9575         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9576         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9577         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9578         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9579         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_)};
9580     return ValuesIn(array);
9581   }
9582 
9583  private:
9584   // No implementation - assignment is unsupported.
9585   void operator=(const ValueArray23& other);
9586 
9587   const T1 v1_;
9588   const T2 v2_;
9589   const T3 v3_;
9590   const T4 v4_;
9591   const T5 v5_;
9592   const T6 v6_;
9593   const T7 v7_;
9594   const T8 v8_;
9595   const T9 v9_;
9596   const T10 v10_;
9597   const T11 v11_;
9598   const T12 v12_;
9599   const T13 v13_;
9600   const T14 v14_;
9601   const T15 v15_;
9602   const T16 v16_;
9603   const T17 v17_;
9604   const T18 v18_;
9605   const T19 v19_;
9606   const T20 v20_;
9607   const T21 v21_;
9608   const T22 v22_;
9609   const T23 v23_;
9610 };
9611 
9612 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9613     typename T6, typename T7, typename T8, typename T9, typename T10,
9614     typename T11, typename T12, typename T13, typename T14, typename T15,
9615     typename T16, typename T17, typename T18, typename T19, typename T20,
9616     typename T21, typename T22, typename T23, typename T24>
9617 class ValueArray24 {
9618  public:
9619   ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9620       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9621       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1),
9622       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
9623       v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
9624       v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
9625       v22_(v22), v23_(v23), v24_(v24) {}
9626 
9627   template <typename T>
9628   operator ParamGenerator<T>() const {
9629     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9630         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9631         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9632         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9633         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9634         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9635         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9636         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9637         static_cast<T>(v24_)};
9638     return ValuesIn(array);
9639   }
9640 
9641  private:
9642   // No implementation - assignment is unsupported.
9643   void operator=(const ValueArray24& other);
9644 
9645   const T1 v1_;
9646   const T2 v2_;
9647   const T3 v3_;
9648   const T4 v4_;
9649   const T5 v5_;
9650   const T6 v6_;
9651   const T7 v7_;
9652   const T8 v8_;
9653   const T9 v9_;
9654   const T10 v10_;
9655   const T11 v11_;
9656   const T12 v12_;
9657   const T13 v13_;
9658   const T14 v14_;
9659   const T15 v15_;
9660   const T16 v16_;
9661   const T17 v17_;
9662   const T18 v18_;
9663   const T19 v19_;
9664   const T20 v20_;
9665   const T21 v21_;
9666   const T22 v22_;
9667   const T23 v23_;
9668   const T24 v24_;
9669 };
9670 
9671 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9672     typename T6, typename T7, typename T8, typename T9, typename T10,
9673     typename T11, typename T12, typename T13, typename T14, typename T15,
9674     typename T16, typename T17, typename T18, typename T19, typename T20,
9675     typename T21, typename T22, typename T23, typename T24, typename T25>
9676 class ValueArray25 {
9677  public:
9678   ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9679       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9680       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
9681       T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
9682       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
9683       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
9684       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {}
9685 
9686   template <typename T>
9687   operator ParamGenerator<T>() const {
9688     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9689         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9690         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9691         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9692         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9693         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9694         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9695         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9696         static_cast<T>(v24_), static_cast<T>(v25_)};
9697     return ValuesIn(array);
9698   }
9699 
9700  private:
9701   // No implementation - assignment is unsupported.
9702   void operator=(const ValueArray25& other);
9703 
9704   const T1 v1_;
9705   const T2 v2_;
9706   const T3 v3_;
9707   const T4 v4_;
9708   const T5 v5_;
9709   const T6 v6_;
9710   const T7 v7_;
9711   const T8 v8_;
9712   const T9 v9_;
9713   const T10 v10_;
9714   const T11 v11_;
9715   const T12 v12_;
9716   const T13 v13_;
9717   const T14 v14_;
9718   const T15 v15_;
9719   const T16 v16_;
9720   const T17 v17_;
9721   const T18 v18_;
9722   const T19 v19_;
9723   const T20 v20_;
9724   const T21 v21_;
9725   const T22 v22_;
9726   const T23 v23_;
9727   const T24 v24_;
9728   const T25 v25_;
9729 };
9730 
9731 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9732     typename T6, typename T7, typename T8, typename T9, typename T10,
9733     typename T11, typename T12, typename T13, typename T14, typename T15,
9734     typename T16, typename T17, typename T18, typename T19, typename T20,
9735     typename T21, typename T22, typename T23, typename T24, typename T25,
9736     typename T26>
9737 class ValueArray26 {
9738  public:
9739   ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9740       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9741       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
9742       T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
9743       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
9744       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
9745       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {}
9746 
9747   template <typename T>
9748   operator ParamGenerator<T>() const {
9749     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9750         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9751         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9752         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9753         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9754         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9755         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9756         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9757         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_)};
9758     return ValuesIn(array);
9759   }
9760 
9761  private:
9762   // No implementation - assignment is unsupported.
9763   void operator=(const ValueArray26& other);
9764 
9765   const T1 v1_;
9766   const T2 v2_;
9767   const T3 v3_;
9768   const T4 v4_;
9769   const T5 v5_;
9770   const T6 v6_;
9771   const T7 v7_;
9772   const T8 v8_;
9773   const T9 v9_;
9774   const T10 v10_;
9775   const T11 v11_;
9776   const T12 v12_;
9777   const T13 v13_;
9778   const T14 v14_;
9779   const T15 v15_;
9780   const T16 v16_;
9781   const T17 v17_;
9782   const T18 v18_;
9783   const T19 v19_;
9784   const T20 v20_;
9785   const T21 v21_;
9786   const T22 v22_;
9787   const T23 v23_;
9788   const T24 v24_;
9789   const T25 v25_;
9790   const T26 v26_;
9791 };
9792 
9793 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9794     typename T6, typename T7, typename T8, typename T9, typename T10,
9795     typename T11, typename T12, typename T13, typename T14, typename T15,
9796     typename T16, typename T17, typename T18, typename T19, typename T20,
9797     typename T21, typename T22, typename T23, typename T24, typename T25,
9798     typename T26, typename T27>
9799 class ValueArray27 {
9800  public:
9801   ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9802       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9803       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
9804       T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
9805       v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
9806       v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
9807       v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
9808       v26_(v26), v27_(v27) {}
9809 
9810   template <typename T>
9811   operator ParamGenerator<T>() const {
9812     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9813         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9814         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9815         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9816         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9817         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9818         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9819         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9820         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
9821         static_cast<T>(v27_)};
9822     return ValuesIn(array);
9823   }
9824 
9825  private:
9826   // No implementation - assignment is unsupported.
9827   void operator=(const ValueArray27& other);
9828 
9829   const T1 v1_;
9830   const T2 v2_;
9831   const T3 v3_;
9832   const T4 v4_;
9833   const T5 v5_;
9834   const T6 v6_;
9835   const T7 v7_;
9836   const T8 v8_;
9837   const T9 v9_;
9838   const T10 v10_;
9839   const T11 v11_;
9840   const T12 v12_;
9841   const T13 v13_;
9842   const T14 v14_;
9843   const T15 v15_;
9844   const T16 v16_;
9845   const T17 v17_;
9846   const T18 v18_;
9847   const T19 v19_;
9848   const T20 v20_;
9849   const T21 v21_;
9850   const T22 v22_;
9851   const T23 v23_;
9852   const T24 v24_;
9853   const T25 v25_;
9854   const T26 v26_;
9855   const T27 v27_;
9856 };
9857 
9858 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9859     typename T6, typename T7, typename T8, typename T9, typename T10,
9860     typename T11, typename T12, typename T13, typename T14, typename T15,
9861     typename T16, typename T17, typename T18, typename T19, typename T20,
9862     typename T21, typename T22, typename T23, typename T24, typename T25,
9863     typename T26, typename T27, typename T28>
9864 class ValueArray28 {
9865  public:
9866   ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9867       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9868       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
9869       T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
9870       v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
9871       v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
9872       v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
9873       v25_(v25), v26_(v26), v27_(v27), v28_(v28) {}
9874 
9875   template <typename T>
9876   operator ParamGenerator<T>() const {
9877     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9878         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9879         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9880         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9881         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9882         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9883         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9884         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9885         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
9886         static_cast<T>(v27_), static_cast<T>(v28_)};
9887     return ValuesIn(array);
9888   }
9889 
9890  private:
9891   // No implementation - assignment is unsupported.
9892   void operator=(const ValueArray28& other);
9893 
9894   const T1 v1_;
9895   const T2 v2_;
9896   const T3 v3_;
9897   const T4 v4_;
9898   const T5 v5_;
9899   const T6 v6_;
9900   const T7 v7_;
9901   const T8 v8_;
9902   const T9 v9_;
9903   const T10 v10_;
9904   const T11 v11_;
9905   const T12 v12_;
9906   const T13 v13_;
9907   const T14 v14_;
9908   const T15 v15_;
9909   const T16 v16_;
9910   const T17 v17_;
9911   const T18 v18_;
9912   const T19 v19_;
9913   const T20 v20_;
9914   const T21 v21_;
9915   const T22 v22_;
9916   const T23 v23_;
9917   const T24 v24_;
9918   const T25 v25_;
9919   const T26 v26_;
9920   const T27 v27_;
9921   const T28 v28_;
9922 };
9923 
9924 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9925     typename T6, typename T7, typename T8, typename T9, typename T10,
9926     typename T11, typename T12, typename T13, typename T14, typename T15,
9927     typename T16, typename T17, typename T18, typename T19, typename T20,
9928     typename T21, typename T22, typename T23, typename T24, typename T25,
9929     typename T26, typename T27, typename T28, typename T29>
9930 class ValueArray29 {
9931  public:
9932   ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
9933       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
9934       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
9935       T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
9936       v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
9937       v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
9938       v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
9939       v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {}
9940 
9941   template <typename T>
9942   operator ParamGenerator<T>() const {
9943     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
9944         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
9945         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
9946         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
9947         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
9948         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
9949         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
9950         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
9951         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
9952         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_)};
9953     return ValuesIn(array);
9954   }
9955 
9956  private:
9957   // No implementation - assignment is unsupported.
9958   void operator=(const ValueArray29& other);
9959 
9960   const T1 v1_;
9961   const T2 v2_;
9962   const T3 v3_;
9963   const T4 v4_;
9964   const T5 v5_;
9965   const T6 v6_;
9966   const T7 v7_;
9967   const T8 v8_;
9968   const T9 v9_;
9969   const T10 v10_;
9970   const T11 v11_;
9971   const T12 v12_;
9972   const T13 v13_;
9973   const T14 v14_;
9974   const T15 v15_;
9975   const T16 v16_;
9976   const T17 v17_;
9977   const T18 v18_;
9978   const T19 v19_;
9979   const T20 v20_;
9980   const T21 v21_;
9981   const T22 v22_;
9982   const T23 v23_;
9983   const T24 v24_;
9984   const T25 v25_;
9985   const T26 v26_;
9986   const T27 v27_;
9987   const T28 v28_;
9988   const T29 v29_;
9989 };
9990 
9991 template <typename T1, typename T2, typename T3, typename T4, typename T5,
9992     typename T6, typename T7, typename T8, typename T9, typename T10,
9993     typename T11, typename T12, typename T13, typename T14, typename T15,
9994     typename T16, typename T17, typename T18, typename T19, typename T20,
9995     typename T21, typename T22, typename T23, typename T24, typename T25,
9996     typename T26, typename T27, typename T28, typename T29, typename T30>
9997 class ValueArray30 {
9998  public:
9999   ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10000       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10001       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10002       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3),
10003       v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
10004       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
10005       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
10006       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
10007       v29_(v29), v30_(v30) {}
10008 
10009   template <typename T>
10010   operator ParamGenerator<T>() const {
10011     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10012         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10013         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10014         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10015         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10016         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10017         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10018         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10019         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10020         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10021         static_cast<T>(v30_)};
10022     return ValuesIn(array);
10023   }
10024 
10025  private:
10026   // No implementation - assignment is unsupported.
10027   void operator=(const ValueArray30& other);
10028 
10029   const T1 v1_;
10030   const T2 v2_;
10031   const T3 v3_;
10032   const T4 v4_;
10033   const T5 v5_;
10034   const T6 v6_;
10035   const T7 v7_;
10036   const T8 v8_;
10037   const T9 v9_;
10038   const T10 v10_;
10039   const T11 v11_;
10040   const T12 v12_;
10041   const T13 v13_;
10042   const T14 v14_;
10043   const T15 v15_;
10044   const T16 v16_;
10045   const T17 v17_;
10046   const T18 v18_;
10047   const T19 v19_;
10048   const T20 v20_;
10049   const T21 v21_;
10050   const T22 v22_;
10051   const T23 v23_;
10052   const T24 v24_;
10053   const T25 v25_;
10054   const T26 v26_;
10055   const T27 v27_;
10056   const T28 v28_;
10057   const T29 v29_;
10058   const T30 v30_;
10059 };
10060 
10061 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10062     typename T6, typename T7, typename T8, typename T9, typename T10,
10063     typename T11, typename T12, typename T13, typename T14, typename T15,
10064     typename T16, typename T17, typename T18, typename T19, typename T20,
10065     typename T21, typename T22, typename T23, typename T24, typename T25,
10066     typename T26, typename T27, typename T28, typename T29, typename T30,
10067     typename T31>
10068 class ValueArray31 {
10069  public:
10070   ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10071       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10072       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10073       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2),
10074       v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
10075       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
10076       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
10077       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
10078       v29_(v29), v30_(v30), v31_(v31) {}
10079 
10080   template <typename T>
10081   operator ParamGenerator<T>() const {
10082     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10083         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10084         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10085         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10086         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10087         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10088         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10089         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10090         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10091         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10092         static_cast<T>(v30_), static_cast<T>(v31_)};
10093     return ValuesIn(array);
10094   }
10095 
10096  private:
10097   // No implementation - assignment is unsupported.
10098   void operator=(const ValueArray31& other);
10099 
10100   const T1 v1_;
10101   const T2 v2_;
10102   const T3 v3_;
10103   const T4 v4_;
10104   const T5 v5_;
10105   const T6 v6_;
10106   const T7 v7_;
10107   const T8 v8_;
10108   const T9 v9_;
10109   const T10 v10_;
10110   const T11 v11_;
10111   const T12 v12_;
10112   const T13 v13_;
10113   const T14 v14_;
10114   const T15 v15_;
10115   const T16 v16_;
10116   const T17 v17_;
10117   const T18 v18_;
10118   const T19 v19_;
10119   const T20 v20_;
10120   const T21 v21_;
10121   const T22 v22_;
10122   const T23 v23_;
10123   const T24 v24_;
10124   const T25 v25_;
10125   const T26 v26_;
10126   const T27 v27_;
10127   const T28 v28_;
10128   const T29 v29_;
10129   const T30 v30_;
10130   const T31 v31_;
10131 };
10132 
10133 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10134     typename T6, typename T7, typename T8, typename T9, typename T10,
10135     typename T11, typename T12, typename T13, typename T14, typename T15,
10136     typename T16, typename T17, typename T18, typename T19, typename T20,
10137     typename T21, typename T22, typename T23, typename T24, typename T25,
10138     typename T26, typename T27, typename T28, typename T29, typename T30,
10139     typename T31, typename T32>
10140 class ValueArray32 {
10141  public:
10142   ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10143       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10144       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10145       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1),
10146       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
10147       v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
10148       v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
10149       v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
10150       v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {}
10151 
10152   template <typename T>
10153   operator ParamGenerator<T>() const {
10154     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10155         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10156         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10157         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10158         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10159         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10160         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10161         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10162         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10163         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10164         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_)};
10165     return ValuesIn(array);
10166   }
10167 
10168  private:
10169   // No implementation - assignment is unsupported.
10170   void operator=(const ValueArray32& other);
10171 
10172   const T1 v1_;
10173   const T2 v2_;
10174   const T3 v3_;
10175   const T4 v4_;
10176   const T5 v5_;
10177   const T6 v6_;
10178   const T7 v7_;
10179   const T8 v8_;
10180   const T9 v9_;
10181   const T10 v10_;
10182   const T11 v11_;
10183   const T12 v12_;
10184   const T13 v13_;
10185   const T14 v14_;
10186   const T15 v15_;
10187   const T16 v16_;
10188   const T17 v17_;
10189   const T18 v18_;
10190   const T19 v19_;
10191   const T20 v20_;
10192   const T21 v21_;
10193   const T22 v22_;
10194   const T23 v23_;
10195   const T24 v24_;
10196   const T25 v25_;
10197   const T26 v26_;
10198   const T27 v27_;
10199   const T28 v28_;
10200   const T29 v29_;
10201   const T30 v30_;
10202   const T31 v31_;
10203   const T32 v32_;
10204 };
10205 
10206 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10207     typename T6, typename T7, typename T8, typename T9, typename T10,
10208     typename T11, typename T12, typename T13, typename T14, typename T15,
10209     typename T16, typename T17, typename T18, typename T19, typename T20,
10210     typename T21, typename T22, typename T23, typename T24, typename T25,
10211     typename T26, typename T27, typename T28, typename T29, typename T30,
10212     typename T31, typename T32, typename T33>
10213 class ValueArray33 {
10214  public:
10215   ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10216       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10217       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10218       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
10219       T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
10220       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
10221       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
10222       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
10223       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
10224       v33_(v33) {}
10225 
10226   template <typename T>
10227   operator ParamGenerator<T>() const {
10228     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10229         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10230         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10231         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10232         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10233         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10234         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10235         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10236         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10237         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10238         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10239         static_cast<T>(v33_)};
10240     return ValuesIn(array);
10241   }
10242 
10243  private:
10244   // No implementation - assignment is unsupported.
10245   void operator=(const ValueArray33& other);
10246 
10247   const T1 v1_;
10248   const T2 v2_;
10249   const T3 v3_;
10250   const T4 v4_;
10251   const T5 v5_;
10252   const T6 v6_;
10253   const T7 v7_;
10254   const T8 v8_;
10255   const T9 v9_;
10256   const T10 v10_;
10257   const T11 v11_;
10258   const T12 v12_;
10259   const T13 v13_;
10260   const T14 v14_;
10261   const T15 v15_;
10262   const T16 v16_;
10263   const T17 v17_;
10264   const T18 v18_;
10265   const T19 v19_;
10266   const T20 v20_;
10267   const T21 v21_;
10268   const T22 v22_;
10269   const T23 v23_;
10270   const T24 v24_;
10271   const T25 v25_;
10272   const T26 v26_;
10273   const T27 v27_;
10274   const T28 v28_;
10275   const T29 v29_;
10276   const T30 v30_;
10277   const T31 v31_;
10278   const T32 v32_;
10279   const T33 v33_;
10280 };
10281 
10282 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10283     typename T6, typename T7, typename T8, typename T9, typename T10,
10284     typename T11, typename T12, typename T13, typename T14, typename T15,
10285     typename T16, typename T17, typename T18, typename T19, typename T20,
10286     typename T21, typename T22, typename T23, typename T24, typename T25,
10287     typename T26, typename T27, typename T28, typename T29, typename T30,
10288     typename T31, typename T32, typename T33, typename T34>
10289 class ValueArray34 {
10290  public:
10291   ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10292       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10293       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10294       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10295       T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
10296       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
10297       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
10298       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
10299       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
10300       v33_(v33), v34_(v34) {}
10301 
10302   template <typename T>
10303   operator ParamGenerator<T>() const {
10304     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10305         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10306         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10307         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10308         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10309         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10310         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10311         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10312         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10313         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10314         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10315         static_cast<T>(v33_), static_cast<T>(v34_)};
10316     return ValuesIn(array);
10317   }
10318 
10319  private:
10320   // No implementation - assignment is unsupported.
10321   void operator=(const ValueArray34& other);
10322 
10323   const T1 v1_;
10324   const T2 v2_;
10325   const T3 v3_;
10326   const T4 v4_;
10327   const T5 v5_;
10328   const T6 v6_;
10329   const T7 v7_;
10330   const T8 v8_;
10331   const T9 v9_;
10332   const T10 v10_;
10333   const T11 v11_;
10334   const T12 v12_;
10335   const T13 v13_;
10336   const T14 v14_;
10337   const T15 v15_;
10338   const T16 v16_;
10339   const T17 v17_;
10340   const T18 v18_;
10341   const T19 v19_;
10342   const T20 v20_;
10343   const T21 v21_;
10344   const T22 v22_;
10345   const T23 v23_;
10346   const T24 v24_;
10347   const T25 v25_;
10348   const T26 v26_;
10349   const T27 v27_;
10350   const T28 v28_;
10351   const T29 v29_;
10352   const T30 v30_;
10353   const T31 v31_;
10354   const T32 v32_;
10355   const T33 v33_;
10356   const T34 v34_;
10357 };
10358 
10359 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10360     typename T6, typename T7, typename T8, typename T9, typename T10,
10361     typename T11, typename T12, typename T13, typename T14, typename T15,
10362     typename T16, typename T17, typename T18, typename T19, typename T20,
10363     typename T21, typename T22, typename T23, typename T24, typename T25,
10364     typename T26, typename T27, typename T28, typename T29, typename T30,
10365     typename T31, typename T32, typename T33, typename T34, typename T35>
10366 class ValueArray35 {
10367  public:
10368   ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10369       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10370       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10371       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10372       T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
10373       v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
10374       v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
10375       v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
10376       v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
10377       v32_(v32), v33_(v33), v34_(v34), v35_(v35) {}
10378 
10379   template <typename T>
10380   operator ParamGenerator<T>() const {
10381     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10382         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10383         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10384         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10385         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10386         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10387         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10388         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10389         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10390         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10391         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10392         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_)};
10393     return ValuesIn(array);
10394   }
10395 
10396  private:
10397   // No implementation - assignment is unsupported.
10398   void operator=(const ValueArray35& other);
10399 
10400   const T1 v1_;
10401   const T2 v2_;
10402   const T3 v3_;
10403   const T4 v4_;
10404   const T5 v5_;
10405   const T6 v6_;
10406   const T7 v7_;
10407   const T8 v8_;
10408   const T9 v9_;
10409   const T10 v10_;
10410   const T11 v11_;
10411   const T12 v12_;
10412   const T13 v13_;
10413   const T14 v14_;
10414   const T15 v15_;
10415   const T16 v16_;
10416   const T17 v17_;
10417   const T18 v18_;
10418   const T19 v19_;
10419   const T20 v20_;
10420   const T21 v21_;
10421   const T22 v22_;
10422   const T23 v23_;
10423   const T24 v24_;
10424   const T25 v25_;
10425   const T26 v26_;
10426   const T27 v27_;
10427   const T28 v28_;
10428   const T29 v29_;
10429   const T30 v30_;
10430   const T31 v31_;
10431   const T32 v32_;
10432   const T33 v33_;
10433   const T34 v34_;
10434   const T35 v35_;
10435 };
10436 
10437 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10438     typename T6, typename T7, typename T8, typename T9, typename T10,
10439     typename T11, typename T12, typename T13, typename T14, typename T15,
10440     typename T16, typename T17, typename T18, typename T19, typename T20,
10441     typename T21, typename T22, typename T23, typename T24, typename T25,
10442     typename T26, typename T27, typename T28, typename T29, typename T30,
10443     typename T31, typename T32, typename T33, typename T34, typename T35,
10444     typename T36>
10445 class ValueArray36 {
10446  public:
10447   ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10448       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10449       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10450       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10451       T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
10452       v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
10453       v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
10454       v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
10455       v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
10456       v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {}
10457 
10458   template <typename T>
10459   operator ParamGenerator<T>() const {
10460     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10461         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10462         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10463         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10464         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10465         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10466         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10467         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10468         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10469         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10470         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10471         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10472         static_cast<T>(v36_)};
10473     return ValuesIn(array);
10474   }
10475 
10476  private:
10477   // No implementation - assignment is unsupported.
10478   void operator=(const ValueArray36& other);
10479 
10480   const T1 v1_;
10481   const T2 v2_;
10482   const T3 v3_;
10483   const T4 v4_;
10484   const T5 v5_;
10485   const T6 v6_;
10486   const T7 v7_;
10487   const T8 v8_;
10488   const T9 v9_;
10489   const T10 v10_;
10490   const T11 v11_;
10491   const T12 v12_;
10492   const T13 v13_;
10493   const T14 v14_;
10494   const T15 v15_;
10495   const T16 v16_;
10496   const T17 v17_;
10497   const T18 v18_;
10498   const T19 v19_;
10499   const T20 v20_;
10500   const T21 v21_;
10501   const T22 v22_;
10502   const T23 v23_;
10503   const T24 v24_;
10504   const T25 v25_;
10505   const T26 v26_;
10506   const T27 v27_;
10507   const T28 v28_;
10508   const T29 v29_;
10509   const T30 v30_;
10510   const T31 v31_;
10511   const T32 v32_;
10512   const T33 v33_;
10513   const T34 v34_;
10514   const T35 v35_;
10515   const T36 v36_;
10516 };
10517 
10518 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10519     typename T6, typename T7, typename T8, typename T9, typename T10,
10520     typename T11, typename T12, typename T13, typename T14, typename T15,
10521     typename T16, typename T17, typename T18, typename T19, typename T20,
10522     typename T21, typename T22, typename T23, typename T24, typename T25,
10523     typename T26, typename T27, typename T28, typename T29, typename T30,
10524     typename T31, typename T32, typename T33, typename T34, typename T35,
10525     typename T36, typename T37>
10526 class ValueArray37 {
10527  public:
10528   ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10529       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10530       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10531       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10532       T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
10533       v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
10534       v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
10535       v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
10536       v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
10537       v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
10538       v36_(v36), v37_(v37) {}
10539 
10540   template <typename T>
10541   operator ParamGenerator<T>() const {
10542     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10543         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10544         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10545         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10546         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10547         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10548         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10549         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10550         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10551         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10552         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10553         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10554         static_cast<T>(v36_), static_cast<T>(v37_)};
10555     return ValuesIn(array);
10556   }
10557 
10558  private:
10559   // No implementation - assignment is unsupported.
10560   void operator=(const ValueArray37& other);
10561 
10562   const T1 v1_;
10563   const T2 v2_;
10564   const T3 v3_;
10565   const T4 v4_;
10566   const T5 v5_;
10567   const T6 v6_;
10568   const T7 v7_;
10569   const T8 v8_;
10570   const T9 v9_;
10571   const T10 v10_;
10572   const T11 v11_;
10573   const T12 v12_;
10574   const T13 v13_;
10575   const T14 v14_;
10576   const T15 v15_;
10577   const T16 v16_;
10578   const T17 v17_;
10579   const T18 v18_;
10580   const T19 v19_;
10581   const T20 v20_;
10582   const T21 v21_;
10583   const T22 v22_;
10584   const T23 v23_;
10585   const T24 v24_;
10586   const T25 v25_;
10587   const T26 v26_;
10588   const T27 v27_;
10589   const T28 v28_;
10590   const T29 v29_;
10591   const T30 v30_;
10592   const T31 v31_;
10593   const T32 v32_;
10594   const T33 v33_;
10595   const T34 v34_;
10596   const T35 v35_;
10597   const T36 v36_;
10598   const T37 v37_;
10599 };
10600 
10601 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10602     typename T6, typename T7, typename T8, typename T9, typename T10,
10603     typename T11, typename T12, typename T13, typename T14, typename T15,
10604     typename T16, typename T17, typename T18, typename T19, typename T20,
10605     typename T21, typename T22, typename T23, typename T24, typename T25,
10606     typename T26, typename T27, typename T28, typename T29, typename T30,
10607     typename T31, typename T32, typename T33, typename T34, typename T35,
10608     typename T36, typename T37, typename T38>
10609 class ValueArray38 {
10610  public:
10611   ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10612       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10613       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10614       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10615       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3),
10616       v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
10617       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
10618       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
10619       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
10620       v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
10621       v35_(v35), v36_(v36), v37_(v37), v38_(v38) {}
10622 
10623   template <typename T>
10624   operator ParamGenerator<T>() const {
10625     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10626         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10627         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10628         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10629         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10630         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10631         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10632         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10633         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10634         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10635         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10636         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10637         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_)};
10638     return ValuesIn(array);
10639   }
10640 
10641  private:
10642   // No implementation - assignment is unsupported.
10643   void operator=(const ValueArray38& other);
10644 
10645   const T1 v1_;
10646   const T2 v2_;
10647   const T3 v3_;
10648   const T4 v4_;
10649   const T5 v5_;
10650   const T6 v6_;
10651   const T7 v7_;
10652   const T8 v8_;
10653   const T9 v9_;
10654   const T10 v10_;
10655   const T11 v11_;
10656   const T12 v12_;
10657   const T13 v13_;
10658   const T14 v14_;
10659   const T15 v15_;
10660   const T16 v16_;
10661   const T17 v17_;
10662   const T18 v18_;
10663   const T19 v19_;
10664   const T20 v20_;
10665   const T21 v21_;
10666   const T22 v22_;
10667   const T23 v23_;
10668   const T24 v24_;
10669   const T25 v25_;
10670   const T26 v26_;
10671   const T27 v27_;
10672   const T28 v28_;
10673   const T29 v29_;
10674   const T30 v30_;
10675   const T31 v31_;
10676   const T32 v32_;
10677   const T33 v33_;
10678   const T34 v34_;
10679   const T35 v35_;
10680   const T36 v36_;
10681   const T37 v37_;
10682   const T38 v38_;
10683 };
10684 
10685 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10686     typename T6, typename T7, typename T8, typename T9, typename T10,
10687     typename T11, typename T12, typename T13, typename T14, typename T15,
10688     typename T16, typename T17, typename T18, typename T19, typename T20,
10689     typename T21, typename T22, typename T23, typename T24, typename T25,
10690     typename T26, typename T27, typename T28, typename T29, typename T30,
10691     typename T31, typename T32, typename T33, typename T34, typename T35,
10692     typename T36, typename T37, typename T38, typename T39>
10693 class ValueArray39 {
10694  public:
10695   ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10696       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10697       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10698       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10699       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2),
10700       v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
10701       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
10702       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
10703       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
10704       v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
10705       v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {}
10706 
10707   template <typename T>
10708   operator ParamGenerator<T>() const {
10709     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10710         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10711         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10712         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10713         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10714         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10715         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10716         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10717         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10718         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10719         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10720         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10721         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
10722         static_cast<T>(v39_)};
10723     return ValuesIn(array);
10724   }
10725 
10726  private:
10727   // No implementation - assignment is unsupported.
10728   void operator=(const ValueArray39& other);
10729 
10730   const T1 v1_;
10731   const T2 v2_;
10732   const T3 v3_;
10733   const T4 v4_;
10734   const T5 v5_;
10735   const T6 v6_;
10736   const T7 v7_;
10737   const T8 v8_;
10738   const T9 v9_;
10739   const T10 v10_;
10740   const T11 v11_;
10741   const T12 v12_;
10742   const T13 v13_;
10743   const T14 v14_;
10744   const T15 v15_;
10745   const T16 v16_;
10746   const T17 v17_;
10747   const T18 v18_;
10748   const T19 v19_;
10749   const T20 v20_;
10750   const T21 v21_;
10751   const T22 v22_;
10752   const T23 v23_;
10753   const T24 v24_;
10754   const T25 v25_;
10755   const T26 v26_;
10756   const T27 v27_;
10757   const T28 v28_;
10758   const T29 v29_;
10759   const T30 v30_;
10760   const T31 v31_;
10761   const T32 v32_;
10762   const T33 v33_;
10763   const T34 v34_;
10764   const T35 v35_;
10765   const T36 v36_;
10766   const T37 v37_;
10767   const T38 v38_;
10768   const T39 v39_;
10769 };
10770 
10771 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10772     typename T6, typename T7, typename T8, typename T9, typename T10,
10773     typename T11, typename T12, typename T13, typename T14, typename T15,
10774     typename T16, typename T17, typename T18, typename T19, typename T20,
10775     typename T21, typename T22, typename T23, typename T24, typename T25,
10776     typename T26, typename T27, typename T28, typename T29, typename T30,
10777     typename T31, typename T32, typename T33, typename T34, typename T35,
10778     typename T36, typename T37, typename T38, typename T39, typename T40>
10779 class ValueArray40 {
10780  public:
10781   ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10782       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10783       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10784       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10785       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1),
10786       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
10787       v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
10788       v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
10789       v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
10790       v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
10791       v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
10792       v40_(v40) {}
10793 
10794   template <typename T>
10795   operator ParamGenerator<T>() const {
10796     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10797         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10798         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10799         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10800         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10801         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10802         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10803         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10804         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10805         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10806         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10807         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10808         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
10809         static_cast<T>(v39_), static_cast<T>(v40_)};
10810     return ValuesIn(array);
10811   }
10812 
10813  private:
10814   // No implementation - assignment is unsupported.
10815   void operator=(const ValueArray40& other);
10816 
10817   const T1 v1_;
10818   const T2 v2_;
10819   const T3 v3_;
10820   const T4 v4_;
10821   const T5 v5_;
10822   const T6 v6_;
10823   const T7 v7_;
10824   const T8 v8_;
10825   const T9 v9_;
10826   const T10 v10_;
10827   const T11 v11_;
10828   const T12 v12_;
10829   const T13 v13_;
10830   const T14 v14_;
10831   const T15 v15_;
10832   const T16 v16_;
10833   const T17 v17_;
10834   const T18 v18_;
10835   const T19 v19_;
10836   const T20 v20_;
10837   const T21 v21_;
10838   const T22 v22_;
10839   const T23 v23_;
10840   const T24 v24_;
10841   const T25 v25_;
10842   const T26 v26_;
10843   const T27 v27_;
10844   const T28 v28_;
10845   const T29 v29_;
10846   const T30 v30_;
10847   const T31 v31_;
10848   const T32 v32_;
10849   const T33 v33_;
10850   const T34 v34_;
10851   const T35 v35_;
10852   const T36 v36_;
10853   const T37 v37_;
10854   const T38 v38_;
10855   const T39 v39_;
10856   const T40 v40_;
10857 };
10858 
10859 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10860     typename T6, typename T7, typename T8, typename T9, typename T10,
10861     typename T11, typename T12, typename T13, typename T14, typename T15,
10862     typename T16, typename T17, typename T18, typename T19, typename T20,
10863     typename T21, typename T22, typename T23, typename T24, typename T25,
10864     typename T26, typename T27, typename T28, typename T29, typename T30,
10865     typename T31, typename T32, typename T33, typename T34, typename T35,
10866     typename T36, typename T37, typename T38, typename T39, typename T40,
10867     typename T41>
10868 class ValueArray41 {
10869  public:
10870   ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10871       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10872       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10873       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10874       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
10875       T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
10876       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
10877       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
10878       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
10879       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
10880       v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
10881       v39_(v39), v40_(v40), v41_(v41) {}
10882 
10883   template <typename T>
10884   operator ParamGenerator<T>() const {
10885     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10886         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10887         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10888         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10889         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10890         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10891         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10892         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10893         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10894         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10895         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10896         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10897         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
10898         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_)};
10899     return ValuesIn(array);
10900   }
10901 
10902  private:
10903   // No implementation - assignment is unsupported.
10904   void operator=(const ValueArray41& other);
10905 
10906   const T1 v1_;
10907   const T2 v2_;
10908   const T3 v3_;
10909   const T4 v4_;
10910   const T5 v5_;
10911   const T6 v6_;
10912   const T7 v7_;
10913   const T8 v8_;
10914   const T9 v9_;
10915   const T10 v10_;
10916   const T11 v11_;
10917   const T12 v12_;
10918   const T13 v13_;
10919   const T14 v14_;
10920   const T15 v15_;
10921   const T16 v16_;
10922   const T17 v17_;
10923   const T18 v18_;
10924   const T19 v19_;
10925   const T20 v20_;
10926   const T21 v21_;
10927   const T22 v22_;
10928   const T23 v23_;
10929   const T24 v24_;
10930   const T25 v25_;
10931   const T26 v26_;
10932   const T27 v27_;
10933   const T28 v28_;
10934   const T29 v29_;
10935   const T30 v30_;
10936   const T31 v31_;
10937   const T32 v32_;
10938   const T33 v33_;
10939   const T34 v34_;
10940   const T35 v35_;
10941   const T36 v36_;
10942   const T37 v37_;
10943   const T38 v38_;
10944   const T39 v39_;
10945   const T40 v40_;
10946   const T41 v41_;
10947 };
10948 
10949 template <typename T1, typename T2, typename T3, typename T4, typename T5,
10950     typename T6, typename T7, typename T8, typename T9, typename T10,
10951     typename T11, typename T12, typename T13, typename T14, typename T15,
10952     typename T16, typename T17, typename T18, typename T19, typename T20,
10953     typename T21, typename T22, typename T23, typename T24, typename T25,
10954     typename T26, typename T27, typename T28, typename T29, typename T30,
10955     typename T31, typename T32, typename T33, typename T34, typename T35,
10956     typename T36, typename T37, typename T38, typename T39, typename T40,
10957     typename T41, typename T42>
10958 class ValueArray42 {
10959  public:
10960   ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
10961       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
10962       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
10963       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
10964       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
10965       T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
10966       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
10967       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
10968       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
10969       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
10970       v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
10971       v39_(v39), v40_(v40), v41_(v41), v42_(v42) {}
10972 
10973   template <typename T>
10974   operator ParamGenerator<T>() const {
10975     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
10976         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
10977         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
10978         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
10979         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
10980         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
10981         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
10982         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
10983         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
10984         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
10985         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
10986         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
10987         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
10988         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
10989         static_cast<T>(v42_)};
10990     return ValuesIn(array);
10991   }
10992 
10993  private:
10994   // No implementation - assignment is unsupported.
10995   void operator=(const ValueArray42& other);
10996 
10997   const T1 v1_;
10998   const T2 v2_;
10999   const T3 v3_;
11000   const T4 v4_;
11001   const T5 v5_;
11002   const T6 v6_;
11003   const T7 v7_;
11004   const T8 v8_;
11005   const T9 v9_;
11006   const T10 v10_;
11007   const T11 v11_;
11008   const T12 v12_;
11009   const T13 v13_;
11010   const T14 v14_;
11011   const T15 v15_;
11012   const T16 v16_;
11013   const T17 v17_;
11014   const T18 v18_;
11015   const T19 v19_;
11016   const T20 v20_;
11017   const T21 v21_;
11018   const T22 v22_;
11019   const T23 v23_;
11020   const T24 v24_;
11021   const T25 v25_;
11022   const T26 v26_;
11023   const T27 v27_;
11024   const T28 v28_;
11025   const T29 v29_;
11026   const T30 v30_;
11027   const T31 v31_;
11028   const T32 v32_;
11029   const T33 v33_;
11030   const T34 v34_;
11031   const T35 v35_;
11032   const T36 v36_;
11033   const T37 v37_;
11034   const T38 v38_;
11035   const T39 v39_;
11036   const T40 v40_;
11037   const T41 v41_;
11038   const T42 v42_;
11039 };
11040 
11041 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11042     typename T6, typename T7, typename T8, typename T9, typename T10,
11043     typename T11, typename T12, typename T13, typename T14, typename T15,
11044     typename T16, typename T17, typename T18, typename T19, typename T20,
11045     typename T21, typename T22, typename T23, typename T24, typename T25,
11046     typename T26, typename T27, typename T28, typename T29, typename T30,
11047     typename T31, typename T32, typename T33, typename T34, typename T35,
11048     typename T36, typename T37, typename T38, typename T39, typename T40,
11049     typename T41, typename T42, typename T43>
11050 class ValueArray43 {
11051  public:
11052   ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11053       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11054       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11055       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11056       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11057       T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
11058       v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
11059       v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
11060       v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
11061       v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
11062       v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37),
11063       v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {}
11064 
11065   template <typename T>
11066   operator ParamGenerator<T>() const {
11067     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11068         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11069         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11070         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11071         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11072         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11073         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11074         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11075         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11076         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11077         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11078         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11079         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11080         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11081         static_cast<T>(v42_), static_cast<T>(v43_)};
11082     return ValuesIn(array);
11083   }
11084 
11085  private:
11086   // No implementation - assignment is unsupported.
11087   void operator=(const ValueArray43& other);
11088 
11089   const T1 v1_;
11090   const T2 v2_;
11091   const T3 v3_;
11092   const T4 v4_;
11093   const T5 v5_;
11094   const T6 v6_;
11095   const T7 v7_;
11096   const T8 v8_;
11097   const T9 v9_;
11098   const T10 v10_;
11099   const T11 v11_;
11100   const T12 v12_;
11101   const T13 v13_;
11102   const T14 v14_;
11103   const T15 v15_;
11104   const T16 v16_;
11105   const T17 v17_;
11106   const T18 v18_;
11107   const T19 v19_;
11108   const T20 v20_;
11109   const T21 v21_;
11110   const T22 v22_;
11111   const T23 v23_;
11112   const T24 v24_;
11113   const T25 v25_;
11114   const T26 v26_;
11115   const T27 v27_;
11116   const T28 v28_;
11117   const T29 v29_;
11118   const T30 v30_;
11119   const T31 v31_;
11120   const T32 v32_;
11121   const T33 v33_;
11122   const T34 v34_;
11123   const T35 v35_;
11124   const T36 v36_;
11125   const T37 v37_;
11126   const T38 v38_;
11127   const T39 v39_;
11128   const T40 v40_;
11129   const T41 v41_;
11130   const T42 v42_;
11131   const T43 v43_;
11132 };
11133 
11134 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11135     typename T6, typename T7, typename T8, typename T9, typename T10,
11136     typename T11, typename T12, typename T13, typename T14, typename T15,
11137     typename T16, typename T17, typename T18, typename T19, typename T20,
11138     typename T21, typename T22, typename T23, typename T24, typename T25,
11139     typename T26, typename T27, typename T28, typename T29, typename T30,
11140     typename T31, typename T32, typename T33, typename T34, typename T35,
11141     typename T36, typename T37, typename T38, typename T39, typename T40,
11142     typename T41, typename T42, typename T43, typename T44>
11143 class ValueArray44 {
11144  public:
11145   ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11146       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11147       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11148       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11149       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11150       T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
11151       v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
11152       v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
11153       v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
11154       v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
11155       v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36),
11156       v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42),
11157       v43_(v43), v44_(v44) {}
11158 
11159   template <typename T>
11160   operator ParamGenerator<T>() const {
11161     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11162         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11163         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11164         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11165         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11166         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11167         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11168         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11169         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11170         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11171         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11172         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11173         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11174         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11175         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_)};
11176     return ValuesIn(array);
11177   }
11178 
11179  private:
11180   // No implementation - assignment is unsupported.
11181   void operator=(const ValueArray44& other);
11182 
11183   const T1 v1_;
11184   const T2 v2_;
11185   const T3 v3_;
11186   const T4 v4_;
11187   const T5 v5_;
11188   const T6 v6_;
11189   const T7 v7_;
11190   const T8 v8_;
11191   const T9 v9_;
11192   const T10 v10_;
11193   const T11 v11_;
11194   const T12 v12_;
11195   const T13 v13_;
11196   const T14 v14_;
11197   const T15 v15_;
11198   const T16 v16_;
11199   const T17 v17_;
11200   const T18 v18_;
11201   const T19 v19_;
11202   const T20 v20_;
11203   const T21 v21_;
11204   const T22 v22_;
11205   const T23 v23_;
11206   const T24 v24_;
11207   const T25 v25_;
11208   const T26 v26_;
11209   const T27 v27_;
11210   const T28 v28_;
11211   const T29 v29_;
11212   const T30 v30_;
11213   const T31 v31_;
11214   const T32 v32_;
11215   const T33 v33_;
11216   const T34 v34_;
11217   const T35 v35_;
11218   const T36 v36_;
11219   const T37 v37_;
11220   const T38 v38_;
11221   const T39 v39_;
11222   const T40 v40_;
11223   const T41 v41_;
11224   const T42 v42_;
11225   const T43 v43_;
11226   const T44 v44_;
11227 };
11228 
11229 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11230     typename T6, typename T7, typename T8, typename T9, typename T10,
11231     typename T11, typename T12, typename T13, typename T14, typename T15,
11232     typename T16, typename T17, typename T18, typename T19, typename T20,
11233     typename T21, typename T22, typename T23, typename T24, typename T25,
11234     typename T26, typename T27, typename T28, typename T29, typename T30,
11235     typename T31, typename T32, typename T33, typename T34, typename T35,
11236     typename T36, typename T37, typename T38, typename T39, typename T40,
11237     typename T41, typename T42, typename T43, typename T44, typename T45>
11238 class ValueArray45 {
11239  public:
11240   ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11241       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11242       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11243       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11244       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11245       T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
11246       v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
11247       v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
11248       v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
11249       v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
11250       v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
11251       v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41),
11252       v42_(v42), v43_(v43), v44_(v44), v45_(v45) {}
11253 
11254   template <typename T>
11255   operator ParamGenerator<T>() const {
11256     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11257         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11258         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11259         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11260         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11261         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11262         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11263         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11264         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11265         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11266         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11267         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11268         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11269         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11270         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11271         static_cast<T>(v45_)};
11272     return ValuesIn(array);
11273   }
11274 
11275  private:
11276   // No implementation - assignment is unsupported.
11277   void operator=(const ValueArray45& other);
11278 
11279   const T1 v1_;
11280   const T2 v2_;
11281   const T3 v3_;
11282   const T4 v4_;
11283   const T5 v5_;
11284   const T6 v6_;
11285   const T7 v7_;
11286   const T8 v8_;
11287   const T9 v9_;
11288   const T10 v10_;
11289   const T11 v11_;
11290   const T12 v12_;
11291   const T13 v13_;
11292   const T14 v14_;
11293   const T15 v15_;
11294   const T16 v16_;
11295   const T17 v17_;
11296   const T18 v18_;
11297   const T19 v19_;
11298   const T20 v20_;
11299   const T21 v21_;
11300   const T22 v22_;
11301   const T23 v23_;
11302   const T24 v24_;
11303   const T25 v25_;
11304   const T26 v26_;
11305   const T27 v27_;
11306   const T28 v28_;
11307   const T29 v29_;
11308   const T30 v30_;
11309   const T31 v31_;
11310   const T32 v32_;
11311   const T33 v33_;
11312   const T34 v34_;
11313   const T35 v35_;
11314   const T36 v36_;
11315   const T37 v37_;
11316   const T38 v38_;
11317   const T39 v39_;
11318   const T40 v40_;
11319   const T41 v41_;
11320   const T42 v42_;
11321   const T43 v43_;
11322   const T44 v44_;
11323   const T45 v45_;
11324 };
11325 
11326 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11327     typename T6, typename T7, typename T8, typename T9, typename T10,
11328     typename T11, typename T12, typename T13, typename T14, typename T15,
11329     typename T16, typename T17, typename T18, typename T19, typename T20,
11330     typename T21, typename T22, typename T23, typename T24, typename T25,
11331     typename T26, typename T27, typename T28, typename T29, typename T30,
11332     typename T31, typename T32, typename T33, typename T34, typename T35,
11333     typename T36, typename T37, typename T38, typename T39, typename T40,
11334     typename T41, typename T42, typename T43, typename T44, typename T45,
11335     typename T46>
11336 class ValueArray46 {
11337  public:
11338   ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11339       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11340       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11341       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11342       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11343       T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3),
11344       v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
11345       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
11346       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
11347       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
11348       v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
11349       v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
11350       v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {}
11351 
11352   template <typename T>
11353   operator ParamGenerator<T>() const {
11354     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11355         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11356         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11357         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11358         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11359         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11360         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11361         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11362         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11363         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11364         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11365         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11366         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11367         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11368         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11369         static_cast<T>(v45_), static_cast<T>(v46_)};
11370     return ValuesIn(array);
11371   }
11372 
11373  private:
11374   // No implementation - assignment is unsupported.
11375   void operator=(const ValueArray46& other);
11376 
11377   const T1 v1_;
11378   const T2 v2_;
11379   const T3 v3_;
11380   const T4 v4_;
11381   const T5 v5_;
11382   const T6 v6_;
11383   const T7 v7_;
11384   const T8 v8_;
11385   const T9 v9_;
11386   const T10 v10_;
11387   const T11 v11_;
11388   const T12 v12_;
11389   const T13 v13_;
11390   const T14 v14_;
11391   const T15 v15_;
11392   const T16 v16_;
11393   const T17 v17_;
11394   const T18 v18_;
11395   const T19 v19_;
11396   const T20 v20_;
11397   const T21 v21_;
11398   const T22 v22_;
11399   const T23 v23_;
11400   const T24 v24_;
11401   const T25 v25_;
11402   const T26 v26_;
11403   const T27 v27_;
11404   const T28 v28_;
11405   const T29 v29_;
11406   const T30 v30_;
11407   const T31 v31_;
11408   const T32 v32_;
11409   const T33 v33_;
11410   const T34 v34_;
11411   const T35 v35_;
11412   const T36 v36_;
11413   const T37 v37_;
11414   const T38 v38_;
11415   const T39 v39_;
11416   const T40 v40_;
11417   const T41 v41_;
11418   const T42 v42_;
11419   const T43 v43_;
11420   const T44 v44_;
11421   const T45 v45_;
11422   const T46 v46_;
11423 };
11424 
11425 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11426     typename T6, typename T7, typename T8, typename T9, typename T10,
11427     typename T11, typename T12, typename T13, typename T14, typename T15,
11428     typename T16, typename T17, typename T18, typename T19, typename T20,
11429     typename T21, typename T22, typename T23, typename T24, typename T25,
11430     typename T26, typename T27, typename T28, typename T29, typename T30,
11431     typename T31, typename T32, typename T33, typename T34, typename T35,
11432     typename T36, typename T37, typename T38, typename T39, typename T40,
11433     typename T41, typename T42, typename T43, typename T44, typename T45,
11434     typename T46, typename T47>
11435 class ValueArray47 {
11436  public:
11437   ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11438       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11439       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11440       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11441       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11442       T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2),
11443       v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
11444       v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
11445       v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
11446       v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
11447       v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
11448       v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
11449       v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46),
11450       v47_(v47) {}
11451 
11452   template <typename T>
11453   operator ParamGenerator<T>() const {
11454     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11455         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11456         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11457         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11458         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11459         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11460         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11461         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11462         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11463         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11464         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11465         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11466         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11467         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11468         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11469         static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_)};
11470     return ValuesIn(array);
11471   }
11472 
11473  private:
11474   // No implementation - assignment is unsupported.
11475   void operator=(const ValueArray47& other);
11476 
11477   const T1 v1_;
11478   const T2 v2_;
11479   const T3 v3_;
11480   const T4 v4_;
11481   const T5 v5_;
11482   const T6 v6_;
11483   const T7 v7_;
11484   const T8 v8_;
11485   const T9 v9_;
11486   const T10 v10_;
11487   const T11 v11_;
11488   const T12 v12_;
11489   const T13 v13_;
11490   const T14 v14_;
11491   const T15 v15_;
11492   const T16 v16_;
11493   const T17 v17_;
11494   const T18 v18_;
11495   const T19 v19_;
11496   const T20 v20_;
11497   const T21 v21_;
11498   const T22 v22_;
11499   const T23 v23_;
11500   const T24 v24_;
11501   const T25 v25_;
11502   const T26 v26_;
11503   const T27 v27_;
11504   const T28 v28_;
11505   const T29 v29_;
11506   const T30 v30_;
11507   const T31 v31_;
11508   const T32 v32_;
11509   const T33 v33_;
11510   const T34 v34_;
11511   const T35 v35_;
11512   const T36 v36_;
11513   const T37 v37_;
11514   const T38 v38_;
11515   const T39 v39_;
11516   const T40 v40_;
11517   const T41 v41_;
11518   const T42 v42_;
11519   const T43 v43_;
11520   const T44 v44_;
11521   const T45 v45_;
11522   const T46 v46_;
11523   const T47 v47_;
11524 };
11525 
11526 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11527     typename T6, typename T7, typename T8, typename T9, typename T10,
11528     typename T11, typename T12, typename T13, typename T14, typename T15,
11529     typename T16, typename T17, typename T18, typename T19, typename T20,
11530     typename T21, typename T22, typename T23, typename T24, typename T25,
11531     typename T26, typename T27, typename T28, typename T29, typename T30,
11532     typename T31, typename T32, typename T33, typename T34, typename T35,
11533     typename T36, typename T37, typename T38, typename T39, typename T40,
11534     typename T41, typename T42, typename T43, typename T44, typename T45,
11535     typename T46, typename T47, typename T48>
11536 class ValueArray48 {
11537  public:
11538   ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11539       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11540       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11541       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11542       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11543       T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1),
11544       v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
11545       v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
11546       v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
11547       v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
11548       v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
11549       v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
11550       v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45),
11551       v46_(v46), v47_(v47), v48_(v48) {}
11552 
11553   template <typename T>
11554   operator ParamGenerator<T>() const {
11555     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11556         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11557         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11558         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11559         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11560         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11561         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11562         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11563         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11564         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11565         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11566         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11567         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11568         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11569         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11570         static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
11571         static_cast<T>(v48_)};
11572     return ValuesIn(array);
11573   }
11574 
11575  private:
11576   // No implementation - assignment is unsupported.
11577   void operator=(const ValueArray48& other);
11578 
11579   const T1 v1_;
11580   const T2 v2_;
11581   const T3 v3_;
11582   const T4 v4_;
11583   const T5 v5_;
11584   const T6 v6_;
11585   const T7 v7_;
11586   const T8 v8_;
11587   const T9 v9_;
11588   const T10 v10_;
11589   const T11 v11_;
11590   const T12 v12_;
11591   const T13 v13_;
11592   const T14 v14_;
11593   const T15 v15_;
11594   const T16 v16_;
11595   const T17 v17_;
11596   const T18 v18_;
11597   const T19 v19_;
11598   const T20 v20_;
11599   const T21 v21_;
11600   const T22 v22_;
11601   const T23 v23_;
11602   const T24 v24_;
11603   const T25 v25_;
11604   const T26 v26_;
11605   const T27 v27_;
11606   const T28 v28_;
11607   const T29 v29_;
11608   const T30 v30_;
11609   const T31 v31_;
11610   const T32 v32_;
11611   const T33 v33_;
11612   const T34 v34_;
11613   const T35 v35_;
11614   const T36 v36_;
11615   const T37 v37_;
11616   const T38 v38_;
11617   const T39 v39_;
11618   const T40 v40_;
11619   const T41 v41_;
11620   const T42 v42_;
11621   const T43 v43_;
11622   const T44 v44_;
11623   const T45 v45_;
11624   const T46 v46_;
11625   const T47 v47_;
11626   const T48 v48_;
11627 };
11628 
11629 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11630     typename T6, typename T7, typename T8, typename T9, typename T10,
11631     typename T11, typename T12, typename T13, typename T14, typename T15,
11632     typename T16, typename T17, typename T18, typename T19, typename T20,
11633     typename T21, typename T22, typename T23, typename T24, typename T25,
11634     typename T26, typename T27, typename T28, typename T29, typename T30,
11635     typename T31, typename T32, typename T33, typename T34, typename T35,
11636     typename T36, typename T37, typename T38, typename T39, typename T40,
11637     typename T41, typename T42, typename T43, typename T44, typename T45,
11638     typename T46, typename T47, typename T48, typename T49>
11639 class ValueArray49 {
11640  public:
11641   ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11642       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11643       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11644       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11645       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11646       T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48,
11647       T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
11648       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
11649       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
11650       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
11651       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
11652       v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
11653       v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
11654       v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {}
11655 
11656   template <typename T>
11657   operator ParamGenerator<T>() const {
11658     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11659         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11660         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11661         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11662         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11663         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11664         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11665         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11666         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11667         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11668         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11669         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11670         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11671         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11672         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11673         static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
11674         static_cast<T>(v48_), static_cast<T>(v49_)};
11675     return ValuesIn(array);
11676   }
11677 
11678  private:
11679   // No implementation - assignment is unsupported.
11680   void operator=(const ValueArray49& other);
11681 
11682   const T1 v1_;
11683   const T2 v2_;
11684   const T3 v3_;
11685   const T4 v4_;
11686   const T5 v5_;
11687   const T6 v6_;
11688   const T7 v7_;
11689   const T8 v8_;
11690   const T9 v9_;
11691   const T10 v10_;
11692   const T11 v11_;
11693   const T12 v12_;
11694   const T13 v13_;
11695   const T14 v14_;
11696   const T15 v15_;
11697   const T16 v16_;
11698   const T17 v17_;
11699   const T18 v18_;
11700   const T19 v19_;
11701   const T20 v20_;
11702   const T21 v21_;
11703   const T22 v22_;
11704   const T23 v23_;
11705   const T24 v24_;
11706   const T25 v25_;
11707   const T26 v26_;
11708   const T27 v27_;
11709   const T28 v28_;
11710   const T29 v29_;
11711   const T30 v30_;
11712   const T31 v31_;
11713   const T32 v32_;
11714   const T33 v33_;
11715   const T34 v34_;
11716   const T35 v35_;
11717   const T36 v36_;
11718   const T37 v37_;
11719   const T38 v38_;
11720   const T39 v39_;
11721   const T40 v40_;
11722   const T41 v41_;
11723   const T42 v42_;
11724   const T43 v43_;
11725   const T44 v44_;
11726   const T45 v45_;
11727   const T46 v46_;
11728   const T47 v47_;
11729   const T48 v48_;
11730   const T49 v49_;
11731 };
11732 
11733 template <typename T1, typename T2, typename T3, typename T4, typename T5,
11734     typename T6, typename T7, typename T8, typename T9, typename T10,
11735     typename T11, typename T12, typename T13, typename T14, typename T15,
11736     typename T16, typename T17, typename T18, typename T19, typename T20,
11737     typename T21, typename T22, typename T23, typename T24, typename T25,
11738     typename T26, typename T27, typename T28, typename T29, typename T30,
11739     typename T31, typename T32, typename T33, typename T34, typename T35,
11740     typename T36, typename T37, typename T38, typename T39, typename T40,
11741     typename T41, typename T42, typename T43, typename T44, typename T45,
11742     typename T46, typename T47, typename T48, typename T49, typename T50>
11743 class ValueArray50 {
11744  public:
11745   ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
11746       T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
11747       T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
11748       T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
11749       T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
11750       T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49,
11751       T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
11752       v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
11753       v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
11754       v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
11755       v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
11756       v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
11757       v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
11758       v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {}
11759 
11760   template <typename T>
11761   operator ParamGenerator<T>() const {
11762     const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),
11763         static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),
11764         static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),
11765         static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),
11766         static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),
11767         static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),
11768         static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),
11769         static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),
11770         static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),
11771         static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),
11772         static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),
11773         static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),
11774         static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),
11775         static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),
11776         static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),
11777         static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),
11778         static_cast<T>(v48_), static_cast<T>(v49_), static_cast<T>(v50_)};
11779     return ValuesIn(array);
11780   }
11781 
11782  private:
11783   // No implementation - assignment is unsupported.
11784   void operator=(const ValueArray50& other);
11785 
11786   const T1 v1_;
11787   const T2 v2_;
11788   const T3 v3_;
11789   const T4 v4_;
11790   const T5 v5_;
11791   const T6 v6_;
11792   const T7 v7_;
11793   const T8 v8_;
11794   const T9 v9_;
11795   const T10 v10_;
11796   const T11 v11_;
11797   const T12 v12_;
11798   const T13 v13_;
11799   const T14 v14_;
11800   const T15 v15_;
11801   const T16 v16_;
11802   const T17 v17_;
11803   const T18 v18_;
11804   const T19 v19_;
11805   const T20 v20_;
11806   const T21 v21_;
11807   const T22 v22_;
11808   const T23 v23_;
11809   const T24 v24_;
11810   const T25 v25_;
11811   const T26 v26_;
11812   const T27 v27_;
11813   const T28 v28_;
11814   const T29 v29_;
11815   const T30 v30_;
11816   const T31 v31_;
11817   const T32 v32_;
11818   const T33 v33_;
11819   const T34 v34_;
11820   const T35 v35_;
11821   const T36 v36_;
11822   const T37 v37_;
11823   const T38 v38_;
11824   const T39 v39_;
11825   const T40 v40_;
11826   const T41 v41_;
11827   const T42 v42_;
11828   const T43 v43_;
11829   const T44 v44_;
11830   const T45 v45_;
11831   const T46 v46_;
11832   const T47 v47_;
11833   const T48 v48_;
11834   const T49 v49_;
11835   const T50 v50_;
11836 };
11837 
11838 # if GTEST_HAS_COMBINE
11839 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
11840 //
11841 // Generates values from the Cartesian product of values produced
11842 // by the argument generators.
11843 //
11844 template <typename T1, typename T2>
11845 class CartesianProductGenerator2
11846     : public ParamGeneratorInterface< ::testing::tuple<T1, T2> > {
11847  public:
11848   typedef ::testing::tuple<T1, T2> ParamType;
11849 
11850   CartesianProductGenerator2(const ParamGenerator<T1>& g1,
11851       const ParamGenerator<T2>& g2)
11852       : g1_(g1), g2_(g2) {}
11853   virtual ~CartesianProductGenerator2() {}
11854 
11855   virtual ParamIteratorInterface<ParamType>* Begin() const {
11856     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());
11857   }
11858   virtual ParamIteratorInterface<ParamType>* End() const {
11859     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());
11860   }
11861 
11862  private:
11863   class Iterator : public ParamIteratorInterface<ParamType> {
11864    public:
11865     Iterator(const ParamGeneratorInterface<ParamType>* base,
11866       const ParamGenerator<T1>& g1,
11867       const typename ParamGenerator<T1>::iterator& current1,
11868       const ParamGenerator<T2>& g2,
11869       const typename ParamGenerator<T2>::iterator& current2)
11870         : base_(base),
11871           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
11872           begin2_(g2.begin()), end2_(g2.end()), current2_(current2)    {
11873       ComputeCurrentValue();
11874     }
11875     virtual ~Iterator() {}
11876 
11877     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
11878       return base_;
11879     }
11880     // Advance should not be called on beyond-of-range iterators
11881     // so no component iterators must be beyond end of range, either.
11882     virtual void Advance() {
11883       assert(!AtEnd());
11884       ++current2_;
11885       if (current2_ == end2_) {
11886         current2_ = begin2_;
11887         ++current1_;
11888       }
11889       ComputeCurrentValue();
11890     }
11891     virtual ParamIteratorInterface<ParamType>* Clone() const {
11892       return new Iterator(*this);
11893     }
11894     virtual const ParamType* Current() const { return &current_value_; }
11895     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
11896       // Having the same base generator guarantees that the other
11897       // iterator is of the same type and we can downcast.
11898       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
11899           << "The program attempted to compare iterators "
11900           << "from different generators." << std::endl;
11901       const Iterator* typed_other =
11902           CheckedDowncastToActualType<const Iterator>(&other);
11903       // We must report iterators equal if they both point beyond their
11904       // respective ranges. That can happen in a variety of fashions,
11905       // so we have to consult AtEnd().
11906       return (AtEnd() && typed_other->AtEnd()) ||
11907          (
11908           current1_ == typed_other->current1_ &&
11909           current2_ == typed_other->current2_);
11910     }
11911 
11912    private:
11913     Iterator(const Iterator& other)
11914         : base_(other.base_),
11915         begin1_(other.begin1_),
11916         end1_(other.end1_),
11917         current1_(other.current1_),
11918         begin2_(other.begin2_),
11919         end2_(other.end2_),
11920         current2_(other.current2_) {
11921       ComputeCurrentValue();
11922     }
11923 
11924     void ComputeCurrentValue() {
11925       if (!AtEnd())
11926         current_value_ = ParamType(*current1_, *current2_);
11927     }
11928     bool AtEnd() const {
11929       // We must report iterator past the end of the range when either of the
11930       // component iterators has reached the end of its range.
11931       return
11932           current1_ == end1_ ||
11933           current2_ == end2_;
11934     }
11935 
11936     // No implementation - assignment is unsupported.
11937     void operator=(const Iterator& other);
11938 
11939     const ParamGeneratorInterface<ParamType>* const base_;
11940     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
11941     // current[i]_ is the actual traversing iterator.
11942     const typename ParamGenerator<T1>::iterator begin1_;
11943     const typename ParamGenerator<T1>::iterator end1_;
11944     typename ParamGenerator<T1>::iterator current1_;
11945     const typename ParamGenerator<T2>::iterator begin2_;
11946     const typename ParamGenerator<T2>::iterator end2_;
11947     typename ParamGenerator<T2>::iterator current2_;
11948     ParamType current_value_;
11949   };  // class CartesianProductGenerator2::Iterator
11950 
11951   // No implementation - assignment is unsupported.
11952   void operator=(const CartesianProductGenerator2& other);
11953 
11954   const ParamGenerator<T1> g1_;
11955   const ParamGenerator<T2> g2_;
11956 };  // class CartesianProductGenerator2
11957 
11958 
11959 template <typename T1, typename T2, typename T3>
11960 class CartesianProductGenerator3
11961     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3> > {
11962  public:
11963   typedef ::testing::tuple<T1, T2, T3> ParamType;
11964 
11965   CartesianProductGenerator3(const ParamGenerator<T1>& g1,
11966       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
11967       : g1_(g1), g2_(g2), g3_(g3) {}
11968   virtual ~CartesianProductGenerator3() {}
11969 
11970   virtual ParamIteratorInterface<ParamType>* Begin() const {
11971     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
11972         g3_.begin());
11973   }
11974   virtual ParamIteratorInterface<ParamType>* End() const {
11975     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());
11976   }
11977 
11978  private:
11979   class Iterator : public ParamIteratorInterface<ParamType> {
11980    public:
11981     Iterator(const ParamGeneratorInterface<ParamType>* base,
11982       const ParamGenerator<T1>& g1,
11983       const typename ParamGenerator<T1>::iterator& current1,
11984       const ParamGenerator<T2>& g2,
11985       const typename ParamGenerator<T2>::iterator& current2,
11986       const ParamGenerator<T3>& g3,
11987       const typename ParamGenerator<T3>::iterator& current3)
11988         : base_(base),
11989           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
11990           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
11991           begin3_(g3.begin()), end3_(g3.end()), current3_(current3)    {
11992       ComputeCurrentValue();
11993     }
11994     virtual ~Iterator() {}
11995 
11996     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
11997       return base_;
11998     }
11999     // Advance should not be called on beyond-of-range iterators
12000     // so no component iterators must be beyond end of range, either.
12001     virtual void Advance() {
12002       assert(!AtEnd());
12003       ++current3_;
12004       if (current3_ == end3_) {
12005         current3_ = begin3_;
12006         ++current2_;
12007       }
12008       if (current2_ == end2_) {
12009         current2_ = begin2_;
12010         ++current1_;
12011       }
12012       ComputeCurrentValue();
12013     }
12014     virtual ParamIteratorInterface<ParamType>* Clone() const {
12015       return new Iterator(*this);
12016     }
12017     virtual const ParamType* Current() const { return &current_value_; }
12018     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12019       // Having the same base generator guarantees that the other
12020       // iterator is of the same type and we can downcast.
12021       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12022           << "The program attempted to compare iterators "
12023           << "from different generators." << std::endl;
12024       const Iterator* typed_other =
12025           CheckedDowncastToActualType<const Iterator>(&other);
12026       // We must report iterators equal if they both point beyond their
12027       // respective ranges. That can happen in a variety of fashions,
12028       // so we have to consult AtEnd().
12029       return (AtEnd() && typed_other->AtEnd()) ||
12030          (
12031           current1_ == typed_other->current1_ &&
12032           current2_ == typed_other->current2_ &&
12033           current3_ == typed_other->current3_);
12034     }
12035 
12036    private:
12037     Iterator(const Iterator& other)
12038         : base_(other.base_),
12039         begin1_(other.begin1_),
12040         end1_(other.end1_),
12041         current1_(other.current1_),
12042         begin2_(other.begin2_),
12043         end2_(other.end2_),
12044         current2_(other.current2_),
12045         begin3_(other.begin3_),
12046         end3_(other.end3_),
12047         current3_(other.current3_) {
12048       ComputeCurrentValue();
12049     }
12050 
12051     void ComputeCurrentValue() {
12052       if (!AtEnd())
12053         current_value_ = ParamType(*current1_, *current2_, *current3_);
12054     }
12055     bool AtEnd() const {
12056       // We must report iterator past the end of the range when either of the
12057       // component iterators has reached the end of its range.
12058       return
12059           current1_ == end1_ ||
12060           current2_ == end2_ ||
12061           current3_ == end3_;
12062     }
12063 
12064     // No implementation - assignment is unsupported.
12065     void operator=(const Iterator& other);
12066 
12067     const ParamGeneratorInterface<ParamType>* const base_;
12068     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12069     // current[i]_ is the actual traversing iterator.
12070     const typename ParamGenerator<T1>::iterator begin1_;
12071     const typename ParamGenerator<T1>::iterator end1_;
12072     typename ParamGenerator<T1>::iterator current1_;
12073     const typename ParamGenerator<T2>::iterator begin2_;
12074     const typename ParamGenerator<T2>::iterator end2_;
12075     typename ParamGenerator<T2>::iterator current2_;
12076     const typename ParamGenerator<T3>::iterator begin3_;
12077     const typename ParamGenerator<T3>::iterator end3_;
12078     typename ParamGenerator<T3>::iterator current3_;
12079     ParamType current_value_;
12080   };  // class CartesianProductGenerator3::Iterator
12081 
12082   // No implementation - assignment is unsupported.
12083   void operator=(const CartesianProductGenerator3& other);
12084 
12085   const ParamGenerator<T1> g1_;
12086   const ParamGenerator<T2> g2_;
12087   const ParamGenerator<T3> g3_;
12088 };  // class CartesianProductGenerator3
12089 
12090 
12091 template <typename T1, typename T2, typename T3, typename T4>
12092 class CartesianProductGenerator4
12093     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4> > {
12094  public:
12095   typedef ::testing::tuple<T1, T2, T3, T4> ParamType;
12096 
12097   CartesianProductGenerator4(const ParamGenerator<T1>& g1,
12098       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
12099       const ParamGenerator<T4>& g4)
12100       : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
12101   virtual ~CartesianProductGenerator4() {}
12102 
12103   virtual ParamIteratorInterface<ParamType>* Begin() const {
12104     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
12105         g3_.begin(), g4_, g4_.begin());
12106   }
12107   virtual ParamIteratorInterface<ParamType>* End() const {
12108     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
12109         g4_, g4_.end());
12110   }
12111 
12112  private:
12113   class Iterator : public ParamIteratorInterface<ParamType> {
12114    public:
12115     Iterator(const ParamGeneratorInterface<ParamType>* base,
12116       const ParamGenerator<T1>& g1,
12117       const typename ParamGenerator<T1>::iterator& current1,
12118       const ParamGenerator<T2>& g2,
12119       const typename ParamGenerator<T2>::iterator& current2,
12120       const ParamGenerator<T3>& g3,
12121       const typename ParamGenerator<T3>::iterator& current3,
12122       const ParamGenerator<T4>& g4,
12123       const typename ParamGenerator<T4>::iterator& current4)
12124         : base_(base),
12125           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
12126           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
12127           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
12128           begin4_(g4.begin()), end4_(g4.end()), current4_(current4)    {
12129       ComputeCurrentValue();
12130     }
12131     virtual ~Iterator() {}
12132 
12133     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
12134       return base_;
12135     }
12136     // Advance should not be called on beyond-of-range iterators
12137     // so no component iterators must be beyond end of range, either.
12138     virtual void Advance() {
12139       assert(!AtEnd());
12140       ++current4_;
12141       if (current4_ == end4_) {
12142         current4_ = begin4_;
12143         ++current3_;
12144       }
12145       if (current3_ == end3_) {
12146         current3_ = begin3_;
12147         ++current2_;
12148       }
12149       if (current2_ == end2_) {
12150         current2_ = begin2_;
12151         ++current1_;
12152       }
12153       ComputeCurrentValue();
12154     }
12155     virtual ParamIteratorInterface<ParamType>* Clone() const {
12156       return new Iterator(*this);
12157     }
12158     virtual const ParamType* Current() const { return &current_value_; }
12159     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12160       // Having the same base generator guarantees that the other
12161       // iterator is of the same type and we can downcast.
12162       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12163           << "The program attempted to compare iterators "
12164           << "from different generators." << std::endl;
12165       const Iterator* typed_other =
12166           CheckedDowncastToActualType<const Iterator>(&other);
12167       // We must report iterators equal if they both point beyond their
12168       // respective ranges. That can happen in a variety of fashions,
12169       // so we have to consult AtEnd().
12170       return (AtEnd() && typed_other->AtEnd()) ||
12171          (
12172           current1_ == typed_other->current1_ &&
12173           current2_ == typed_other->current2_ &&
12174           current3_ == typed_other->current3_ &&
12175           current4_ == typed_other->current4_);
12176     }
12177 
12178    private:
12179     Iterator(const Iterator& other)
12180         : base_(other.base_),
12181         begin1_(other.begin1_),
12182         end1_(other.end1_),
12183         current1_(other.current1_),
12184         begin2_(other.begin2_),
12185         end2_(other.end2_),
12186         current2_(other.current2_),
12187         begin3_(other.begin3_),
12188         end3_(other.end3_),
12189         current3_(other.current3_),
12190         begin4_(other.begin4_),
12191         end4_(other.end4_),
12192         current4_(other.current4_) {
12193       ComputeCurrentValue();
12194     }
12195 
12196     void ComputeCurrentValue() {
12197       if (!AtEnd())
12198         current_value_ = ParamType(*current1_, *current2_, *current3_,
12199             *current4_);
12200     }
12201     bool AtEnd() const {
12202       // We must report iterator past the end of the range when either of the
12203       // component iterators has reached the end of its range.
12204       return
12205           current1_ == end1_ ||
12206           current2_ == end2_ ||
12207           current3_ == end3_ ||
12208           current4_ == end4_;
12209     }
12210 
12211     // No implementation - assignment is unsupported.
12212     void operator=(const Iterator& other);
12213 
12214     const ParamGeneratorInterface<ParamType>* const base_;
12215     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12216     // current[i]_ is the actual traversing iterator.
12217     const typename ParamGenerator<T1>::iterator begin1_;
12218     const typename ParamGenerator<T1>::iterator end1_;
12219     typename ParamGenerator<T1>::iterator current1_;
12220     const typename ParamGenerator<T2>::iterator begin2_;
12221     const typename ParamGenerator<T2>::iterator end2_;
12222     typename ParamGenerator<T2>::iterator current2_;
12223     const typename ParamGenerator<T3>::iterator begin3_;
12224     const typename ParamGenerator<T3>::iterator end3_;
12225     typename ParamGenerator<T3>::iterator current3_;
12226     const typename ParamGenerator<T4>::iterator begin4_;
12227     const typename ParamGenerator<T4>::iterator end4_;
12228     typename ParamGenerator<T4>::iterator current4_;
12229     ParamType current_value_;
12230   };  // class CartesianProductGenerator4::Iterator
12231 
12232   // No implementation - assignment is unsupported.
12233   void operator=(const CartesianProductGenerator4& other);
12234 
12235   const ParamGenerator<T1> g1_;
12236   const ParamGenerator<T2> g2_;
12237   const ParamGenerator<T3> g3_;
12238   const ParamGenerator<T4> g4_;
12239 };  // class CartesianProductGenerator4
12240 
12241 
12242 template <typename T1, typename T2, typename T3, typename T4, typename T5>
12243 class CartesianProductGenerator5
12244     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5> > {
12245  public:
12246   typedef ::testing::tuple<T1, T2, T3, T4, T5> ParamType;
12247 
12248   CartesianProductGenerator5(const ParamGenerator<T1>& g1,
12249       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
12250       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)
12251       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
12252   virtual ~CartesianProductGenerator5() {}
12253 
12254   virtual ParamIteratorInterface<ParamType>* Begin() const {
12255     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
12256         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());
12257   }
12258   virtual ParamIteratorInterface<ParamType>* End() const {
12259     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
12260         g4_, g4_.end(), g5_, g5_.end());
12261   }
12262 
12263  private:
12264   class Iterator : public ParamIteratorInterface<ParamType> {
12265    public:
12266     Iterator(const ParamGeneratorInterface<ParamType>* base,
12267       const ParamGenerator<T1>& g1,
12268       const typename ParamGenerator<T1>::iterator& current1,
12269       const ParamGenerator<T2>& g2,
12270       const typename ParamGenerator<T2>::iterator& current2,
12271       const ParamGenerator<T3>& g3,
12272       const typename ParamGenerator<T3>::iterator& current3,
12273       const ParamGenerator<T4>& g4,
12274       const typename ParamGenerator<T4>::iterator& current4,
12275       const ParamGenerator<T5>& g5,
12276       const typename ParamGenerator<T5>::iterator& current5)
12277         : base_(base),
12278           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
12279           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
12280           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
12281           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
12282           begin5_(g5.begin()), end5_(g5.end()), current5_(current5)    {
12283       ComputeCurrentValue();
12284     }
12285     virtual ~Iterator() {}
12286 
12287     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
12288       return base_;
12289     }
12290     // Advance should not be called on beyond-of-range iterators
12291     // so no component iterators must be beyond end of range, either.
12292     virtual void Advance() {
12293       assert(!AtEnd());
12294       ++current5_;
12295       if (current5_ == end5_) {
12296         current5_ = begin5_;
12297         ++current4_;
12298       }
12299       if (current4_ == end4_) {
12300         current4_ = begin4_;
12301         ++current3_;
12302       }
12303       if (current3_ == end3_) {
12304         current3_ = begin3_;
12305         ++current2_;
12306       }
12307       if (current2_ == end2_) {
12308         current2_ = begin2_;
12309         ++current1_;
12310       }
12311       ComputeCurrentValue();
12312     }
12313     virtual ParamIteratorInterface<ParamType>* Clone() const {
12314       return new Iterator(*this);
12315     }
12316     virtual const ParamType* Current() const { return &current_value_; }
12317     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12318       // Having the same base generator guarantees that the other
12319       // iterator is of the same type and we can downcast.
12320       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12321           << "The program attempted to compare iterators "
12322           << "from different generators." << std::endl;
12323       const Iterator* typed_other =
12324           CheckedDowncastToActualType<const Iterator>(&other);
12325       // We must report iterators equal if they both point beyond their
12326       // respective ranges. That can happen in a variety of fashions,
12327       // so we have to consult AtEnd().
12328       return (AtEnd() && typed_other->AtEnd()) ||
12329          (
12330           current1_ == typed_other->current1_ &&
12331           current2_ == typed_other->current2_ &&
12332           current3_ == typed_other->current3_ &&
12333           current4_ == typed_other->current4_ &&
12334           current5_ == typed_other->current5_);
12335     }
12336 
12337    private:
12338     Iterator(const Iterator& other)
12339         : base_(other.base_),
12340         begin1_(other.begin1_),
12341         end1_(other.end1_),
12342         current1_(other.current1_),
12343         begin2_(other.begin2_),
12344         end2_(other.end2_),
12345         current2_(other.current2_),
12346         begin3_(other.begin3_),
12347         end3_(other.end3_),
12348         current3_(other.current3_),
12349         begin4_(other.begin4_),
12350         end4_(other.end4_),
12351         current4_(other.current4_),
12352         begin5_(other.begin5_),
12353         end5_(other.end5_),
12354         current5_(other.current5_) {
12355       ComputeCurrentValue();
12356     }
12357 
12358     void ComputeCurrentValue() {
12359       if (!AtEnd())
12360         current_value_ = ParamType(*current1_, *current2_, *current3_,
12361             *current4_, *current5_);
12362     }
12363     bool AtEnd() const {
12364       // We must report iterator past the end of the range when either of the
12365       // component iterators has reached the end of its range.
12366       return
12367           current1_ == end1_ ||
12368           current2_ == end2_ ||
12369           current3_ == end3_ ||
12370           current4_ == end4_ ||
12371           current5_ == end5_;
12372     }
12373 
12374     // No implementation - assignment is unsupported.
12375     void operator=(const Iterator& other);
12376 
12377     const ParamGeneratorInterface<ParamType>* const base_;
12378     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12379     // current[i]_ is the actual traversing iterator.
12380     const typename ParamGenerator<T1>::iterator begin1_;
12381     const typename ParamGenerator<T1>::iterator end1_;
12382     typename ParamGenerator<T1>::iterator current1_;
12383     const typename ParamGenerator<T2>::iterator begin2_;
12384     const typename ParamGenerator<T2>::iterator end2_;
12385     typename ParamGenerator<T2>::iterator current2_;
12386     const typename ParamGenerator<T3>::iterator begin3_;
12387     const typename ParamGenerator<T3>::iterator end3_;
12388     typename ParamGenerator<T3>::iterator current3_;
12389     const typename ParamGenerator<T4>::iterator begin4_;
12390     const typename ParamGenerator<T4>::iterator end4_;
12391     typename ParamGenerator<T4>::iterator current4_;
12392     const typename ParamGenerator<T5>::iterator begin5_;
12393     const typename ParamGenerator<T5>::iterator end5_;
12394     typename ParamGenerator<T5>::iterator current5_;
12395     ParamType current_value_;
12396   };  // class CartesianProductGenerator5::Iterator
12397 
12398   // No implementation - assignment is unsupported.
12399   void operator=(const CartesianProductGenerator5& other);
12400 
12401   const ParamGenerator<T1> g1_;
12402   const ParamGenerator<T2> g2_;
12403   const ParamGenerator<T3> g3_;
12404   const ParamGenerator<T4> g4_;
12405   const ParamGenerator<T5> g5_;
12406 };  // class CartesianProductGenerator5
12407 
12408 
12409 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12410     typename T6>
12411 class CartesianProductGenerator6
12412     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5,
12413         T6> > {
12414  public:
12415   typedef ::testing::tuple<T1, T2, T3, T4, T5, T6> ParamType;
12416 
12417   CartesianProductGenerator6(const ParamGenerator<T1>& g1,
12418       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
12419       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
12420       const ParamGenerator<T6>& g6)
12421       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
12422   virtual ~CartesianProductGenerator6() {}
12423 
12424   virtual ParamIteratorInterface<ParamType>* Begin() const {
12425     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
12426         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());
12427   }
12428   virtual ParamIteratorInterface<ParamType>* End() const {
12429     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
12430         g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());
12431   }
12432 
12433  private:
12434   class Iterator : public ParamIteratorInterface<ParamType> {
12435    public:
12436     Iterator(const ParamGeneratorInterface<ParamType>* base,
12437       const ParamGenerator<T1>& g1,
12438       const typename ParamGenerator<T1>::iterator& current1,
12439       const ParamGenerator<T2>& g2,
12440       const typename ParamGenerator<T2>::iterator& current2,
12441       const ParamGenerator<T3>& g3,
12442       const typename ParamGenerator<T3>::iterator& current3,
12443       const ParamGenerator<T4>& g4,
12444       const typename ParamGenerator<T4>::iterator& current4,
12445       const ParamGenerator<T5>& g5,
12446       const typename ParamGenerator<T5>::iterator& current5,
12447       const ParamGenerator<T6>& g6,
12448       const typename ParamGenerator<T6>::iterator& current6)
12449         : base_(base),
12450           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
12451           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
12452           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
12453           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
12454           begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
12455           begin6_(g6.begin()), end6_(g6.end()), current6_(current6)    {
12456       ComputeCurrentValue();
12457     }
12458     virtual ~Iterator() {}
12459 
12460     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
12461       return base_;
12462     }
12463     // Advance should not be called on beyond-of-range iterators
12464     // so no component iterators must be beyond end of range, either.
12465     virtual void Advance() {
12466       assert(!AtEnd());
12467       ++current6_;
12468       if (current6_ == end6_) {
12469         current6_ = begin6_;
12470         ++current5_;
12471       }
12472       if (current5_ == end5_) {
12473         current5_ = begin5_;
12474         ++current4_;
12475       }
12476       if (current4_ == end4_) {
12477         current4_ = begin4_;
12478         ++current3_;
12479       }
12480       if (current3_ == end3_) {
12481         current3_ = begin3_;
12482         ++current2_;
12483       }
12484       if (current2_ == end2_) {
12485         current2_ = begin2_;
12486         ++current1_;
12487       }
12488       ComputeCurrentValue();
12489     }
12490     virtual ParamIteratorInterface<ParamType>* Clone() const {
12491       return new Iterator(*this);
12492     }
12493     virtual const ParamType* Current() const { return &current_value_; }
12494     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12495       // Having the same base generator guarantees that the other
12496       // iterator is of the same type and we can downcast.
12497       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12498           << "The program attempted to compare iterators "
12499           << "from different generators." << std::endl;
12500       const Iterator* typed_other =
12501           CheckedDowncastToActualType<const Iterator>(&other);
12502       // We must report iterators equal if they both point beyond their
12503       // respective ranges. That can happen in a variety of fashions,
12504       // so we have to consult AtEnd().
12505       return (AtEnd() && typed_other->AtEnd()) ||
12506          (
12507           current1_ == typed_other->current1_ &&
12508           current2_ == typed_other->current2_ &&
12509           current3_ == typed_other->current3_ &&
12510           current4_ == typed_other->current4_ &&
12511           current5_ == typed_other->current5_ &&
12512           current6_ == typed_other->current6_);
12513     }
12514 
12515    private:
12516     Iterator(const Iterator& other)
12517         : base_(other.base_),
12518         begin1_(other.begin1_),
12519         end1_(other.end1_),
12520         current1_(other.current1_),
12521         begin2_(other.begin2_),
12522         end2_(other.end2_),
12523         current2_(other.current2_),
12524         begin3_(other.begin3_),
12525         end3_(other.end3_),
12526         current3_(other.current3_),
12527         begin4_(other.begin4_),
12528         end4_(other.end4_),
12529         current4_(other.current4_),
12530         begin5_(other.begin5_),
12531         end5_(other.end5_),
12532         current5_(other.current5_),
12533         begin6_(other.begin6_),
12534         end6_(other.end6_),
12535         current6_(other.current6_) {
12536       ComputeCurrentValue();
12537     }
12538 
12539     void ComputeCurrentValue() {
12540       if (!AtEnd())
12541         current_value_ = ParamType(*current1_, *current2_, *current3_,
12542             *current4_, *current5_, *current6_);
12543     }
12544     bool AtEnd() const {
12545       // We must report iterator past the end of the range when either of the
12546       // component iterators has reached the end of its range.
12547       return
12548           current1_ == end1_ ||
12549           current2_ == end2_ ||
12550           current3_ == end3_ ||
12551           current4_ == end4_ ||
12552           current5_ == end5_ ||
12553           current6_ == end6_;
12554     }
12555 
12556     // No implementation - assignment is unsupported.
12557     void operator=(const Iterator& other);
12558 
12559     const ParamGeneratorInterface<ParamType>* const base_;
12560     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12561     // current[i]_ is the actual traversing iterator.
12562     const typename ParamGenerator<T1>::iterator begin1_;
12563     const typename ParamGenerator<T1>::iterator end1_;
12564     typename ParamGenerator<T1>::iterator current1_;
12565     const typename ParamGenerator<T2>::iterator begin2_;
12566     const typename ParamGenerator<T2>::iterator end2_;
12567     typename ParamGenerator<T2>::iterator current2_;
12568     const typename ParamGenerator<T3>::iterator begin3_;
12569     const typename ParamGenerator<T3>::iterator end3_;
12570     typename ParamGenerator<T3>::iterator current3_;
12571     const typename ParamGenerator<T4>::iterator begin4_;
12572     const typename ParamGenerator<T4>::iterator end4_;
12573     typename ParamGenerator<T4>::iterator current4_;
12574     const typename ParamGenerator<T5>::iterator begin5_;
12575     const typename ParamGenerator<T5>::iterator end5_;
12576     typename ParamGenerator<T5>::iterator current5_;
12577     const typename ParamGenerator<T6>::iterator begin6_;
12578     const typename ParamGenerator<T6>::iterator end6_;
12579     typename ParamGenerator<T6>::iterator current6_;
12580     ParamType current_value_;
12581   };  // class CartesianProductGenerator6::Iterator
12582 
12583   // No implementation - assignment is unsupported.
12584   void operator=(const CartesianProductGenerator6& other);
12585 
12586   const ParamGenerator<T1> g1_;
12587   const ParamGenerator<T2> g2_;
12588   const ParamGenerator<T3> g3_;
12589   const ParamGenerator<T4> g4_;
12590   const ParamGenerator<T5> g5_;
12591   const ParamGenerator<T6> g6_;
12592 };  // class CartesianProductGenerator6
12593 
12594 
12595 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12596     typename T6, typename T7>
12597 class CartesianProductGenerator7
12598     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
12599         T7> > {
12600  public:
12601   typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
12602 
12603   CartesianProductGenerator7(const ParamGenerator<T1>& g1,
12604       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
12605       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
12606       const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)
12607       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
12608   virtual ~CartesianProductGenerator7() {}
12609 
12610   virtual ParamIteratorInterface<ParamType>* Begin() const {
12611     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
12612         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
12613         g7_.begin());
12614   }
12615   virtual ParamIteratorInterface<ParamType>* End() const {
12616     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
12617         g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());
12618   }
12619 
12620  private:
12621   class Iterator : public ParamIteratorInterface<ParamType> {
12622    public:
12623     Iterator(const ParamGeneratorInterface<ParamType>* base,
12624       const ParamGenerator<T1>& g1,
12625       const typename ParamGenerator<T1>::iterator& current1,
12626       const ParamGenerator<T2>& g2,
12627       const typename ParamGenerator<T2>::iterator& current2,
12628       const ParamGenerator<T3>& g3,
12629       const typename ParamGenerator<T3>::iterator& current3,
12630       const ParamGenerator<T4>& g4,
12631       const typename ParamGenerator<T4>::iterator& current4,
12632       const ParamGenerator<T5>& g5,
12633       const typename ParamGenerator<T5>::iterator& current5,
12634       const ParamGenerator<T6>& g6,
12635       const typename ParamGenerator<T6>::iterator& current6,
12636       const ParamGenerator<T7>& g7,
12637       const typename ParamGenerator<T7>::iterator& current7)
12638         : base_(base),
12639           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
12640           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
12641           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
12642           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
12643           begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
12644           begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
12645           begin7_(g7.begin()), end7_(g7.end()), current7_(current7)    {
12646       ComputeCurrentValue();
12647     }
12648     virtual ~Iterator() {}
12649 
12650     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
12651       return base_;
12652     }
12653     // Advance should not be called on beyond-of-range iterators
12654     // so no component iterators must be beyond end of range, either.
12655     virtual void Advance() {
12656       assert(!AtEnd());
12657       ++current7_;
12658       if (current7_ == end7_) {
12659         current7_ = begin7_;
12660         ++current6_;
12661       }
12662       if (current6_ == end6_) {
12663         current6_ = begin6_;
12664         ++current5_;
12665       }
12666       if (current5_ == end5_) {
12667         current5_ = begin5_;
12668         ++current4_;
12669       }
12670       if (current4_ == end4_) {
12671         current4_ = begin4_;
12672         ++current3_;
12673       }
12674       if (current3_ == end3_) {
12675         current3_ = begin3_;
12676         ++current2_;
12677       }
12678       if (current2_ == end2_) {
12679         current2_ = begin2_;
12680         ++current1_;
12681       }
12682       ComputeCurrentValue();
12683     }
12684     virtual ParamIteratorInterface<ParamType>* Clone() const {
12685       return new Iterator(*this);
12686     }
12687     virtual const ParamType* Current() const { return &current_value_; }
12688     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12689       // Having the same base generator guarantees that the other
12690       // iterator is of the same type and we can downcast.
12691       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12692           << "The program attempted to compare iterators "
12693           << "from different generators." << std::endl;
12694       const Iterator* typed_other =
12695           CheckedDowncastToActualType<const Iterator>(&other);
12696       // We must report iterators equal if they both point beyond their
12697       // respective ranges. That can happen in a variety of fashions,
12698       // so we have to consult AtEnd().
12699       return (AtEnd() && typed_other->AtEnd()) ||
12700          (
12701           current1_ == typed_other->current1_ &&
12702           current2_ == typed_other->current2_ &&
12703           current3_ == typed_other->current3_ &&
12704           current4_ == typed_other->current4_ &&
12705           current5_ == typed_other->current5_ &&
12706           current6_ == typed_other->current6_ &&
12707           current7_ == typed_other->current7_);
12708     }
12709 
12710    private:
12711     Iterator(const Iterator& other)
12712         : base_(other.base_),
12713         begin1_(other.begin1_),
12714         end1_(other.end1_),
12715         current1_(other.current1_),
12716         begin2_(other.begin2_),
12717         end2_(other.end2_),
12718         current2_(other.current2_),
12719         begin3_(other.begin3_),
12720         end3_(other.end3_),
12721         current3_(other.current3_),
12722         begin4_(other.begin4_),
12723         end4_(other.end4_),
12724         current4_(other.current4_),
12725         begin5_(other.begin5_),
12726         end5_(other.end5_),
12727         current5_(other.current5_),
12728         begin6_(other.begin6_),
12729         end6_(other.end6_),
12730         current6_(other.current6_),
12731         begin7_(other.begin7_),
12732         end7_(other.end7_),
12733         current7_(other.current7_) {
12734       ComputeCurrentValue();
12735     }
12736 
12737     void ComputeCurrentValue() {
12738       if (!AtEnd())
12739         current_value_ = ParamType(*current1_, *current2_, *current3_,
12740             *current4_, *current5_, *current6_, *current7_);
12741     }
12742     bool AtEnd() const {
12743       // We must report iterator past the end of the range when either of the
12744       // component iterators has reached the end of its range.
12745       return
12746           current1_ == end1_ ||
12747           current2_ == end2_ ||
12748           current3_ == end3_ ||
12749           current4_ == end4_ ||
12750           current5_ == end5_ ||
12751           current6_ == end6_ ||
12752           current7_ == end7_;
12753     }
12754 
12755     // No implementation - assignment is unsupported.
12756     void operator=(const Iterator& other);
12757 
12758     const ParamGeneratorInterface<ParamType>* const base_;
12759     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12760     // current[i]_ is the actual traversing iterator.
12761     const typename ParamGenerator<T1>::iterator begin1_;
12762     const typename ParamGenerator<T1>::iterator end1_;
12763     typename ParamGenerator<T1>::iterator current1_;
12764     const typename ParamGenerator<T2>::iterator begin2_;
12765     const typename ParamGenerator<T2>::iterator end2_;
12766     typename ParamGenerator<T2>::iterator current2_;
12767     const typename ParamGenerator<T3>::iterator begin3_;
12768     const typename ParamGenerator<T3>::iterator end3_;
12769     typename ParamGenerator<T3>::iterator current3_;
12770     const typename ParamGenerator<T4>::iterator begin4_;
12771     const typename ParamGenerator<T4>::iterator end4_;
12772     typename ParamGenerator<T4>::iterator current4_;
12773     const typename ParamGenerator<T5>::iterator begin5_;
12774     const typename ParamGenerator<T5>::iterator end5_;
12775     typename ParamGenerator<T5>::iterator current5_;
12776     const typename ParamGenerator<T6>::iterator begin6_;
12777     const typename ParamGenerator<T6>::iterator end6_;
12778     typename ParamGenerator<T6>::iterator current6_;
12779     const typename ParamGenerator<T7>::iterator begin7_;
12780     const typename ParamGenerator<T7>::iterator end7_;
12781     typename ParamGenerator<T7>::iterator current7_;
12782     ParamType current_value_;
12783   };  // class CartesianProductGenerator7::Iterator
12784 
12785   // No implementation - assignment is unsupported.
12786   void operator=(const CartesianProductGenerator7& other);
12787 
12788   const ParamGenerator<T1> g1_;
12789   const ParamGenerator<T2> g2_;
12790   const ParamGenerator<T3> g3_;
12791   const ParamGenerator<T4> g4_;
12792   const ParamGenerator<T5> g5_;
12793   const ParamGenerator<T6> g6_;
12794   const ParamGenerator<T7> g7_;
12795 };  // class CartesianProductGenerator7
12796 
12797 
12798 template <typename T1, typename T2, typename T3, typename T4, typename T5,
12799     typename T6, typename T7, typename T8>
12800 class CartesianProductGenerator8
12801     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
12802         T7, T8> > {
12803  public:
12804   typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
12805 
12806   CartesianProductGenerator8(const ParamGenerator<T1>& g1,
12807       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
12808       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
12809       const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
12810       const ParamGenerator<T8>& g8)
12811       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
12812           g8_(g8) {}
12813   virtual ~CartesianProductGenerator8() {}
12814 
12815   virtual ParamIteratorInterface<ParamType>* Begin() const {
12816     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
12817         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
12818         g7_.begin(), g8_, g8_.begin());
12819   }
12820   virtual ParamIteratorInterface<ParamType>* End() const {
12821     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
12822         g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
12823         g8_.end());
12824   }
12825 
12826  private:
12827   class Iterator : public ParamIteratorInterface<ParamType> {
12828    public:
12829     Iterator(const ParamGeneratorInterface<ParamType>* base,
12830       const ParamGenerator<T1>& g1,
12831       const typename ParamGenerator<T1>::iterator& current1,
12832       const ParamGenerator<T2>& g2,
12833       const typename ParamGenerator<T2>::iterator& current2,
12834       const ParamGenerator<T3>& g3,
12835       const typename ParamGenerator<T3>::iterator& current3,
12836       const ParamGenerator<T4>& g4,
12837       const typename ParamGenerator<T4>::iterator& current4,
12838       const ParamGenerator<T5>& g5,
12839       const typename ParamGenerator<T5>::iterator& current5,
12840       const ParamGenerator<T6>& g6,
12841       const typename ParamGenerator<T6>::iterator& current6,
12842       const ParamGenerator<T7>& g7,
12843       const typename ParamGenerator<T7>::iterator& current7,
12844       const ParamGenerator<T8>& g8,
12845       const typename ParamGenerator<T8>::iterator& current8)
12846         : base_(base),
12847           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
12848           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
12849           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
12850           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
12851           begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
12852           begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
12853           begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
12854           begin8_(g8.begin()), end8_(g8.end()), current8_(current8)    {
12855       ComputeCurrentValue();
12856     }
12857     virtual ~Iterator() {}
12858 
12859     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
12860       return base_;
12861     }
12862     // Advance should not be called on beyond-of-range iterators
12863     // so no component iterators must be beyond end of range, either.
12864     virtual void Advance() {
12865       assert(!AtEnd());
12866       ++current8_;
12867       if (current8_ == end8_) {
12868         current8_ = begin8_;
12869         ++current7_;
12870       }
12871       if (current7_ == end7_) {
12872         current7_ = begin7_;
12873         ++current6_;
12874       }
12875       if (current6_ == end6_) {
12876         current6_ = begin6_;
12877         ++current5_;
12878       }
12879       if (current5_ == end5_) {
12880         current5_ = begin5_;
12881         ++current4_;
12882       }
12883       if (current4_ == end4_) {
12884         current4_ = begin4_;
12885         ++current3_;
12886       }
12887       if (current3_ == end3_) {
12888         current3_ = begin3_;
12889         ++current2_;
12890       }
12891       if (current2_ == end2_) {
12892         current2_ = begin2_;
12893         ++current1_;
12894       }
12895       ComputeCurrentValue();
12896     }
12897     virtual ParamIteratorInterface<ParamType>* Clone() const {
12898       return new Iterator(*this);
12899     }
12900     virtual const ParamType* Current() const { return &current_value_; }
12901     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
12902       // Having the same base generator guarantees that the other
12903       // iterator is of the same type and we can downcast.
12904       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
12905           << "The program attempted to compare iterators "
12906           << "from different generators." << std::endl;
12907       const Iterator* typed_other =
12908           CheckedDowncastToActualType<const Iterator>(&other);
12909       // We must report iterators equal if they both point beyond their
12910       // respective ranges. That can happen in a variety of fashions,
12911       // so we have to consult AtEnd().
12912       return (AtEnd() && typed_other->AtEnd()) ||
12913          (
12914           current1_ == typed_other->current1_ &&
12915           current2_ == typed_other->current2_ &&
12916           current3_ == typed_other->current3_ &&
12917           current4_ == typed_other->current4_ &&
12918           current5_ == typed_other->current5_ &&
12919           current6_ == typed_other->current6_ &&
12920           current7_ == typed_other->current7_ &&
12921           current8_ == typed_other->current8_);
12922     }
12923 
12924    private:
12925     Iterator(const Iterator& other)
12926         : base_(other.base_),
12927         begin1_(other.begin1_),
12928         end1_(other.end1_),
12929         current1_(other.current1_),
12930         begin2_(other.begin2_),
12931         end2_(other.end2_),
12932         current2_(other.current2_),
12933         begin3_(other.begin3_),
12934         end3_(other.end3_),
12935         current3_(other.current3_),
12936         begin4_(other.begin4_),
12937         end4_(other.end4_),
12938         current4_(other.current4_),
12939         begin5_(other.begin5_),
12940         end5_(other.end5_),
12941         current5_(other.current5_),
12942         begin6_(other.begin6_),
12943         end6_(other.end6_),
12944         current6_(other.current6_),
12945         begin7_(other.begin7_),
12946         end7_(other.end7_),
12947         current7_(other.current7_),
12948         begin8_(other.begin8_),
12949         end8_(other.end8_),
12950         current8_(other.current8_) {
12951       ComputeCurrentValue();
12952     }
12953 
12954     void ComputeCurrentValue() {
12955       if (!AtEnd())
12956         current_value_ = ParamType(*current1_, *current2_, *current3_,
12957             *current4_, *current5_, *current6_, *current7_, *current8_);
12958     }
12959     bool AtEnd() const {
12960       // We must report iterator past the end of the range when either of the
12961       // component iterators has reached the end of its range.
12962       return
12963           current1_ == end1_ ||
12964           current2_ == end2_ ||
12965           current3_ == end3_ ||
12966           current4_ == end4_ ||
12967           current5_ == end5_ ||
12968           current6_ == end6_ ||
12969           current7_ == end7_ ||
12970           current8_ == end8_;
12971     }
12972 
12973     // No implementation - assignment is unsupported.
12974     void operator=(const Iterator& other);
12975 
12976     const ParamGeneratorInterface<ParamType>* const base_;
12977     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
12978     // current[i]_ is the actual traversing iterator.
12979     const typename ParamGenerator<T1>::iterator begin1_;
12980     const typename ParamGenerator<T1>::iterator end1_;
12981     typename ParamGenerator<T1>::iterator current1_;
12982     const typename ParamGenerator<T2>::iterator begin2_;
12983     const typename ParamGenerator<T2>::iterator end2_;
12984     typename ParamGenerator<T2>::iterator current2_;
12985     const typename ParamGenerator<T3>::iterator begin3_;
12986     const typename ParamGenerator<T3>::iterator end3_;
12987     typename ParamGenerator<T3>::iterator current3_;
12988     const typename ParamGenerator<T4>::iterator begin4_;
12989     const typename ParamGenerator<T4>::iterator end4_;
12990     typename ParamGenerator<T4>::iterator current4_;
12991     const typename ParamGenerator<T5>::iterator begin5_;
12992     const typename ParamGenerator<T5>::iterator end5_;
12993     typename ParamGenerator<T5>::iterator current5_;
12994     const typename ParamGenerator<T6>::iterator begin6_;
12995     const typename ParamGenerator<T6>::iterator end6_;
12996     typename ParamGenerator<T6>::iterator current6_;
12997     const typename ParamGenerator<T7>::iterator begin7_;
12998     const typename ParamGenerator<T7>::iterator end7_;
12999     typename ParamGenerator<T7>::iterator current7_;
13000     const typename ParamGenerator<T8>::iterator begin8_;
13001     const typename ParamGenerator<T8>::iterator end8_;
13002     typename ParamGenerator<T8>::iterator current8_;
13003     ParamType current_value_;
13004   };  // class CartesianProductGenerator8::Iterator
13005 
13006   // No implementation - assignment is unsupported.
13007   void operator=(const CartesianProductGenerator8& other);
13008 
13009   const ParamGenerator<T1> g1_;
13010   const ParamGenerator<T2> g2_;
13011   const ParamGenerator<T3> g3_;
13012   const ParamGenerator<T4> g4_;
13013   const ParamGenerator<T5> g5_;
13014   const ParamGenerator<T6> g6_;
13015   const ParamGenerator<T7> g7_;
13016   const ParamGenerator<T8> g8_;
13017 };  // class CartesianProductGenerator8
13018 
13019 
13020 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13021     typename T6, typename T7, typename T8, typename T9>
13022 class CartesianProductGenerator9
13023     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
13024         T7, T8, T9> > {
13025  public:
13026   typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
13027 
13028   CartesianProductGenerator9(const ParamGenerator<T1>& g1,
13029       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
13030       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
13031       const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
13032       const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)
13033       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
13034           g9_(g9) {}
13035   virtual ~CartesianProductGenerator9() {}
13036 
13037   virtual ParamIteratorInterface<ParamType>* Begin() const {
13038     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
13039         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
13040         g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());
13041   }
13042   virtual ParamIteratorInterface<ParamType>* End() const {
13043     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
13044         g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
13045         g8_.end(), g9_, g9_.end());
13046   }
13047 
13048  private:
13049   class Iterator : public ParamIteratorInterface<ParamType> {
13050    public:
13051     Iterator(const ParamGeneratorInterface<ParamType>* base,
13052       const ParamGenerator<T1>& g1,
13053       const typename ParamGenerator<T1>::iterator& current1,
13054       const ParamGenerator<T2>& g2,
13055       const typename ParamGenerator<T2>::iterator& current2,
13056       const ParamGenerator<T3>& g3,
13057       const typename ParamGenerator<T3>::iterator& current3,
13058       const ParamGenerator<T4>& g4,
13059       const typename ParamGenerator<T4>::iterator& current4,
13060       const ParamGenerator<T5>& g5,
13061       const typename ParamGenerator<T5>::iterator& current5,
13062       const ParamGenerator<T6>& g6,
13063       const typename ParamGenerator<T6>::iterator& current6,
13064       const ParamGenerator<T7>& g7,
13065       const typename ParamGenerator<T7>::iterator& current7,
13066       const ParamGenerator<T8>& g8,
13067       const typename ParamGenerator<T8>::iterator& current8,
13068       const ParamGenerator<T9>& g9,
13069       const typename ParamGenerator<T9>::iterator& current9)
13070         : base_(base),
13071           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
13072           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
13073           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
13074           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
13075           begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
13076           begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
13077           begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
13078           begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
13079           begin9_(g9.begin()), end9_(g9.end()), current9_(current9)    {
13080       ComputeCurrentValue();
13081     }
13082     virtual ~Iterator() {}
13083 
13084     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
13085       return base_;
13086     }
13087     // Advance should not be called on beyond-of-range iterators
13088     // so no component iterators must be beyond end of range, either.
13089     virtual void Advance() {
13090       assert(!AtEnd());
13091       ++current9_;
13092       if (current9_ == end9_) {
13093         current9_ = begin9_;
13094         ++current8_;
13095       }
13096       if (current8_ == end8_) {
13097         current8_ = begin8_;
13098         ++current7_;
13099       }
13100       if (current7_ == end7_) {
13101         current7_ = begin7_;
13102         ++current6_;
13103       }
13104       if (current6_ == end6_) {
13105         current6_ = begin6_;
13106         ++current5_;
13107       }
13108       if (current5_ == end5_) {
13109         current5_ = begin5_;
13110         ++current4_;
13111       }
13112       if (current4_ == end4_) {
13113         current4_ = begin4_;
13114         ++current3_;
13115       }
13116       if (current3_ == end3_) {
13117         current3_ = begin3_;
13118         ++current2_;
13119       }
13120       if (current2_ == end2_) {
13121         current2_ = begin2_;
13122         ++current1_;
13123       }
13124       ComputeCurrentValue();
13125     }
13126     virtual ParamIteratorInterface<ParamType>* Clone() const {
13127       return new Iterator(*this);
13128     }
13129     virtual const ParamType* Current() const { return &current_value_; }
13130     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
13131       // Having the same base generator guarantees that the other
13132       // iterator is of the same type and we can downcast.
13133       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
13134           << "The program attempted to compare iterators "
13135           << "from different generators." << std::endl;
13136       const Iterator* typed_other =
13137           CheckedDowncastToActualType<const Iterator>(&other);
13138       // We must report iterators equal if they both point beyond their
13139       // respective ranges. That can happen in a variety of fashions,
13140       // so we have to consult AtEnd().
13141       return (AtEnd() && typed_other->AtEnd()) ||
13142          (
13143           current1_ == typed_other->current1_ &&
13144           current2_ == typed_other->current2_ &&
13145           current3_ == typed_other->current3_ &&
13146           current4_ == typed_other->current4_ &&
13147           current5_ == typed_other->current5_ &&
13148           current6_ == typed_other->current6_ &&
13149           current7_ == typed_other->current7_ &&
13150           current8_ == typed_other->current8_ &&
13151           current9_ == typed_other->current9_);
13152     }
13153 
13154    private:
13155     Iterator(const Iterator& other)
13156         : base_(other.base_),
13157         begin1_(other.begin1_),
13158         end1_(other.end1_),
13159         current1_(other.current1_),
13160         begin2_(other.begin2_),
13161         end2_(other.end2_),
13162         current2_(other.current2_),
13163         begin3_(other.begin3_),
13164         end3_(other.end3_),
13165         current3_(other.current3_),
13166         begin4_(other.begin4_),
13167         end4_(other.end4_),
13168         current4_(other.current4_),
13169         begin5_(other.begin5_),
13170         end5_(other.end5_),
13171         current5_(other.current5_),
13172         begin6_(other.begin6_),
13173         end6_(other.end6_),
13174         current6_(other.current6_),
13175         begin7_(other.begin7_),
13176         end7_(other.end7_),
13177         current7_(other.current7_),
13178         begin8_(other.begin8_),
13179         end8_(other.end8_),
13180         current8_(other.current8_),
13181         begin9_(other.begin9_),
13182         end9_(other.end9_),
13183         current9_(other.current9_) {
13184       ComputeCurrentValue();
13185     }
13186 
13187     void ComputeCurrentValue() {
13188       if (!AtEnd())
13189         current_value_ = ParamType(*current1_, *current2_, *current3_,
13190             *current4_, *current5_, *current6_, *current7_, *current8_,
13191             *current9_);
13192     }
13193     bool AtEnd() const {
13194       // We must report iterator past the end of the range when either of the
13195       // component iterators has reached the end of its range.
13196       return
13197           current1_ == end1_ ||
13198           current2_ == end2_ ||
13199           current3_ == end3_ ||
13200           current4_ == end4_ ||
13201           current5_ == end5_ ||
13202           current6_ == end6_ ||
13203           current7_ == end7_ ||
13204           current8_ == end8_ ||
13205           current9_ == end9_;
13206     }
13207 
13208     // No implementation - assignment is unsupported.
13209     void operator=(const Iterator& other);
13210 
13211     const ParamGeneratorInterface<ParamType>* const base_;
13212     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
13213     // current[i]_ is the actual traversing iterator.
13214     const typename ParamGenerator<T1>::iterator begin1_;
13215     const typename ParamGenerator<T1>::iterator end1_;
13216     typename ParamGenerator<T1>::iterator current1_;
13217     const typename ParamGenerator<T2>::iterator begin2_;
13218     const typename ParamGenerator<T2>::iterator end2_;
13219     typename ParamGenerator<T2>::iterator current2_;
13220     const typename ParamGenerator<T3>::iterator begin3_;
13221     const typename ParamGenerator<T3>::iterator end3_;
13222     typename ParamGenerator<T3>::iterator current3_;
13223     const typename ParamGenerator<T4>::iterator begin4_;
13224     const typename ParamGenerator<T4>::iterator end4_;
13225     typename ParamGenerator<T4>::iterator current4_;
13226     const typename ParamGenerator<T5>::iterator begin5_;
13227     const typename ParamGenerator<T5>::iterator end5_;
13228     typename ParamGenerator<T5>::iterator current5_;
13229     const typename ParamGenerator<T6>::iterator begin6_;
13230     const typename ParamGenerator<T6>::iterator end6_;
13231     typename ParamGenerator<T6>::iterator current6_;
13232     const typename ParamGenerator<T7>::iterator begin7_;
13233     const typename ParamGenerator<T7>::iterator end7_;
13234     typename ParamGenerator<T7>::iterator current7_;
13235     const typename ParamGenerator<T8>::iterator begin8_;
13236     const typename ParamGenerator<T8>::iterator end8_;
13237     typename ParamGenerator<T8>::iterator current8_;
13238     const typename ParamGenerator<T9>::iterator begin9_;
13239     const typename ParamGenerator<T9>::iterator end9_;
13240     typename ParamGenerator<T9>::iterator current9_;
13241     ParamType current_value_;
13242   };  // class CartesianProductGenerator9::Iterator
13243 
13244   // No implementation - assignment is unsupported.
13245   void operator=(const CartesianProductGenerator9& other);
13246 
13247   const ParamGenerator<T1> g1_;
13248   const ParamGenerator<T2> g2_;
13249   const ParamGenerator<T3> g3_;
13250   const ParamGenerator<T4> g4_;
13251   const ParamGenerator<T5> g5_;
13252   const ParamGenerator<T6> g6_;
13253   const ParamGenerator<T7> g7_;
13254   const ParamGenerator<T8> g8_;
13255   const ParamGenerator<T9> g9_;
13256 };  // class CartesianProductGenerator9
13257 
13258 
13259 template <typename T1, typename T2, typename T3, typename T4, typename T5,
13260     typename T6, typename T7, typename T8, typename T9, typename T10>
13261 class CartesianProductGenerator10
13262     : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
13263         T7, T8, T9, T10> > {
13264  public:
13265   typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
13266 
13267   CartesianProductGenerator10(const ParamGenerator<T1>& g1,
13268       const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
13269       const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
13270       const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
13271       const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,
13272       const ParamGenerator<T10>& g10)
13273       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
13274           g9_(g9), g10_(g10) {}
13275   virtual ~CartesianProductGenerator10() {}
13276 
13277   virtual ParamIteratorInterface<ParamType>* Begin() const {
13278     return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
13279         g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
13280         g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());
13281   }
13282   virtual ParamIteratorInterface<ParamType>* End() const {
13283     return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
13284         g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
13285         g8_.end(), g9_, g9_.end(), g10_, g10_.end());
13286   }
13287 
13288  private:
13289   class Iterator : public ParamIteratorInterface<ParamType> {
13290    public:
13291     Iterator(const ParamGeneratorInterface<ParamType>* base,
13292       const ParamGenerator<T1>& g1,
13293       const typename ParamGenerator<T1>::iterator& current1,
13294       const ParamGenerator<T2>& g2,
13295       const typename ParamGenerator<T2>::iterator& current2,
13296       const ParamGenerator<T3>& g3,
13297       const typename ParamGenerator<T3>::iterator& current3,
13298       const ParamGenerator<T4>& g4,
13299       const typename ParamGenerator<T4>::iterator& current4,
13300       const ParamGenerator<T5>& g5,
13301       const typename ParamGenerator<T5>::iterator& current5,
13302       const ParamGenerator<T6>& g6,
13303       const typename ParamGenerator<T6>::iterator& current6,
13304       const ParamGenerator<T7>& g7,
13305       const typename ParamGenerator<T7>::iterator& current7,
13306       const ParamGenerator<T8>& g8,
13307       const typename ParamGenerator<T8>::iterator& current8,
13308       const ParamGenerator<T9>& g9,
13309       const typename ParamGenerator<T9>::iterator& current9,
13310       const ParamGenerator<T10>& g10,
13311       const typename ParamGenerator<T10>::iterator& current10)
13312         : base_(base),
13313           begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
13314           begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
13315           begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
13316           begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
13317           begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
13318           begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
13319           begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
13320           begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
13321           begin9_(g9.begin()), end9_(g9.end()), current9_(current9),
13322           begin10_(g10.begin()), end10_(g10.end()), current10_(current10)    {
13323       ComputeCurrentValue();
13324     }
13325     virtual ~Iterator() {}
13326 
13327     virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
13328       return base_;
13329     }
13330     // Advance should not be called on beyond-of-range iterators
13331     // so no component iterators must be beyond end of range, either.
13332     virtual void Advance() {
13333       assert(!AtEnd());
13334       ++current10_;
13335       if (current10_ == end10_) {
13336         current10_ = begin10_;
13337         ++current9_;
13338       }
13339       if (current9_ == end9_) {
13340         current9_ = begin9_;
13341         ++current8_;
13342       }
13343       if (current8_ == end8_) {
13344         current8_ = begin8_;
13345         ++current7_;
13346       }
13347       if (current7_ == end7_) {
13348         current7_ = begin7_;
13349         ++current6_;
13350       }
13351       if (current6_ == end6_) {
13352         current6_ = begin6_;
13353         ++current5_;
13354       }
13355       if (current5_ == end5_) {
13356         current5_ = begin5_;
13357         ++current4_;
13358       }
13359       if (current4_ == end4_) {
13360         current4_ = begin4_;
13361         ++current3_;
13362       }
13363       if (current3_ == end3_) {
13364         current3_ = begin3_;
13365         ++current2_;
13366       }
13367       if (current2_ == end2_) {
13368         current2_ = begin2_;
13369         ++current1_;
13370       }
13371       ComputeCurrentValue();
13372     }
13373     virtual ParamIteratorInterface<ParamType>* Clone() const {
13374       return new Iterator(*this);
13375     }
13376     virtual const ParamType* Current() const { return &current_value_; }
13377     virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
13378       // Having the same base generator guarantees that the other
13379       // iterator is of the same type and we can downcast.
13380       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
13381           << "The program attempted to compare iterators "
13382           << "from different generators." << std::endl;
13383       const Iterator* typed_other =
13384           CheckedDowncastToActualType<const Iterator>(&other);
13385       // We must report iterators equal if they both point beyond their
13386       // respective ranges. That can happen in a variety of fashions,
13387       // so we have to consult AtEnd().
13388       return (AtEnd() && typed_other->AtEnd()) ||
13389          (
13390           current1_ == typed_other->current1_ &&
13391           current2_ == typed_other->current2_ &&
13392           current3_ == typed_other->current3_ &&
13393           current4_ == typed_other->current4_ &&
13394           current5_ == typed_other->current5_ &&
13395           current6_ == typed_other->current6_ &&
13396           current7_ == typed_other->current7_ &&
13397           current8_ == typed_other->current8_ &&
13398           current9_ == typed_other->current9_ &&
13399           current10_ == typed_other->current10_);
13400     }
13401 
13402    private:
13403     Iterator(const Iterator& other)
13404         : base_(other.base_),
13405         begin1_(other.begin1_),
13406         end1_(other.end1_),
13407         current1_(other.current1_),
13408         begin2_(other.begin2_),
13409         end2_(other.end2_),
13410         current2_(other.current2_),
13411         begin3_(other.begin3_),
13412         end3_(other.end3_),
13413         current3_(other.current3_),
13414         begin4_(other.begin4_),
13415         end4_(other.end4_),
13416         current4_(other.current4_),
13417         begin5_(other.begin5_),
13418         end5_(other.end5_),
13419         current5_(other.current5_),
13420         begin6_(other.begin6_),
13421         end6_(other.end6_),
13422         current6_(other.current6_),
13423         begin7_(other.begin7_),
13424         end7_(other.end7_),
13425         current7_(other.current7_),
13426         begin8_(other.begin8_),
13427         end8_(other.end8_),
13428         current8_(other.current8_),
13429         begin9_(other.begin9_),
13430         end9_(other.end9_),
13431         current9_(other.current9_),
13432         begin10_(other.begin10_),
13433         end10_(other.end10_),
13434         current10_(other.current10_) {
13435       ComputeCurrentValue();
13436     }
13437 
13438     void ComputeCurrentValue() {
13439       if (!AtEnd())
13440         current_value_ = ParamType(*current1_, *current2_, *current3_,
13441             *current4_, *current5_, *current6_, *current7_, *current8_,
13442             *current9_, *current10_);
13443     }
13444     bool AtEnd() const {
13445       // We must report iterator past the end of the range when either of the
13446       // component iterators has reached the end of its range.
13447       return
13448           current1_ == end1_ ||
13449           current2_ == end2_ ||
13450           current3_ == end3_ ||
13451           current4_ == end4_ ||
13452           current5_ == end5_ ||
13453           current6_ == end6_ ||
13454           current7_ == end7_ ||
13455           current8_ == end8_ ||
13456           current9_ == end9_ ||
13457           current10_ == end10_;
13458     }
13459 
13460     // No implementation - assignment is unsupported.
13461     void operator=(const Iterator& other);
13462 
13463     const ParamGeneratorInterface<ParamType>* const base_;
13464     // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
13465     // current[i]_ is the actual traversing iterator.
13466     const typename ParamGenerator<T1>::iterator begin1_;
13467     const typename ParamGenerator<T1>::iterator end1_;
13468     typename ParamGenerator<T1>::iterator current1_;
13469     const typename ParamGenerator<T2>::iterator begin2_;
13470     const typename ParamGenerator<T2>::iterator end2_;
13471     typename ParamGenerator<T2>::iterator current2_;
13472     const typename ParamGenerator<T3>::iterator begin3_;
13473     const typename ParamGenerator<T3>::iterator end3_;
13474     typename ParamGenerator<T3>::iterator current3_;
13475     const typename ParamGenerator<T4>::iterator begin4_;
13476     const typename ParamGenerator<T4>::iterator end4_;
13477     typename ParamGenerator<T4>::iterator current4_;
13478     const typename ParamGenerator<T5>::iterator begin5_;
13479     const typename ParamGenerator<T5>::iterator end5_;
13480     typename ParamGenerator<T5>::iterator current5_;
13481     const typename ParamGenerator<T6>::iterator begin6_;
13482     const typename ParamGenerator<T6>::iterator end6_;
13483     typename ParamGenerator<T6>::iterator current6_;
13484     const typename ParamGenerator<T7>::iterator begin7_;
13485     const typename ParamGenerator<T7>::iterator end7_;
13486     typename ParamGenerator<T7>::iterator current7_;
13487     const typename ParamGenerator<T8>::iterator begin8_;
13488     const typename ParamGenerator<T8>::iterator end8_;
13489     typename ParamGenerator<T8>::iterator current8_;
13490     const typename ParamGenerator<T9>::iterator begin9_;
13491     const typename ParamGenerator<T9>::iterator end9_;
13492     typename ParamGenerator<T9>::iterator current9_;
13493     const typename ParamGenerator<T10>::iterator begin10_;
13494     const typename ParamGenerator<T10>::iterator end10_;
13495     typename ParamGenerator<T10>::iterator current10_;
13496     ParamType current_value_;
13497   };  // class CartesianProductGenerator10::Iterator
13498 
13499   // No implementation - assignment is unsupported.
13500   void operator=(const CartesianProductGenerator10& other);
13501 
13502   const ParamGenerator<T1> g1_;
13503   const ParamGenerator<T2> g2_;
13504   const ParamGenerator<T3> g3_;
13505   const ParamGenerator<T4> g4_;
13506   const ParamGenerator<T5> g5_;
13507   const ParamGenerator<T6> g6_;
13508   const ParamGenerator<T7> g7_;
13509   const ParamGenerator<T8> g8_;
13510   const ParamGenerator<T9> g9_;
13511   const ParamGenerator<T10> g10_;
13512 };  // class CartesianProductGenerator10
13513 
13514 
13515 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
13516 //
13517 // Helper classes providing Combine() with polymorphic features. They allow
13518 // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
13519 // convertible to U.
13520 //
13521 template <class Generator1, class Generator2>
13522 class CartesianProductHolder2 {
13523  public:
13524 CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
13525       : g1_(g1), g2_(g2) {}
13526   template <typename T1, typename T2>
13527   operator ParamGenerator< ::testing::tuple<T1, T2> >() const {
13528     return ParamGenerator< ::testing::tuple<T1, T2> >(
13529         new CartesianProductGenerator2<T1, T2>(
13530         static_cast<ParamGenerator<T1> >(g1_),
13531         static_cast<ParamGenerator<T2> >(g2_)));
13532   }
13533 
13534  private:
13535   // No implementation - assignment is unsupported.
13536   void operator=(const CartesianProductHolder2& other);
13537 
13538   const Generator1 g1_;
13539   const Generator2 g2_;
13540 };  // class CartesianProductHolder2
13541 
13542 template <class Generator1, class Generator2, class Generator3>
13543 class CartesianProductHolder3 {
13544  public:
13545 CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
13546     const Generator3& g3)
13547       : g1_(g1), g2_(g2), g3_(g3) {}
13548   template <typename T1, typename T2, typename T3>
13549   operator ParamGenerator< ::testing::tuple<T1, T2, T3> >() const {
13550     return ParamGenerator< ::testing::tuple<T1, T2, T3> >(
13551         new CartesianProductGenerator3<T1, T2, T3>(
13552         static_cast<ParamGenerator<T1> >(g1_),
13553         static_cast<ParamGenerator<T2> >(g2_),
13554         static_cast<ParamGenerator<T3> >(g3_)));
13555   }
13556 
13557  private:
13558   // No implementation - assignment is unsupported.
13559   void operator=(const CartesianProductHolder3& other);
13560 
13561   const Generator1 g1_;
13562   const Generator2 g2_;
13563   const Generator3 g3_;
13564 };  // class CartesianProductHolder3
13565 
13566 template <class Generator1, class Generator2, class Generator3,
13567     class Generator4>
13568 class CartesianProductHolder4 {
13569  public:
13570 CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
13571     const Generator3& g3, const Generator4& g4)
13572       : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
13573   template <typename T1, typename T2, typename T3, typename T4>
13574   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >() const {
13575     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >(
13576         new CartesianProductGenerator4<T1, T2, T3, T4>(
13577         static_cast<ParamGenerator<T1> >(g1_),
13578         static_cast<ParamGenerator<T2> >(g2_),
13579         static_cast<ParamGenerator<T3> >(g3_),
13580         static_cast<ParamGenerator<T4> >(g4_)));
13581   }
13582 
13583  private:
13584   // No implementation - assignment is unsupported.
13585   void operator=(const CartesianProductHolder4& other);
13586 
13587   const Generator1 g1_;
13588   const Generator2 g2_;
13589   const Generator3 g3_;
13590   const Generator4 g4_;
13591 };  // class CartesianProductHolder4
13592 
13593 template <class Generator1, class Generator2, class Generator3,
13594     class Generator4, class Generator5>
13595 class CartesianProductHolder5 {
13596  public:
13597 CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
13598     const Generator3& g3, const Generator4& g4, const Generator5& g5)
13599       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
13600   template <typename T1, typename T2, typename T3, typename T4, typename T5>
13601   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >() const {
13602     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >(
13603         new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
13604         static_cast<ParamGenerator<T1> >(g1_),
13605         static_cast<ParamGenerator<T2> >(g2_),
13606         static_cast<ParamGenerator<T3> >(g3_),
13607         static_cast<ParamGenerator<T4> >(g4_),
13608         static_cast<ParamGenerator<T5> >(g5_)));
13609   }
13610 
13611  private:
13612   // No implementation - assignment is unsupported.
13613   void operator=(const CartesianProductHolder5& other);
13614 
13615   const Generator1 g1_;
13616   const Generator2 g2_;
13617   const Generator3 g3_;
13618   const Generator4 g4_;
13619   const Generator5 g5_;
13620 };  // class CartesianProductHolder5
13621 
13622 template <class Generator1, class Generator2, class Generator3,
13623     class Generator4, class Generator5, class Generator6>
13624 class CartesianProductHolder6 {
13625  public:
13626 CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
13627     const Generator3& g3, const Generator4& g4, const Generator5& g5,
13628     const Generator6& g6)
13629       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
13630   template <typename T1, typename T2, typename T3, typename T4, typename T5,
13631       typename T6>
13632   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >() const {
13633     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >(
13634         new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
13635         static_cast<ParamGenerator<T1> >(g1_),
13636         static_cast<ParamGenerator<T2> >(g2_),
13637         static_cast<ParamGenerator<T3> >(g3_),
13638         static_cast<ParamGenerator<T4> >(g4_),
13639         static_cast<ParamGenerator<T5> >(g5_),
13640         static_cast<ParamGenerator<T6> >(g6_)));
13641   }
13642 
13643  private:
13644   // No implementation - assignment is unsupported.
13645   void operator=(const CartesianProductHolder6& other);
13646 
13647   const Generator1 g1_;
13648   const Generator2 g2_;
13649   const Generator3 g3_;
13650   const Generator4 g4_;
13651   const Generator5 g5_;
13652   const Generator6 g6_;
13653 };  // class CartesianProductHolder6
13654 
13655 template <class Generator1, class Generator2, class Generator3,
13656     class Generator4, class Generator5, class Generator6, class Generator7>
13657 class CartesianProductHolder7 {
13658  public:
13659 CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
13660     const Generator3& g3, const Generator4& g4, const Generator5& g5,
13661     const Generator6& g6, const Generator7& g7)
13662       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
13663   template <typename T1, typename T2, typename T3, typename T4, typename T5,
13664       typename T6, typename T7>
13665   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6,
13666       T7> >() const {
13667     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> >(
13668         new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(
13669         static_cast<ParamGenerator<T1> >(g1_),
13670         static_cast<ParamGenerator<T2> >(g2_),
13671         static_cast<ParamGenerator<T3> >(g3_),
13672         static_cast<ParamGenerator<T4> >(g4_),
13673         static_cast<ParamGenerator<T5> >(g5_),
13674         static_cast<ParamGenerator<T6> >(g6_),
13675         static_cast<ParamGenerator<T7> >(g7_)));
13676   }
13677 
13678  private:
13679   // No implementation - assignment is unsupported.
13680   void operator=(const CartesianProductHolder7& other);
13681 
13682   const Generator1 g1_;
13683   const Generator2 g2_;
13684   const Generator3 g3_;
13685   const Generator4 g4_;
13686   const Generator5 g5_;
13687   const Generator6 g6_;
13688   const Generator7 g7_;
13689 };  // class CartesianProductHolder7
13690 
13691 template <class Generator1, class Generator2, class Generator3,
13692     class Generator4, class Generator5, class Generator6, class Generator7,
13693     class Generator8>
13694 class CartesianProductHolder8 {
13695  public:
13696 CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
13697     const Generator3& g3, const Generator4& g4, const Generator5& g5,
13698     const Generator6& g6, const Generator7& g7, const Generator8& g8)
13699       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
13700           g8_(g8) {}
13701   template <typename T1, typename T2, typename T3, typename T4, typename T5,
13702       typename T6, typename T7, typename T8>
13703   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7,
13704       T8> >() const {
13705     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
13706         new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(
13707         static_cast<ParamGenerator<T1> >(g1_),
13708         static_cast<ParamGenerator<T2> >(g2_),
13709         static_cast<ParamGenerator<T3> >(g3_),
13710         static_cast<ParamGenerator<T4> >(g4_),
13711         static_cast<ParamGenerator<T5> >(g5_),
13712         static_cast<ParamGenerator<T6> >(g6_),
13713         static_cast<ParamGenerator<T7> >(g7_),
13714         static_cast<ParamGenerator<T8> >(g8_)));
13715   }
13716 
13717  private:
13718   // No implementation - assignment is unsupported.
13719   void operator=(const CartesianProductHolder8& other);
13720 
13721   const Generator1 g1_;
13722   const Generator2 g2_;
13723   const Generator3 g3_;
13724   const Generator4 g4_;
13725   const Generator5 g5_;
13726   const Generator6 g6_;
13727   const Generator7 g7_;
13728   const Generator8 g8_;
13729 };  // class CartesianProductHolder8
13730 
13731 template <class Generator1, class Generator2, class Generator3,
13732     class Generator4, class Generator5, class Generator6, class Generator7,
13733     class Generator8, class Generator9>
13734 class CartesianProductHolder9 {
13735  public:
13736 CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
13737     const Generator3& g3, const Generator4& g4, const Generator5& g5,
13738     const Generator6& g6, const Generator7& g7, const Generator8& g8,
13739     const Generator9& g9)
13740       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
13741           g9_(g9) {}
13742   template <typename T1, typename T2, typename T3, typename T4, typename T5,
13743       typename T6, typename T7, typename T8, typename T9>
13744   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
13745       T9> >() const {
13746     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
13747         T9> >(
13748         new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
13749         static_cast<ParamGenerator<T1> >(g1_),
13750         static_cast<ParamGenerator<T2> >(g2_),
13751         static_cast<ParamGenerator<T3> >(g3_),
13752         static_cast<ParamGenerator<T4> >(g4_),
13753         static_cast<ParamGenerator<T5> >(g5_),
13754         static_cast<ParamGenerator<T6> >(g6_),
13755         static_cast<ParamGenerator<T7> >(g7_),
13756         static_cast<ParamGenerator<T8> >(g8_),
13757         static_cast<ParamGenerator<T9> >(g9_)));
13758   }
13759 
13760  private:
13761   // No implementation - assignment is unsupported.
13762   void operator=(const CartesianProductHolder9& other);
13763 
13764   const Generator1 g1_;
13765   const Generator2 g2_;
13766   const Generator3 g3_;
13767   const Generator4 g4_;
13768   const Generator5 g5_;
13769   const Generator6 g6_;
13770   const Generator7 g7_;
13771   const Generator8 g8_;
13772   const Generator9 g9_;
13773 };  // class CartesianProductHolder9
13774 
13775 template <class Generator1, class Generator2, class Generator3,
13776     class Generator4, class Generator5, class Generator6, class Generator7,
13777     class Generator8, class Generator9, class Generator10>
13778 class CartesianProductHolder10 {
13779  public:
13780 CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
13781     const Generator3& g3, const Generator4& g4, const Generator5& g5,
13782     const Generator6& g6, const Generator7& g7, const Generator8& g8,
13783     const Generator9& g9, const Generator10& g10)
13784       : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
13785           g9_(g9), g10_(g10) {}
13786   template <typename T1, typename T2, typename T3, typename T4, typename T5,
13787       typename T6, typename T7, typename T8, typename T9, typename T10>
13788   operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
13789       T10> >() const {
13790     return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
13791         T10> >(
13792         new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
13793             T10>(
13794         static_cast<ParamGenerator<T1> >(g1_),
13795         static_cast<ParamGenerator<T2> >(g2_),
13796         static_cast<ParamGenerator<T3> >(g3_),
13797         static_cast<ParamGenerator<T4> >(g4_),
13798         static_cast<ParamGenerator<T5> >(g5_),
13799         static_cast<ParamGenerator<T6> >(g6_),
13800         static_cast<ParamGenerator<T7> >(g7_),
13801         static_cast<ParamGenerator<T8> >(g8_),
13802         static_cast<ParamGenerator<T9> >(g9_),
13803         static_cast<ParamGenerator<T10> >(g10_)));
13804   }
13805 
13806  private:
13807   // No implementation - assignment is unsupported.
13808   void operator=(const CartesianProductHolder10& other);
13809 
13810   const Generator1 g1_;
13811   const Generator2 g2_;
13812   const Generator3 g3_;
13813   const Generator4 g4_;
13814   const Generator5 g5_;
13815   const Generator6 g6_;
13816   const Generator7 g7_;
13817   const Generator8 g8_;
13818   const Generator9 g9_;
13819   const Generator10 g10_;
13820 };  // class CartesianProductHolder10
13821 
13822 # endif  // GTEST_HAS_COMBINE
13823 
13824 }  // namespace internal
13825 }  // namespace testing
13826 
13827 #endif  //  GTEST_HAS_PARAM_TEST
13828 
13829 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
13830 
13831 #if GTEST_HAS_PARAM_TEST
13832 
13833 namespace testing {
13834 
13835 // Functions producing parameter generators.
13836 //
13837 // Google Test uses these generators to produce parameters for value-
13838 // parameterized tests. When a parameterized test case is instantiated
13839 // with a particular generator, Google Test creates and runs tests
13840 // for each element in the sequence produced by the generator.
13841 //
13842 // In the following sample, tests from test case FooTest are instantiated
13843 // each three times with parameter values 3, 5, and 8:
13844 //
13845 // class FooTest : public TestWithParam<int> { ... };
13846 //
13847 // TEST_P(FooTest, TestThis) {
13848 // }
13849 // TEST_P(FooTest, TestThat) {
13850 // }
13851 // INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
13852 //
13853 
13854 // Range() returns generators providing sequences of values in a range.
13855 //
13856 // Synopsis:
13857 // Range(start, end)
13858 //   - returns a generator producing a sequence of values {start, start+1,
13859 //     start+2, ..., }.
13860 // Range(start, end, step)
13861 //   - returns a generator producing a sequence of values {start, start+step,
13862 //     start+step+step, ..., }.
13863 // Notes:
13864 //   * The generated sequences never include end. For example, Range(1, 5)
13865 //     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
13866 //     returns a generator producing {1, 3, 5, 7}.
13867 //   * start and end must have the same type. That type may be any integral or
13868 //     floating-point type or a user defined type satisfying these conditions:
13869 //     * It must be assignable (have operator=() defined).
13870 //     * It must have operator+() (operator+(int-compatible type) for
13871 //       two-operand version).
13872 //     * It must have operator<() defined.
13873 //     Elements in the resulting sequences will also have that type.
13874 //   * Condition start < end must be satisfied in order for resulting sequences
13875 //     to contain any elements.
13876 //
13877 template <typename T, typename IncrementT>
13878 internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
13879   return internal::ParamGenerator<T>(
13880       new internal::RangeGenerator<T, IncrementT>(start, end, step));
13881 }
13882 
13883 template <typename T>
13884 internal::ParamGenerator<T> Range(T start, T end) {
13885   return Range(start, end, 1);
13886 }
13887 
13888 // ValuesIn() function allows generation of tests with parameters coming from
13889 // a container.
13890 //
13891 // Synopsis:
13892 // ValuesIn(const T (&array)[N])
13893 //   - returns a generator producing sequences with elements from
13894 //     a C-style array.
13895 // ValuesIn(const Container& container)
13896 //   - returns a generator producing sequences with elements from
13897 //     an STL-style container.
13898 // ValuesIn(Iterator begin, Iterator end)
13899 //   - returns a generator producing sequences with elements from
13900 //     a range [begin, end) defined by a pair of STL-style iterators. These
13901 //     iterators can also be plain C pointers.
13902 //
13903 // Please note that ValuesIn copies the values from the containers
13904 // passed in and keeps them to generate tests in RUN_ALL_TESTS().
13905 //
13906 // Examples:
13907 //
13908 // This instantiates tests from test case StringTest
13909 // each with C-string values of "foo", "bar", and "baz":
13910 //
13911 // const char* strings[] = {"foo", "bar", "baz"};
13912 // INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
13913 //
13914 // This instantiates tests from test case StlStringTest
13915 // each with STL strings with values "a" and "b":
13916 //
13917 // ::std::vector< ::std::string> GetParameterStrings() {
13918 //   ::std::vector< ::std::string> v;
13919 //   v.push_back("a");
13920 //   v.push_back("b");
13921 //   return v;
13922 // }
13923 //
13924 // INSTANTIATE_TEST_CASE_P(CharSequence,
13925 //                         StlStringTest,
13926 //                         ValuesIn(GetParameterStrings()));
13927 //
13928 //
13929 // This will also instantiate tests from CharTest
13930 // each with parameter values 'a' and 'b':
13931 //
13932 // ::std::list<char> GetParameterChars() {
13933 //   ::std::list<char> list;
13934 //   list.push_back('a');
13935 //   list.push_back('b');
13936 //   return list;
13937 // }
13938 // ::std::list<char> l = GetParameterChars();
13939 // INSTANTIATE_TEST_CASE_P(CharSequence2,
13940 //                         CharTest,
13941 //                         ValuesIn(l.begin(), l.end()));
13942 //
13943 template <typename ForwardIterator>
13944 internal::ParamGenerator<
13945   typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
13946 ValuesIn(ForwardIterator begin, ForwardIterator end) {
13947   typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
13948       ::value_type ParamType;
13949   return internal::ParamGenerator<ParamType>(
13950       new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
13951 }
13952 
13953 template <typename T, size_t N>
13954 internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
13955   return ValuesIn(array, array + N);
13956 }
13957 
13958 template <class Container>
13959 internal::ParamGenerator<typename Container::value_type> ValuesIn(
13960     const Container& container) {
13961   return ValuesIn(container.begin(), container.end());
13962 }
13963 
13964 // Values() allows generating tests from explicitly specified list of
13965 // parameters.
13966 //
13967 // Synopsis:
13968 // Values(T v1, T v2, ..., T vN)
13969 //   - returns a generator producing sequences with elements v1, v2, ..., vN.
13970 //
13971 // For example, this instantiates tests from test case BarTest each
13972 // with values "one", "two", and "three":
13973 //
13974 // INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
13975 //
13976 // This instantiates tests from test case BazTest each with values 1, 2, 3.5.
13977 // The exact type of values will depend on the type of parameter in BazTest.
13978 //
13979 // INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
13980 //
13981 // Currently, Values() supports from 1 to 50 parameters.
13982 //
13983 template <typename T1>
13984 internal::ValueArray1<T1> Values(T1 v1) {
13985   return internal::ValueArray1<T1>(v1);
13986 }
13987 
13988 template <typename T1, typename T2>
13989 internal::ValueArray2<T1, T2> Values(T1 v1, T2 v2) {
13990   return internal::ValueArray2<T1, T2>(v1, v2);
13991 }
13992 
13993 template <typename T1, typename T2, typename T3>
13994 internal::ValueArray3<T1, T2, T3> Values(T1 v1, T2 v2, T3 v3) {
13995   return internal::ValueArray3<T1, T2, T3>(v1, v2, v3);
13996 }
13997 
13998 template <typename T1, typename T2, typename T3, typename T4>
13999 internal::ValueArray4<T1, T2, T3, T4> Values(T1 v1, T2 v2, T3 v3, T4 v4) {
14000   return internal::ValueArray4<T1, T2, T3, T4>(v1, v2, v3, v4);
14001 }
14002 
14003 template <typename T1, typename T2, typename T3, typename T4, typename T5>
14004 internal::ValueArray5<T1, T2, T3, T4, T5> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14005     T5 v5) {
14006   return internal::ValueArray5<T1, T2, T3, T4, T5>(v1, v2, v3, v4, v5);
14007 }
14008 
14009 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14010     typename T6>
14011 internal::ValueArray6<T1, T2, T3, T4, T5, T6> Values(T1 v1, T2 v2, T3 v3,
14012     T4 v4, T5 v5, T6 v6) {
14013   return internal::ValueArray6<T1, T2, T3, T4, T5, T6>(v1, v2, v3, v4, v5, v6);
14014 }
14015 
14016 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14017     typename T6, typename T7>
14018 internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7> Values(T1 v1, T2 v2, T3 v3,
14019     T4 v4, T5 v5, T6 v6, T7 v7) {
14020   return internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7>(v1, v2, v3, v4, v5,
14021       v6, v7);
14022 }
14023 
14024 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14025     typename T6, typename T7, typename T8>
14026 internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8> Values(T1 v1, T2 v2,
14027     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
14028   return internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8>(v1, v2, v3, v4,
14029       v5, v6, v7, v8);
14030 }
14031 
14032 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14033     typename T6, typename T7, typename T8, typename T9>
14034 internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9> Values(T1 v1, T2 v2,
14035     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {
14036   return internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1, v2, v3,
14037       v4, v5, v6, v7, v8, v9);
14038 }
14039 
14040 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14041     typename T6, typename T7, typename T8, typename T9, typename T10>
14042 internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Values(T1 v1,
14043     T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {
14044   return internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1,
14045       v2, v3, v4, v5, v6, v7, v8, v9, v10);
14046 }
14047 
14048 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14049     typename T6, typename T7, typename T8, typename T9, typename T10,
14050     typename T11>
14051 internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
14052     T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14053     T10 v10, T11 v11) {
14054   return internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
14055       T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
14056 }
14057 
14058 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14059     typename T6, typename T7, typename T8, typename T9, typename T10,
14060     typename T11, typename T12>
14061 internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14062     T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14063     T10 v10, T11 v11, T12 v12) {
14064   return internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14065       T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
14066 }
14067 
14068 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14069     typename T6, typename T7, typename T8, typename T9, typename T10,
14070     typename T11, typename T12, typename T13>
14071 internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
14072     T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14073     T10 v10, T11 v11, T12 v12, T13 v13) {
14074   return internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14075       T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
14076 }
14077 
14078 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14079     typename T6, typename T7, typename T8, typename T9, typename T10,
14080     typename T11, typename T12, typename T13, typename T14>
14081 internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14082     T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14083     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {
14084   return internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14085       T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
14086       v14);
14087 }
14088 
14089 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14090     typename T6, typename T7, typename T8, typename T9, typename T10,
14091     typename T11, typename T12, typename T13, typename T14, typename T15>
14092 internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14093     T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
14094     T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {
14095   return internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14096       T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
14097       v13, v14, v15);
14098 }
14099 
14100 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14101     typename T6, typename T7, typename T8, typename T9, typename T10,
14102     typename T11, typename T12, typename T13, typename T14, typename T15,
14103     typename T16>
14104 internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14105     T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14106     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14107     T16 v16) {
14108   return internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14109       T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
14110       v12, v13, v14, v15, v16);
14111 }
14112 
14113 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14114     typename T6, typename T7, typename T8, typename T9, typename T10,
14115     typename T11, typename T12, typename T13, typename T14, typename T15,
14116     typename T16, typename T17>
14117 internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14118     T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14119     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14120     T16 v16, T17 v17) {
14121   return internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14122       T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
14123       v11, v12, v13, v14, v15, v16, v17);
14124 }
14125 
14126 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14127     typename T6, typename T7, typename T8, typename T9, typename T10,
14128     typename T11, typename T12, typename T13, typename T14, typename T15,
14129     typename T16, typename T17, typename T18>
14130 internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14131     T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
14132     T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14133     T16 v16, T17 v17, T18 v18) {
14134   return internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14135       T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
14136       v10, v11, v12, v13, v14, v15, v16, v17, v18);
14137 }
14138 
14139 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14140     typename T6, typename T7, typename T8, typename T9, typename T10,
14141     typename T11, typename T12, typename T13, typename T14, typename T15,
14142     typename T16, typename T17, typename T18, typename T19>
14143 internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14144     T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
14145     T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
14146     T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {
14147   return internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14148       T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,
14149       v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);
14150 }
14151 
14152 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14153     typename T6, typename T7, typename T8, typename T9, typename T10,
14154     typename T11, typename T12, typename T13, typename T14, typename T15,
14155     typename T16, typename T17, typename T18, typename T19, typename T20>
14156 internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14157     T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14158     T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
14159     T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {
14160   return internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14161       T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,
14162       v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);
14163 }
14164 
14165 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14166     typename T6, typename T7, typename T8, typename T9, typename T10,
14167     typename T11, typename T12, typename T13, typename T14, typename T15,
14168     typename T16, typename T17, typename T18, typename T19, typename T20,
14169     typename T21>
14170 internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14171     T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14172     T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
14173     T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {
14174   return internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14175       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,
14176       v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);
14177 }
14178 
14179 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14180     typename T6, typename T7, typename T8, typename T9, typename T10,
14181     typename T11, typename T12, typename T13, typename T14, typename T15,
14182     typename T16, typename T17, typename T18, typename T19, typename T20,
14183     typename T21, typename T22>
14184 internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14185     T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,
14186     T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14187     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14188     T21 v21, T22 v22) {
14189   return internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14190       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,
14191       v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
14192       v20, v21, v22);
14193 }
14194 
14195 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14196     typename T6, typename T7, typename T8, typename T9, typename T10,
14197     typename T11, typename T12, typename T13, typename T14, typename T15,
14198     typename T16, typename T17, typename T18, typename T19, typename T20,
14199     typename T21, typename T22, typename T23>
14200 internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14201     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,
14202     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14203     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14204     T21 v21, T22 v22, T23 v23) {
14205   return internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14206       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,
14207       v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
14208       v20, v21, v22, v23);
14209 }
14210 
14211 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14212     typename T6, typename T7, typename T8, typename T9, typename T10,
14213     typename T11, typename T12, typename T13, typename T14, typename T15,
14214     typename T16, typename T17, typename T18, typename T19, typename T20,
14215     typename T21, typename T22, typename T23, typename T24>
14216 internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14217     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,
14218     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14219     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14220     T21 v21, T22 v22, T23 v23, T24 v24) {
14221   return internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14222       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,
14223       v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
14224       v19, v20, v21, v22, v23, v24);
14225 }
14226 
14227 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14228     typename T6, typename T7, typename T8, typename T9, typename T10,
14229     typename T11, typename T12, typename T13, typename T14, typename T15,
14230     typename T16, typename T17, typename T18, typename T19, typename T20,
14231     typename T21, typename T22, typename T23, typename T24, typename T25>
14232 internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14233     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,
14234     T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
14235     T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
14236     T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {
14237   return internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14238       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,
14239       v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
14240       v18, v19, v20, v21, v22, v23, v24, v25);
14241 }
14242 
14243 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14244     typename T6, typename T7, typename T8, typename T9, typename T10,
14245     typename T11, typename T12, typename T13, typename T14, typename T15,
14246     typename T16, typename T17, typename T18, typename T19, typename T20,
14247     typename T21, typename T22, typename T23, typename T24, typename T25,
14248     typename T26>
14249 internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14250     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14251     T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14252     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14253     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14254     T26 v26) {
14255   return internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14256       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14257       T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
14258       v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);
14259 }
14260 
14261 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14262     typename T6, typename T7, typename T8, typename T9, typename T10,
14263     typename T11, typename T12, typename T13, typename T14, typename T15,
14264     typename T16, typename T17, typename T18, typename T19, typename T20,
14265     typename T21, typename T22, typename T23, typename T24, typename T25,
14266     typename T26, typename T27>
14267 internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14268     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
14269     T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14270     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14271     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14272     T26 v26, T27 v27) {
14273   return internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14274       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14275       T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
14276       v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
14277 }
14278 
14279 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14280     typename T6, typename T7, typename T8, typename T9, typename T10,
14281     typename T11, typename T12, typename T13, typename T14, typename T15,
14282     typename T16, typename T17, typename T18, typename T19, typename T20,
14283     typename T21, typename T22, typename T23, typename T24, typename T25,
14284     typename T26, typename T27, typename T28>
14285 internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14286     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
14287     T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14288     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14289     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14290     T26 v26, T27 v27, T28 v28) {
14291   return internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14292       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14293       T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
14294       v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
14295       v28);
14296 }
14297 
14298 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14299     typename T6, typename T7, typename T8, typename T9, typename T10,
14300     typename T11, typename T12, typename T13, typename T14, typename T15,
14301     typename T16, typename T17, typename T18, typename T19, typename T20,
14302     typename T21, typename T22, typename T23, typename T24, typename T25,
14303     typename T26, typename T27, typename T28, typename T29>
14304 internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14305     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14306     T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14307     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14308     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14309     T26 v26, T27 v27, T28 v28, T29 v29) {
14310   return internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14311       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14312       T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
14313       v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
14314       v27, v28, v29);
14315 }
14316 
14317 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14318     typename T6, typename T7, typename T8, typename T9, typename T10,
14319     typename T11, typename T12, typename T13, typename T14, typename T15,
14320     typename T16, typename T17, typename T18, typename T19, typename T20,
14321     typename T21, typename T22, typename T23, typename T24, typename T25,
14322     typename T26, typename T27, typename T28, typename T29, typename T30>
14323 internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14324     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14325     T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
14326     T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
14327     T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
14328     T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {
14329   return internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14330       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14331       T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
14332       v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
14333       v26, v27, v28, v29, v30);
14334 }
14335 
14336 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14337     typename T6, typename T7, typename T8, typename T9, typename T10,
14338     typename T11, typename T12, typename T13, typename T14, typename T15,
14339     typename T16, typename T17, typename T18, typename T19, typename T20,
14340     typename T21, typename T22, typename T23, typename T24, typename T25,
14341     typename T26, typename T27, typename T28, typename T29, typename T30,
14342     typename T31>
14343 internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14344     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14345     T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14346     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14347     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14348     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {
14349   return internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14350       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14351       T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
14352       v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
14353       v25, v26, v27, v28, v29, v30, v31);
14354 }
14355 
14356 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14357     typename T6, typename T7, typename T8, typename T9, typename T10,
14358     typename T11, typename T12, typename T13, typename T14, typename T15,
14359     typename T16, typename T17, typename T18, typename T19, typename T20,
14360     typename T21, typename T22, typename T23, typename T24, typename T25,
14361     typename T26, typename T27, typename T28, typename T29, typename T30,
14362     typename T31, typename T32>
14363 internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14364     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14365     T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14366     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14367     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14368     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
14369     T32 v32) {
14370   return internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14371       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14372       T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
14373       v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
14374       v24, v25, v26, v27, v28, v29, v30, v31, v32);
14375 }
14376 
14377 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14378     typename T6, typename T7, typename T8, typename T9, typename T10,
14379     typename T11, typename T12, typename T13, typename T14, typename T15,
14380     typename T16, typename T17, typename T18, typename T19, typename T20,
14381     typename T21, typename T22, typename T23, typename T24, typename T25,
14382     typename T26, typename T27, typename T28, typename T29, typename T30,
14383     typename T31, typename T32, typename T33>
14384 internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14385     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14386     T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
14387     T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14388     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14389     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
14390     T32 v32, T33 v33) {
14391   return internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14392       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14393       T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,
14394       v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
14395       v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);
14396 }
14397 
14398 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14399     typename T6, typename T7, typename T8, typename T9, typename T10,
14400     typename T11, typename T12, typename T13, typename T14, typename T15,
14401     typename T16, typename T17, typename T18, typename T19, typename T20,
14402     typename T21, typename T22, typename T23, typename T24, typename T25,
14403     typename T26, typename T27, typename T28, typename T29, typename T30,
14404     typename T31, typename T32, typename T33, typename T34>
14405 internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14406     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14407     T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
14408     T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
14409     T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
14410     T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
14411     T31 v31, T32 v32, T33 v33, T34 v34) {
14412   return internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14413       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14414       T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,
14415       v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
14416       v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);
14417 }
14418 
14419 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14420     typename T6, typename T7, typename T8, typename T9, typename T10,
14421     typename T11, typename T12, typename T13, typename T14, typename T15,
14422     typename T16, typename T17, typename T18, typename T19, typename T20,
14423     typename T21, typename T22, typename T23, typename T24, typename T25,
14424     typename T26, typename T27, typename T28, typename T29, typename T30,
14425     typename T31, typename T32, typename T33, typename T34, typename T35>
14426 internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14427     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14428     T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14429     T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
14430     T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
14431     T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
14432     T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {
14433   return internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14434       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14435       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,
14436       v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
14437       v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);
14438 }
14439 
14440 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14441     typename T6, typename T7, typename T8, typename T9, typename T10,
14442     typename T11, typename T12, typename T13, typename T14, typename T15,
14443     typename T16, typename T17, typename T18, typename T19, typename T20,
14444     typename T21, typename T22, typename T23, typename T24, typename T25,
14445     typename T26, typename T27, typename T28, typename T29, typename T30,
14446     typename T31, typename T32, typename T33, typename T34, typename T35,
14447     typename T36>
14448 internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14449     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14450     T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14451     T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
14452     T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
14453     T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
14454     T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {
14455   return internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14456       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14457       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,
14458       v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
14459       v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
14460       v34, v35, v36);
14461 }
14462 
14463 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14464     typename T6, typename T7, typename T8, typename T9, typename T10,
14465     typename T11, typename T12, typename T13, typename T14, typename T15,
14466     typename T16, typename T17, typename T18, typename T19, typename T20,
14467     typename T21, typename T22, typename T23, typename T24, typename T25,
14468     typename T26, typename T27, typename T28, typename T29, typename T30,
14469     typename T31, typename T32, typename T33, typename T34, typename T35,
14470     typename T36, typename T37>
14471 internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14472     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14473     T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,
14474     T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14475     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14476     T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
14477     T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
14478     T37 v37) {
14479   return internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14480       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14481       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,
14482       v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
14483       v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
14484       v34, v35, v36, v37);
14485 }
14486 
14487 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14488     typename T6, typename T7, typename T8, typename T9, typename T10,
14489     typename T11, typename T12, typename T13, typename T14, typename T15,
14490     typename T16, typename T17, typename T18, typename T19, typename T20,
14491     typename T21, typename T22, typename T23, typename T24, typename T25,
14492     typename T26, typename T27, typename T28, typename T29, typename T30,
14493     typename T31, typename T32, typename T33, typename T34, typename T35,
14494     typename T36, typename T37, typename T38>
14495 internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14496     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14497     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,
14498     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14499     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14500     T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
14501     T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
14502     T37 v37, T38 v38) {
14503   return internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14504       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14505       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,
14506       v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
14507       v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,
14508       v33, v34, v35, v36, v37, v38);
14509 }
14510 
14511 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14512     typename T6, typename T7, typename T8, typename T9, typename T10,
14513     typename T11, typename T12, typename T13, typename T14, typename T15,
14514     typename T16, typename T17, typename T18, typename T19, typename T20,
14515     typename T21, typename T22, typename T23, typename T24, typename T25,
14516     typename T26, typename T27, typename T28, typename T29, typename T30,
14517     typename T31, typename T32, typename T33, typename T34, typename T35,
14518     typename T36, typename T37, typename T38, typename T39>
14519 internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14520     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14521     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,
14522     T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
14523     T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
14524     T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
14525     T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
14526     T37 v37, T38 v38, T39 v39) {
14527   return internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14528       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14529       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,
14530       v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
14531       v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
14532       v32, v33, v34, v35, v36, v37, v38, v39);
14533 }
14534 
14535 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14536     typename T6, typename T7, typename T8, typename T9, typename T10,
14537     typename T11, typename T12, typename T13, typename T14, typename T15,
14538     typename T16, typename T17, typename T18, typename T19, typename T20,
14539     typename T21, typename T22, typename T23, typename T24, typename T25,
14540     typename T26, typename T27, typename T28, typename T29, typename T30,
14541     typename T31, typename T32, typename T33, typename T34, typename T35,
14542     typename T36, typename T37, typename T38, typename T39, typename T40>
14543 internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14544     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14545     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,
14546     T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
14547     T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
14548     T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,
14549     T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,
14550     T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {
14551   return internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14552       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14553       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14554       T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
14555       v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,
14556       v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);
14557 }
14558 
14559 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14560     typename T6, typename T7, typename T8, typename T9, typename T10,
14561     typename T11, typename T12, typename T13, typename T14, typename T15,
14562     typename T16, typename T17, typename T18, typename T19, typename T20,
14563     typename T21, typename T22, typename T23, typename T24, typename T25,
14564     typename T26, typename T27, typename T28, typename T29, typename T30,
14565     typename T31, typename T32, typename T33, typename T34, typename T35,
14566     typename T36, typename T37, typename T38, typename T39, typename T40,
14567     typename T41>
14568 internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14569     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14570     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
14571     T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14572     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14573     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14574     T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
14575     T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {
14576   return internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14577       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14578       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14579       T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
14580       v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,
14581       v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);
14582 }
14583 
14584 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14585     typename T6, typename T7, typename T8, typename T9, typename T10,
14586     typename T11, typename T12, typename T13, typename T14, typename T15,
14587     typename T16, typename T17, typename T18, typename T19, typename T20,
14588     typename T21, typename T22, typename T23, typename T24, typename T25,
14589     typename T26, typename T27, typename T28, typename T29, typename T30,
14590     typename T31, typename T32, typename T33, typename T34, typename T35,
14591     typename T36, typename T37, typename T38, typename T39, typename T40,
14592     typename T41, typename T42>
14593 internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14594     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14595     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
14596     T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14597     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14598     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14599     T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
14600     T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
14601     T42 v42) {
14602   return internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14603       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14604       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14605       T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
14606       v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
14607       v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,
14608       v42);
14609 }
14610 
14611 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14612     typename T6, typename T7, typename T8, typename T9, typename T10,
14613     typename T11, typename T12, typename T13, typename T14, typename T15,
14614     typename T16, typename T17, typename T18, typename T19, typename T20,
14615     typename T21, typename T22, typename T23, typename T24, typename T25,
14616     typename T26, typename T27, typename T28, typename T29, typename T30,
14617     typename T31, typename T32, typename T33, typename T34, typename T35,
14618     typename T36, typename T37, typename T38, typename T39, typename T40,
14619     typename T41, typename T42, typename T43>
14620 internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14621     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14622     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
14623     T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14624     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14625     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14626     T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
14627     T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
14628     T42 v42, T43 v43) {
14629   return internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14630       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14631       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14632       T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
14633       v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
14634       v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
14635       v41, v42, v43);
14636 }
14637 
14638 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14639     typename T6, typename T7, typename T8, typename T9, typename T10,
14640     typename T11, typename T12, typename T13, typename T14, typename T15,
14641     typename T16, typename T17, typename T18, typename T19, typename T20,
14642     typename T21, typename T22, typename T23, typename T24, typename T25,
14643     typename T26, typename T27, typename T28, typename T29, typename T30,
14644     typename T31, typename T32, typename T33, typename T34, typename T35,
14645     typename T36, typename T37, typename T38, typename T39, typename T40,
14646     typename T41, typename T42, typename T43, typename T44>
14647 internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14648     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14649     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14650     T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
14651     T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
14652     T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
14653     T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
14654     T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
14655     T42 v42, T43 v43, T44 v44) {
14656   return internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14657       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14658       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14659       T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
14660       v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
14661       v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,
14662       v40, v41, v42, v43, v44);
14663 }
14664 
14665 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14666     typename T6, typename T7, typename T8, typename T9, typename T10,
14667     typename T11, typename T12, typename T13, typename T14, typename T15,
14668     typename T16, typename T17, typename T18, typename T19, typename T20,
14669     typename T21, typename T22, typename T23, typename T24, typename T25,
14670     typename T26, typename T27, typename T28, typename T29, typename T30,
14671     typename T31, typename T32, typename T33, typename T34, typename T35,
14672     typename T36, typename T37, typename T38, typename T39, typename T40,
14673     typename T41, typename T42, typename T43, typename T44, typename T45>
14674 internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14675     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14676     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14677     T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
14678     T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
14679     T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
14680     T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
14681     T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
14682     T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {
14683   return internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14684       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14685       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14686       T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
14687       v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
14688       v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,
14689       v39, v40, v41, v42, v43, v44, v45);
14690 }
14691 
14692 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14693     typename T6, typename T7, typename T8, typename T9, typename T10,
14694     typename T11, typename T12, typename T13, typename T14, typename T15,
14695     typename T16, typename T17, typename T18, typename T19, typename T20,
14696     typename T21, typename T22, typename T23, typename T24, typename T25,
14697     typename T26, typename T27, typename T28, typename T29, typename T30,
14698     typename T31, typename T32, typename T33, typename T34, typename T35,
14699     typename T36, typename T37, typename T38, typename T39, typename T40,
14700     typename T41, typename T42, typename T43, typename T44, typename T45,
14701     typename T46>
14702 internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14703     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14704     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14705     T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14706     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14707     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14708     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
14709     T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
14710     T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {
14711   return internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14712       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14713       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14714       T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
14715       v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
14716       v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
14717       v38, v39, v40, v41, v42, v43, v44, v45, v46);
14718 }
14719 
14720 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14721     typename T6, typename T7, typename T8, typename T9, typename T10,
14722     typename T11, typename T12, typename T13, typename T14, typename T15,
14723     typename T16, typename T17, typename T18, typename T19, typename T20,
14724     typename T21, typename T22, typename T23, typename T24, typename T25,
14725     typename T26, typename T27, typename T28, typename T29, typename T30,
14726     typename T31, typename T32, typename T33, typename T34, typename T35,
14727     typename T36, typename T37, typename T38, typename T39, typename T40,
14728     typename T41, typename T42, typename T43, typename T44, typename T45,
14729     typename T46, typename T47>
14730 internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14731     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14732     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14733     T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
14734     T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14735     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14736     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
14737     T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
14738     T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {
14739   return internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14740       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14741       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14742       T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,
14743       v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
14744       v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
14745       v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);
14746 }
14747 
14748 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14749     typename T6, typename T7, typename T8, typename T9, typename T10,
14750     typename T11, typename T12, typename T13, typename T14, typename T15,
14751     typename T16, typename T17, typename T18, typename T19, typename T20,
14752     typename T21, typename T22, typename T23, typename T24, typename T25,
14753     typename T26, typename T27, typename T28, typename T29, typename T30,
14754     typename T31, typename T32, typename T33, typename T34, typename T35,
14755     typename T36, typename T37, typename T38, typename T39, typename T40,
14756     typename T41, typename T42, typename T43, typename T44, typename T45,
14757     typename T46, typename T47, typename T48>
14758 internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14759     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14760     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14761     T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
14762     T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
14763     T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
14764     T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
14765     T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
14766     T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,
14767     T48 v48) {
14768   return internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14769       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14770       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14771       T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,
14772       v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
14773       v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,
14774       v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);
14775 }
14776 
14777 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14778     typename T6, typename T7, typename T8, typename T9, typename T10,
14779     typename T11, typename T12, typename T13, typename T14, typename T15,
14780     typename T16, typename T17, typename T18, typename T19, typename T20,
14781     typename T21, typename T22, typename T23, typename T24, typename T25,
14782     typename T26, typename T27, typename T28, typename T29, typename T30,
14783     typename T31, typename T32, typename T33, typename T34, typename T35,
14784     typename T36, typename T37, typename T38, typename T39, typename T40,
14785     typename T41, typename T42, typename T43, typename T44, typename T45,
14786     typename T46, typename T47, typename T48, typename T49>
14787 internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14788     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14789     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14790     T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
14791     T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
14792     T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
14793     T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
14794     T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,
14795     T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,
14796     T47 v47, T48 v48, T49 v49) {
14797   return internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14798       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14799       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14800       T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,
14801       v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
14802       v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,
14803       v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);
14804 }
14805 
14806 template <typename T1, typename T2, typename T3, typename T4, typename T5,
14807     typename T6, typename T7, typename T8, typename T9, typename T10,
14808     typename T11, typename T12, typename T13, typename T14, typename T15,
14809     typename T16, typename T17, typename T18, typename T19, typename T20,
14810     typename T21, typename T22, typename T23, typename T24, typename T25,
14811     typename T26, typename T27, typename T28, typename T29, typename T30,
14812     typename T31, typename T32, typename T33, typename T34, typename T35,
14813     typename T36, typename T37, typename T38, typename T39, typename T40,
14814     typename T41, typename T42, typename T43, typename T44, typename T45,
14815     typename T46, typename T47, typename T48, typename T49, typename T50>
14816 internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
14817     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
14818     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
14819     T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,
14820     T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
14821     T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
14822     T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
14823     T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,
14824     T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,
14825     T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {
14826   return internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
14827       T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
14828       T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
14829       T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,
14830       v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
14831       v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
14832       v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,
14833       v48, v49, v50);
14834 }
14835 
14836 // Bool() allows generating tests with parameters in a set of (false, true).
14837 //
14838 // Synopsis:
14839 // Bool()
14840 //   - returns a generator producing sequences with elements {false, true}.
14841 //
14842 // It is useful when testing code that depends on Boolean flags. Combinations
14843 // of multiple flags can be tested when several Bool()'s are combined using
14844 // Combine() function.
14845 //
14846 // In the following example all tests in the test case FlagDependentTest
14847 // will be instantiated twice with parameters false and true.
14848 //
14849 // class FlagDependentTest : public testing::TestWithParam<bool> {
14850 //   virtual void SetUp() {
14851 //     external_flag = GetParam();
14852 //   }
14853 // }
14854 // INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
14855 //
14856 inline internal::ParamGenerator<bool> Bool() {
14857   return Values(false, true);
14858 }
14859 
14860 # if GTEST_HAS_COMBINE
14861 // Combine() allows the user to combine two or more sequences to produce
14862 // values of a Cartesian product of those sequences' elements.
14863 //
14864 // Synopsis:
14865 // Combine(gen1, gen2, ..., genN)
14866 //   - returns a generator producing sequences with elements coming from
14867 //     the Cartesian product of elements from the sequences generated by
14868 //     gen1, gen2, ..., genN. The sequence elements will have a type of
14869 //     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
14870 //     of elements from sequences produces by gen1, gen2, ..., genN.
14871 //
14872 // Combine can have up to 10 arguments. This number is currently limited
14873 // by the maximum number of elements in the tuple implementation used by Google
14874 // Test.
14875 //
14876 // Example:
14877 //
14878 // This will instantiate tests in test case AnimalTest each one with
14879 // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
14880 // tuple("dog", BLACK), and tuple("dog", WHITE):
14881 //
14882 // enum Color { BLACK, GRAY, WHITE };
14883 // class AnimalTest
14884 //     : public testing::TestWithParam<tuple<const char*, Color> > {...};
14885 //
14886 // TEST_P(AnimalTest, AnimalLooksNice) {...}
14887 //
14888 // INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
14889 //                         Combine(Values("cat", "dog"),
14890 //                                 Values(BLACK, WHITE)));
14891 //
14892 // This will instantiate tests in FlagDependentTest with all variations of two
14893 // Boolean flags:
14894 //
14895 // class FlagDependentTest
14896 //     : public testing::TestWithParam<tuple<bool, bool> > {
14897 //   virtual void SetUp() {
14898 //     // Assigns external_flag_1 and external_flag_2 values from the tuple.
14899 //     tie(external_flag_1, external_flag_2) = GetParam();
14900 //   }
14901 // };
14902 //
14903 // TEST_P(FlagDependentTest, TestFeature1) {
14904 //   // Test your code using external_flag_1 and external_flag_2 here.
14905 // }
14906 // INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
14907 //                         Combine(Bool(), Bool()));
14908 //
14909 template <typename Generator1, typename Generator2>
14910 internal::CartesianProductHolder2<Generator1, Generator2> Combine(
14911     const Generator1& g1, const Generator2& g2) {
14912   return internal::CartesianProductHolder2<Generator1, Generator2>(
14913       g1, g2);
14914 }
14915 
14916 template <typename Generator1, typename Generator2, typename Generator3>
14917 internal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(
14918     const Generator1& g1, const Generator2& g2, const Generator3& g3) {
14919   return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
14920       g1, g2, g3);
14921 }
14922 
14923 template <typename Generator1, typename Generator2, typename Generator3,
14924     typename Generator4>
14925 internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
14926     Generator4> Combine(
14927     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14928         const Generator4& g4) {
14929   return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
14930       Generator4>(
14931       g1, g2, g3, g4);
14932 }
14933 
14934 template <typename Generator1, typename Generator2, typename Generator3,
14935     typename Generator4, typename Generator5>
14936 internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
14937     Generator4, Generator5> Combine(
14938     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14939         const Generator4& g4, const Generator5& g5) {
14940   return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
14941       Generator4, Generator5>(
14942       g1, g2, g3, g4, g5);
14943 }
14944 
14945 template <typename Generator1, typename Generator2, typename Generator3,
14946     typename Generator4, typename Generator5, typename Generator6>
14947 internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
14948     Generator4, Generator5, Generator6> Combine(
14949     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14950         const Generator4& g4, const Generator5& g5, const Generator6& g6) {
14951   return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
14952       Generator4, Generator5, Generator6>(
14953       g1, g2, g3, g4, g5, g6);
14954 }
14955 
14956 template <typename Generator1, typename Generator2, typename Generator3,
14957     typename Generator4, typename Generator5, typename Generator6,
14958     typename Generator7>
14959 internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
14960     Generator4, Generator5, Generator6, Generator7> Combine(
14961     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14962         const Generator4& g4, const Generator5& g5, const Generator6& g6,
14963         const Generator7& g7) {
14964   return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
14965       Generator4, Generator5, Generator6, Generator7>(
14966       g1, g2, g3, g4, g5, g6, g7);
14967 }
14968 
14969 template <typename Generator1, typename Generator2, typename Generator3,
14970     typename Generator4, typename Generator5, typename Generator6,
14971     typename Generator7, typename Generator8>
14972 internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
14973     Generator4, Generator5, Generator6, Generator7, Generator8> Combine(
14974     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14975         const Generator4& g4, const Generator5& g5, const Generator6& g6,
14976         const Generator7& g7, const Generator8& g8) {
14977   return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
14978       Generator4, Generator5, Generator6, Generator7, Generator8>(
14979       g1, g2, g3, g4, g5, g6, g7, g8);
14980 }
14981 
14982 template <typename Generator1, typename Generator2, typename Generator3,
14983     typename Generator4, typename Generator5, typename Generator6,
14984     typename Generator7, typename Generator8, typename Generator9>
14985 internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
14986     Generator4, Generator5, Generator6, Generator7, Generator8,
14987     Generator9> Combine(
14988     const Generator1& g1, const Generator2& g2, const Generator3& g3,
14989         const Generator4& g4, const Generator5& g5, const Generator6& g6,
14990         const Generator7& g7, const Generator8& g8, const Generator9& g9) {
14991   return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
14992       Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(
14993       g1, g2, g3, g4, g5, g6, g7, g8, g9);
14994 }
14995 
14996 template <typename Generator1, typename Generator2, typename Generator3,
14997     typename Generator4, typename Generator5, typename Generator6,
14998     typename Generator7, typename Generator8, typename Generator9,
14999     typename Generator10>
15000 internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
15001     Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
15002     Generator10> Combine(
15003     const Generator1& g1, const Generator2& g2, const Generator3& g3,
15004         const Generator4& g4, const Generator5& g5, const Generator6& g6,
15005         const Generator7& g7, const Generator8& g8, const Generator9& g9,
15006         const Generator10& g10) {
15007   return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
15008       Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
15009       Generator10>(
15010       g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
15011 }
15012 # endif  // GTEST_HAS_COMBINE
15013 
15014 
15015 
15016 # define TEST_P(test_case_name, test_name) \
15017   class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
15018       : public test_case_name { \
15019    public: \
15020     GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
15021     virtual void TestBody(); \
15022    private: \
15023     static int AddToRegistry() { \
15024       ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
15025           GetTestCasePatternHolder<test_case_name>(\
15026               #test_case_name, \
15027               ::testing::internal::CodeLocation(\
15028                   __FILE__, __LINE__))->AddTestPattern(\
15029                       #test_case_name, \
15030                       #test_name, \
15031                       new ::testing::internal::TestMetaFactory< \
15032                           GTEST_TEST_CLASS_NAME_(\
15033                               test_case_name, test_name)>()); \
15034       return 0; \
15035     } \
15036     static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
15037     GTEST_DISALLOW_COPY_AND_ASSIGN_(\
15038         GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
15039   }; \
15040   int GTEST_TEST_CLASS_NAME_(test_case_name, \
15041                              test_name)::gtest_registering_dummy_ = \
15042       GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
15043   void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
15044 
15045 // The optional last argument to INSTANTIATE_TEST_CASE_P allows the user
15046 // to specify a function or functor that generates custom test name suffixes
15047 // based on the test parameters. The function should accept one argument of
15048 // type testing::TestParamInfo<class ParamType>, and return std::string.
15049 //
15050 // testing::PrintToStringParamName is a builtin test suffix generator that
15051 // returns the value of testing::PrintToString(GetParam()). It does not work
15052 // for std::string or C strings.
15053 //
15054 // Note: test names must be non-empty, unique, and may only contain ASCII
15055 // alphanumeric characters or underscore.
15056 
15057 # define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
15058   ::testing::internal::ParamGenerator<test_case_name::ParamType> \
15059       gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
15060   ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \
15061       const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \
15062     return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \
15063         (__VA_ARGS__)(info); \
15064   } \
15065   int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \
15066       ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
15067           GetTestCasePatternHolder<test_case_name>(\
15068               #test_case_name, \
15069               ::testing::internal::CodeLocation(\
15070                   __FILE__, __LINE__))->AddTestCaseInstantiation(\
15071                       #prefix, \
15072                       &gtest_##prefix##test_case_name##_EvalGenerator_, \
15073                       &gtest_##prefix##test_case_name##_EvalGenerateName_, \
15074                       __FILE__, __LINE__)
15075 
15076 }  // namespace testing
15077 
15078 #endif  // GTEST_HAS_PARAM_TEST
15079 
15080 #endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
15081 // Copyright 2006, Google Inc.
15082 // All rights reserved.
15083 //
15084 // Redistribution and use in source and binary forms, with or without
15085 // modification, are permitted provided that the following conditions are
15086 // met:
15087 //
15088 //     * Redistributions of source code must retain the above copyright
15089 // notice, this list of conditions and the following disclaimer.
15090 //     * Redistributions in binary form must reproduce the above
15091 // copyright notice, this list of conditions and the following disclaimer
15092 // in the documentation and/or other materials provided with the
15093 // distribution.
15094 //     * Neither the name of Google Inc. nor the names of its
15095 // contributors may be used to endorse or promote products derived from
15096 // this software without specific prior written permission.
15097 //
15098 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15099 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15100 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15101 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
15102 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15103 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15104 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15105 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
15106 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15107 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15108 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15109 //
15110 // Author: wan@google.com (Zhanyong Wan)
15111 //
15112 // Google C++ Testing Framework definitions useful in production code.
15113 
15114 #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
15115 #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
15116 
15117 // When you need to test the private or protected members of a class,
15118 // use the FRIEND_TEST macro to declare your tests as friends of the
15119 // class.  For example:
15120 //
15121 // class MyClass {
15122 //  private:
15123 //   void MyMethod();
15124 //   FRIEND_TEST(MyClassTest, MyMethod);
15125 // };
15126 //
15127 // class MyClassTest : public testing::Test {
15128 //   // ...
15129 // };
15130 //
15131 // TEST_F(MyClassTest, MyMethod) {
15132 //   // Can call MyClass::MyMethod() here.
15133 // }
15134 
15135 #define FRIEND_TEST(test_case_name, test_name)\
15136 friend class test_case_name##_##test_name##_Test
15137 
15138 #endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
15139 // Copyright 2008, Google Inc.
15140 // All rights reserved.
15141 //
15142 // Redistribution and use in source and binary forms, with or without
15143 // modification, are permitted provided that the following conditions are
15144 // met:
15145 //
15146 //     * Redistributions of source code must retain the above copyright
15147 // notice, this list of conditions and the following disclaimer.
15148 //     * Redistributions in binary form must reproduce the above
15149 // copyright notice, this list of conditions and the following disclaimer
15150 // in the documentation and/or other materials provided with the
15151 // distribution.
15152 //     * Neither the name of Google Inc. nor the names of its
15153 // contributors may be used to endorse or promote products derived from
15154 // this software without specific prior written permission.
15155 //
15156 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15157 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15158 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15159 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
15160 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15161 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15162 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15163 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
15164 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15165 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15166 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15167 //
15168 // Author: mheule@google.com (Markus Heule)
15169 //
15170 
15171 #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
15172 #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
15173 
15174 #include <iosfwd>
15175 #include <vector>
15176 
15177 namespace testing {
15178 
15179 // A copyable object representing the result of a test part (i.e. an
15180 // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
15181 //
15182 // Don't inherit from TestPartResult as its destructor is not virtual.
15183 class GTEST_API_ TestPartResult {
15184  public:
15185   // The possible outcomes of a test part (i.e. an assertion or an
15186   // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
15187   enum Type {
15188     kSuccess,          // Succeeded.
15189     kNonFatalFailure,  // Failed but the test can continue.
15190     kFatalFailure      // Failed and the test should be terminated.
15191   };
15192 
15193   // C'tor.  TestPartResult does NOT have a default constructor.
15194   // Always use this constructor (with parameters) to create a
15195   // TestPartResult object.
15196   TestPartResult(Type a_type,
15197                  const char* a_file_name,
15198                  int a_line_number,
15199                  const char* a_message)
15200       : type_(a_type),
15201         file_name_(a_file_name == NULL ? "" : a_file_name),
15202         line_number_(a_line_number),
15203         summary_(ExtractSummary(a_message)),
15204         message_(a_message) {
15205   }
15206 
15207   // Gets the outcome of the test part.
15208   Type type() const { return type_; }
15209 
15210   // Gets the name of the source file where the test part took place, or
15211   // NULL if it's unknown.
15212   const char* file_name() const {
15213     return file_name_.empty() ? NULL : file_name_.c_str();
15214   }
15215 
15216   // Gets the line in the source file where the test part took place,
15217   // or -1 if it's unknown.
15218   int line_number() const { return line_number_; }
15219 
15220   // Gets the summary of the failure message.
15221   const char* summary() const { return summary_.c_str(); }
15222 
15223   // Gets the message associated with the test part.
15224   const char* message() const { return message_.c_str(); }
15225 
15226   // Returns true iff the test part passed.
15227   bool passed() const { return type_ == kSuccess; }
15228 
15229   // Returns true iff the test part failed.
15230   bool failed() const { return type_ != kSuccess; }
15231 
15232   // Returns true iff the test part non-fatally failed.
15233   bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
15234 
15235   // Returns true iff the test part fatally failed.
15236   bool fatally_failed() const { return type_ == kFatalFailure; }
15237 
15238  private:
15239   Type type_;
15240 
15241   // Gets the summary of the failure message by omitting the stack
15242   // trace in it.
15243   static std::string ExtractSummary(const char* message);
15244 
15245   // The name of the source file where the test part took place, or
15246   // "" if the source file is unknown.
15247   std::string file_name_;
15248   // The line in the source file where the test part took place, or -1
15249   // if the line number is unknown.
15250   int line_number_;
15251   std::string summary_;  // The test failure summary.
15252   std::string message_;  // The test failure message.
15253 };
15254 
15255 // Prints a TestPartResult object.
15256 std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
15257 
15258 // An array of TestPartResult objects.
15259 //
15260 // Don't inherit from TestPartResultArray as its destructor is not
15261 // virtual.
15262 class GTEST_API_ TestPartResultArray {
15263  public:
15264   TestPartResultArray() {}
15265 
15266   // Appends the given TestPartResult to the array.
15267   void Append(const TestPartResult& result);
15268 
15269   // Returns the TestPartResult at the given index (0-based).
15270   const TestPartResult& GetTestPartResult(int index) const;
15271 
15272   // Returns the number of TestPartResult objects in the array.
15273   int size() const;
15274 
15275  private:
15276   std::vector<TestPartResult> array_;
15277 
15278   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
15279 };
15280 
15281 // This interface knows how to report a test part result.
15282 class TestPartResultReporterInterface {
15283  public:
15284   virtual ~TestPartResultReporterInterface() {}
15285 
15286   virtual void ReportTestPartResult(const TestPartResult& result) = 0;
15287 };
15288 
15289 namespace internal {
15290 
15291 // This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
15292 // statement generates new fatal failures. To do so it registers itself as the
15293 // current test part result reporter. Besides checking if fatal failures were
15294 // reported, it only delegates the reporting to the former result reporter.
15295 // The original result reporter is restored in the destructor.
15296 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
15297 class GTEST_API_ HasNewFatalFailureHelper
15298     : public TestPartResultReporterInterface {
15299  public:
15300   HasNewFatalFailureHelper();
15301   virtual ~HasNewFatalFailureHelper();
15302   virtual void ReportTestPartResult(const TestPartResult& result);
15303   bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
15304  private:
15305   bool has_new_fatal_failure_;
15306   TestPartResultReporterInterface* original_reporter_;
15307 
15308   GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
15309 };
15310 
15311 }  // namespace internal
15312 
15313 }  // namespace testing
15314 
15315 #endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
15316 // Copyright 2008 Google Inc.
15317 // All Rights Reserved.
15318 //
15319 // Redistribution and use in source and binary forms, with or without
15320 // modification, are permitted provided that the following conditions are
15321 // met:
15322 //
15323 //     * Redistributions of source code must retain the above copyright
15324 // notice, this list of conditions and the following disclaimer.
15325 //     * Redistributions in binary form must reproduce the above
15326 // copyright notice, this list of conditions and the following disclaimer
15327 // in the documentation and/or other materials provided with the
15328 // distribution.
15329 //     * Neither the name of Google Inc. nor the names of its
15330 // contributors may be used to endorse or promote products derived from
15331 // this software without specific prior written permission.
15332 //
15333 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15334 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15335 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15336 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
15337 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15338 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15339 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15340 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
15341 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15342 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15343 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15344 //
15345 // Author: wan@google.com (Zhanyong Wan)
15346 
15347 #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
15348 #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
15349 
15350 // This header implements typed tests and type-parameterized tests.
15351 
15352 // Typed (aka type-driven) tests repeat the same test for types in a
15353 // list.  You must know which types you want to test with when writing
15354 // typed tests. Here's how you do it:
15355 
15356 #if 0
15357 
15358 // First, define a fixture class template.  It should be parameterized
15359 // by a type.  Remember to derive it from testing::Test.
15360 template <typename T>
15361 class FooTest : public testing::Test {
15362  public:
15363   ...
15364   typedef std::list<T> List;
15365   static T shared_;
15366   T value_;
15367 };
15368 
15369 // Next, associate a list of types with the test case, which will be
15370 // repeated for each type in the list.  The typedef is necessary for
15371 // the macro to parse correctly.
15372 typedef testing::Types<char, int, unsigned int> MyTypes;
15373 TYPED_TEST_CASE(FooTest, MyTypes);
15374 
15375 // If the type list contains only one type, you can write that type
15376 // directly without Types<...>:
15377 //   TYPED_TEST_CASE(FooTest, int);
15378 
15379 // Then, use TYPED_TEST() instead of TEST_F() to define as many typed
15380 // tests for this test case as you want.
15381 TYPED_TEST(FooTest, DoesBlah) {
15382   // Inside a test, refer to TypeParam to get the type parameter.
15383   // Since we are inside a derived class template, C++ requires use to
15384   // visit the members of FooTest via 'this'.
15385   TypeParam n = this->value_;
15386 
15387   // To visit static members of the fixture, add the TestFixture::
15388   // prefix.
15389   n += TestFixture::shared_;
15390 
15391   // To refer to typedefs in the fixture, add the "typename
15392   // TestFixture::" prefix.
15393   typename TestFixture::List values;
15394   values.push_back(n);
15395   ...
15396 }
15397 
15398 TYPED_TEST(FooTest, HasPropertyA) { ... }
15399 
15400 #endif  // 0
15401 
15402 // Type-parameterized tests are abstract test patterns parameterized
15403 // by a type.  Compared with typed tests, type-parameterized tests
15404 // allow you to define the test pattern without knowing what the type
15405 // parameters are.  The defined pattern can be instantiated with
15406 // different types any number of times, in any number of translation
15407 // units.
15408 //
15409 // If you are designing an interface or concept, you can define a
15410 // suite of type-parameterized tests to verify properties that any
15411 // valid implementation of the interface/concept should have.  Then,
15412 // each implementation can easily instantiate the test suite to verify
15413 // that it conforms to the requirements, without having to write
15414 // similar tests repeatedly.  Here's an example:
15415 
15416 #if 0
15417 
15418 // First, define a fixture class template.  It should be parameterized
15419 // by a type.  Remember to derive it from testing::Test.
15420 template <typename T>
15421 class FooTest : public testing::Test {
15422   ...
15423 };
15424 
15425 // Next, declare that you will define a type-parameterized test case
15426 // (the _P suffix is for "parameterized" or "pattern", whichever you
15427 // prefer):
15428 TYPED_TEST_CASE_P(FooTest);
15429 
15430 // Then, use TYPED_TEST_P() to define as many type-parameterized tests
15431 // for this type-parameterized test case as you want.
15432 TYPED_TEST_P(FooTest, DoesBlah) {
15433   // Inside a test, refer to TypeParam to get the type parameter.
15434   TypeParam n = 0;
15435   ...
15436 }
15437 
15438 TYPED_TEST_P(FooTest, HasPropertyA) { ... }
15439 
15440 // Now the tricky part: you need to register all test patterns before
15441 // you can instantiate them.  The first argument of the macro is the
15442 // test case name; the rest are the names of the tests in this test
15443 // case.
15444 REGISTER_TYPED_TEST_CASE_P(FooTest,
15445                            DoesBlah, HasPropertyA);
15446 
15447 // Finally, you are free to instantiate the pattern with the types you
15448 // want.  If you put the above code in a header file, you can #include
15449 // it in multiple C++ source files and instantiate it multiple times.
15450 //
15451 // To distinguish different instances of the pattern, the first
15452 // argument to the INSTANTIATE_* macro is a prefix that will be added
15453 // to the actual test case name.  Remember to pick unique prefixes for
15454 // different instances.
15455 typedef testing::Types<char, int, unsigned int> MyTypes;
15456 INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
15457 
15458 // If the type list contains only one type, you can write that type
15459 // directly without Types<...>:
15460 //   INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
15461 
15462 #endif  // 0
15463 
15464 
15465 // Implements typed tests.
15466 
15467 #if GTEST_HAS_TYPED_TEST
15468 
15469 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
15470 //
15471 // Expands to the name of the typedef for the type parameters of the
15472 // given test case.
15473 # define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
15474 
15475 // The 'Types' template argument below must have spaces around it
15476 // since some compilers may choke on '>>' when passing a template
15477 // instance (e.g. Types<int>)
15478 # define TYPED_TEST_CASE(CaseName, Types) \
15479   typedef ::testing::internal::TypeList< Types >::type \
15480       GTEST_TYPE_PARAMS_(CaseName)
15481 
15482 # define TYPED_TEST(CaseName, TestName) \
15483   template <typename gtest_TypeParam_> \
15484   class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
15485       : public CaseName<gtest_TypeParam_> { \
15486    private: \
15487     typedef CaseName<gtest_TypeParam_> TestFixture; \
15488     typedef gtest_TypeParam_ TypeParam; \
15489     virtual void TestBody(); \
15490   }; \
15491   bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
15492       ::testing::internal::TypeParameterizedTest< \
15493           CaseName, \
15494           ::testing::internal::TemplateSel< \
15495               GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
15496           GTEST_TYPE_PARAMS_(CaseName)>::Register(\
15497               "", ::testing::internal::CodeLocation(__FILE__, __LINE__), \
15498               #CaseName, #TestName, 0); \
15499   template <typename gtest_TypeParam_> \
15500   void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
15501 
15502 #endif  // GTEST_HAS_TYPED_TEST
15503 
15504 // Implements type-parameterized tests.
15505 
15506 #if GTEST_HAS_TYPED_TEST_P
15507 
15508 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
15509 //
15510 // Expands to the namespace name that the type-parameterized tests for
15511 // the given type-parameterized test case are defined in.  The exact
15512 // name of the namespace is subject to change without notice.
15513 # define GTEST_CASE_NAMESPACE_(TestCaseName) \
15514   gtest_case_##TestCaseName##_
15515 
15516 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
15517 //
15518 // Expands to the name of the variable used to remember the names of
15519 // the defined tests in the given test case.
15520 # define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
15521   gtest_typed_test_case_p_state_##TestCaseName##_
15522 
15523 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
15524 //
15525 // Expands to the name of the variable used to remember the names of
15526 // the registered tests in the given test case.
15527 # define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
15528   gtest_registered_test_names_##TestCaseName##_
15529 
15530 // The variables defined in the type-parameterized test macros are
15531 // static as typically these macros are used in a .h file that can be
15532 // #included in multiple translation units linked together.
15533 # define TYPED_TEST_CASE_P(CaseName) \
15534   static ::testing::internal::TypedTestCasePState \
15535       GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
15536 
15537 # define TYPED_TEST_P(CaseName, TestName) \
15538   namespace GTEST_CASE_NAMESPACE_(CaseName) { \
15539   template <typename gtest_TypeParam_> \
15540   class TestName : public CaseName<gtest_TypeParam_> { \
15541    private: \
15542     typedef CaseName<gtest_TypeParam_> TestFixture; \
15543     typedef gtest_TypeParam_ TypeParam; \
15544     virtual void TestBody(); \
15545   }; \
15546   static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
15547       GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
15548           __FILE__, __LINE__, #CaseName, #TestName); \
15549   } \
15550   template <typename gtest_TypeParam_> \
15551   void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
15552 
15553 # define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
15554   namespace GTEST_CASE_NAMESPACE_(CaseName) { \
15555   typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
15556   } \
15557   static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
15558       GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
15559           __FILE__, __LINE__, #__VA_ARGS__)
15560 
15561 // The 'Types' template argument below must have spaces around it
15562 // since some compilers may choke on '>>' when passing a template
15563 // instance (e.g. Types<int>)
15564 # define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
15565   bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
15566       ::testing::internal::TypeParameterizedTestCase<CaseName, \
15567           GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
15568           ::testing::internal::TypeList< Types >::type>::Register(\
15569               #Prefix, \
15570               ::testing::internal::CodeLocation(__FILE__, __LINE__), \
15571               &GTEST_TYPED_TEST_CASE_P_STATE_(CaseName), \
15572               #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
15573 
15574 #endif  // GTEST_HAS_TYPED_TEST_P
15575 
15576 #endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
15577 
15578 // Depending on the platform, different string classes are available.
15579 // On Linux, in addition to ::std::string, Google also makes use of
15580 // class ::string, which has the same interface as ::std::string, but
15581 // has a different implementation.
15582 //
15583 // You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
15584 // ::string is available AND is a distinct type to ::std::string, or
15585 // define it to 0 to indicate otherwise.
15586 //
15587 // If ::std::string and ::string are the same class on your platform
15588 // due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0.
15589 //
15590 // If you do not define GTEST_HAS_GLOBAL_STRING, it is defined
15591 // heuristically.
15592 
15593 namespace testing {
15594 
15595 // Declares the flags.
15596 
15597 // This flag temporary enables the disabled tests.
15598 GTEST_DECLARE_bool_(also_run_disabled_tests);
15599 
15600 // This flag brings the debugger on an assertion failure.
15601 GTEST_DECLARE_bool_(break_on_failure);
15602 
15603 // This flag controls whether Google Test catches all test-thrown exceptions
15604 // and logs them as failures.
15605 GTEST_DECLARE_bool_(catch_exceptions);
15606 
15607 // This flag enables using colors in terminal output. Available values are
15608 // "yes" to enable colors, "no" (disable colors), or "auto" (the default)
15609 // to let Google Test decide.
15610 GTEST_DECLARE_string_(color);
15611 
15612 // This flag sets up the filter to select by name using a glob pattern
15613 // the tests to run. If the filter is not given all tests are executed.
15614 GTEST_DECLARE_string_(filter);
15615 
15616 // This flag causes the Google Test to list tests. None of the tests listed
15617 // are actually run if the flag is provided.
15618 GTEST_DECLARE_bool_(list_tests);
15619 
15620 // This flag controls whether Google Test emits a detailed XML report to a file
15621 // in addition to its normal textual output.
15622 GTEST_DECLARE_string_(output);
15623 
15624 // This flags control whether Google Test prints the elapsed time for each
15625 // test.
15626 GTEST_DECLARE_bool_(print_time);
15627 
15628 // This flag specifies the random number seed.
15629 GTEST_DECLARE_int32_(random_seed);
15630 
15631 // This flag sets how many times the tests are repeated. The default value
15632 // is 1. If the value is -1 the tests are repeating forever.
15633 GTEST_DECLARE_int32_(repeat);
15634 
15635 // This flag controls whether Google Test includes Google Test internal
15636 // stack frames in failure stack traces.
15637 GTEST_DECLARE_bool_(show_internal_stack_frames);
15638 
15639 // When this flag is specified, tests' order is randomized on every iteration.
15640 GTEST_DECLARE_bool_(shuffle);
15641 
15642 // This flag specifies the maximum number of stack frames to be
15643 // printed in a failure message.
15644 GTEST_DECLARE_int32_(stack_trace_depth);
15645 
15646 // When this flag is specified, a failed assertion will throw an
15647 // exception if exceptions are enabled, or exit the program with a
15648 // non-zero code otherwise.
15649 GTEST_DECLARE_bool_(throw_on_failure);
15650 
15651 // When this flag is set with a "host:port" string, on supported
15652 // platforms test results are streamed to the specified port on
15653 // the specified host machine.
15654 GTEST_DECLARE_string_(stream_result_to);
15655 
15656 // The upper limit for valid stack trace depths.
15657 const int kMaxStackTraceDepth = 100;
15658 
15659 namespace internal {
15660 
15661 class AssertHelper;
15662 class DefaultGlobalTestPartResultReporter;
15663 class ExecDeathTest;
15664 class NoExecDeathTest;
15665 class FinalSuccessChecker;
15666 class GTestFlagSaver;
15667 class StreamingListenerTest;
15668 class TestResultAccessor;
15669 class TestEventListenersAccessor;
15670 class TestEventRepeater;
15671 class UnitTestRecordPropertyTestHelper;
15672 class WindowsDeathTest;
15673 class UnitTestImpl* GetUnitTestImpl();
15674 void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
15675                                     const std::string& message);
15676 
15677 }  // namespace internal
15678 
15679 // The friend relationship of some of these classes is cyclic.
15680 // If we don't forward declare them the compiler might confuse the classes
15681 // in friendship clauses with same named classes on the scope.
15682 class Test;
15683 class TestCase;
15684 class TestInfo;
15685 class UnitTest;
15686 
15687 // A class for indicating whether an assertion was successful.  When
15688 // the assertion wasn't successful, the AssertionResult object
15689 // remembers a non-empty message that describes how it failed.
15690 //
15691 // To create an instance of this class, use one of the factory functions
15692 // (AssertionSuccess() and AssertionFailure()).
15693 //
15694 // This class is useful for two purposes:
15695 //   1. Defining predicate functions to be used with Boolean test assertions
15696 //      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
15697 //   2. Defining predicate-format functions to be
15698 //      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
15699 //
15700 // For example, if you define IsEven predicate:
15701 //
15702 //   testing::AssertionResult IsEven(int n) {
15703 //     if ((n % 2) == 0)
15704 //       return testing::AssertionSuccess();
15705 //     else
15706 //       return testing::AssertionFailure() << n << " is odd";
15707 //   }
15708 //
15709 // Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
15710 // will print the message
15711 //
15712 //   Value of: IsEven(Fib(5))
15713 //     Actual: false (5 is odd)
15714 //   Expected: true
15715 //
15716 // instead of a more opaque
15717 //
15718 //   Value of: IsEven(Fib(5))
15719 //     Actual: false
15720 //   Expected: true
15721 //
15722 // in case IsEven is a simple Boolean predicate.
15723 //
15724 // If you expect your predicate to be reused and want to support informative
15725 // messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
15726 // about half as often as positive ones in our tests), supply messages for
15727 // both success and failure cases:
15728 //
15729 //   testing::AssertionResult IsEven(int n) {
15730 //     if ((n % 2) == 0)
15731 //       return testing::AssertionSuccess() << n << " is even";
15732 //     else
15733 //       return testing::AssertionFailure() << n << " is odd";
15734 //   }
15735 //
15736 // Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
15737 //
15738 //   Value of: IsEven(Fib(6))
15739 //     Actual: true (8 is even)
15740 //   Expected: false
15741 //
15742 // NB: Predicates that support negative Boolean assertions have reduced
15743 // performance in positive ones so be careful not to use them in tests
15744 // that have lots (tens of thousands) of positive Boolean assertions.
15745 //
15746 // To use this class with EXPECT_PRED_FORMAT assertions such as:
15747 //
15748 //   // Verifies that Foo() returns an even number.
15749 //   EXPECT_PRED_FORMAT1(IsEven, Foo());
15750 //
15751 // you need to define:
15752 //
15753 //   testing::AssertionResult IsEven(const char* expr, int n) {
15754 //     if ((n % 2) == 0)
15755 //       return testing::AssertionSuccess();
15756 //     else
15757 //       return testing::AssertionFailure()
15758 //         << "Expected: " << expr << " is even\n  Actual: it's " << n;
15759 //   }
15760 //
15761 // If Foo() returns 5, you will see the following message:
15762 //
15763 //   Expected: Foo() is even
15764 //     Actual: it's 5
15765 //
15766 class GTEST_API_ AssertionResult {
15767  public:
15768   // Copy constructor.
15769   // Used in EXPECT_TRUE/FALSE(assertion_result).
15770   AssertionResult(const AssertionResult& other);
15771 
15772   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
15773 
15774   // Used in the EXPECT_TRUE/FALSE(bool_expression).
15775   //
15776   // T must be contextually convertible to bool.
15777   //
15778   // The second parameter prevents this overload from being considered if
15779   // the argument is implicitly convertible to AssertionResult. In that case
15780   // we want AssertionResult's copy constructor to be used.
15781   template <typename T>
15782   explicit AssertionResult(
15783       const T& success,
15784       typename internal::EnableIf<
15785           !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type*
15786           /*enabler*/ = NULL)
15787       : success_(success) {}
15788 
15789   GTEST_DISABLE_MSC_WARNINGS_POP_()
15790 
15791   // Assignment operator.
15792   AssertionResult& operator=(AssertionResult other) {
15793     swap(other);
15794     return *this;
15795   }
15796 
15797   // Returns true iff the assertion succeeded.
15798   operator bool() const { return success_; }  // NOLINT
15799 
15800   // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
15801   AssertionResult operator!() const;
15802 
15803   // Returns the text streamed into this AssertionResult. Test assertions
15804   // use it when they fail (i.e., the predicate's outcome doesn't match the
15805   // assertion's expectation). When nothing has been streamed into the
15806   // object, returns an empty string.
15807   const char* message() const {
15808     return message_.get() != NULL ?  message_->c_str() : "";
15809   }
15810   // TODO(vladl@google.com): Remove this after making sure no clients use it.
15811   // Deprecated; please use message() instead.
15812   const char* failure_message() const { return message(); }
15813 
15814   // Streams a custom failure message into this object.
15815   template <typename T> AssertionResult& operator<<(const T& value) {
15816     AppendMessage(Message() << value);
15817     return *this;
15818   }
15819 
15820   // Allows streaming basic output manipulators such as endl or flush into
15821   // this object.
15822   AssertionResult& operator<<(
15823       ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
15824     AppendMessage(Message() << basic_manipulator);
15825     return *this;
15826   }
15827 
15828  private:
15829   // Appends the contents of message to message_.
15830   void AppendMessage(const Message& a_message) {
15831     if (message_.get() == NULL)
15832       message_.reset(new ::std::string);
15833     message_->append(a_message.GetString().c_str());
15834   }
15835 
15836   // Swap the contents of this AssertionResult with other.
15837   void swap(AssertionResult& other);
15838 
15839   // Stores result of the assertion predicate.
15840   bool success_;
15841   // Stores the message describing the condition in case the expectation
15842   // construct is not satisfied with the predicate's outcome.
15843   // Referenced via a pointer to avoid taking too much stack frame space
15844   // with test assertions.
15845   internal::scoped_ptr< ::std::string> message_;
15846 };
15847 
15848 // Makes a successful assertion result.
15849 GTEST_API_ AssertionResult AssertionSuccess();
15850 
15851 // Makes a failed assertion result.
15852 GTEST_API_ AssertionResult AssertionFailure();
15853 
15854 // Makes a failed assertion result with the given failure message.
15855 // Deprecated; use AssertionFailure() << msg.
15856 GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
15857 
15858 // The abstract class that all tests inherit from.
15859 //
15860 // In Google Test, a unit test program contains one or many TestCases, and
15861 // each TestCase contains one or many Tests.
15862 //
15863 // When you define a test using the TEST macro, you don't need to
15864 // explicitly derive from Test - the TEST macro automatically does
15865 // this for you.
15866 //
15867 // The only time you derive from Test is when defining a test fixture
15868 // to be used a TEST_F.  For example:
15869 //
15870 //   class FooTest : public testing::Test {
15871 //    protected:
15872 //     void SetUp() override { ... }
15873 //     void TearDown() override { ... }
15874 //     ...
15875 //   };
15876 //
15877 //   TEST_F(FooTest, Bar) { ... }
15878 //   TEST_F(FooTest, Baz) { ... }
15879 //
15880 // Test is not copyable.
15881 class GTEST_API_ Test {
15882  public:
15883   friend class TestInfo;
15884 
15885   // Defines types for pointers to functions that set up and tear down
15886   // a test case.
15887   typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;
15888   typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;
15889 
15890   // The d'tor is virtual as we intend to inherit from Test.
15891   virtual ~Test();
15892 
15893   // Sets up the stuff shared by all tests in this test case.
15894   //
15895   // Google Test will call Foo::SetUpTestCase() before running the first
15896   // test in test case Foo.  Hence a sub-class can define its own
15897   // SetUpTestCase() method to shadow the one defined in the super
15898   // class.
15899   static void SetUpTestCase() {}
15900 
15901   // Tears down the stuff shared by all tests in this test case.
15902   //
15903   // Google Test will call Foo::TearDownTestCase() after running the last
15904   // test in test case Foo.  Hence a sub-class can define its own
15905   // TearDownTestCase() method to shadow the one defined in the super
15906   // class.
15907   static void TearDownTestCase() {}
15908 
15909   // Returns true iff the current test has a fatal failure.
15910   static bool HasFatalFailure();
15911 
15912   // Returns true iff the current test has a non-fatal failure.
15913   static bool HasNonfatalFailure();
15914 
15915   // Returns true iff the current test has a (either fatal or
15916   // non-fatal) failure.
15917   static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
15918 
15919   // Logs a property for the current test, test case, or for the entire
15920   // invocation of the test program when used outside of the context of a
15921   // test case.  Only the last value for a given key is remembered.  These
15922   // are public static so they can be called from utility functions that are
15923   // not members of the test fixture.  Calls to RecordProperty made during
15924   // lifespan of the test (from the moment its constructor starts to the
15925   // moment its destructor finishes) will be output in XML as attributes of
15926   // the <testcase> element.  Properties recorded from fixture's
15927   // SetUpTestCase or TearDownTestCase are logged as attributes of the
15928   // corresponding <testsuite> element.  Calls to RecordProperty made in the
15929   // global context (before or after invocation of RUN_ALL_TESTS and from
15930   // SetUp/TearDown method of Environment objects registered with Google
15931   // Test) will be output as attributes of the <testsuites> element.
15932   static void RecordProperty(const std::string& key, const std::string& value);
15933   static void RecordProperty(const std::string& key, int value);
15934 
15935  protected:
15936   // Creates a Test object.
15937   Test();
15938 
15939   // Sets up the test fixture.
15940   virtual void SetUp();
15941 
15942   // Tears down the test fixture.
15943   virtual void TearDown();
15944 
15945  private:
15946   // Returns true iff the current test has the same fixture class as
15947   // the first test in the current test case.
15948   static bool HasSameFixtureClass();
15949 
15950   // Runs the test after the test fixture has been set up.
15951   //
15952   // A sub-class must implement this to define the test logic.
15953   //
15954   // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
15955   // Instead, use the TEST or TEST_F macro.
15956   virtual void TestBody() = 0;
15957 
15958   // Sets up, executes, and tears down the test.
15959   void Run();
15960 
15961   // Deletes self.  We deliberately pick an unusual name for this
15962   // internal method to avoid clashing with names used in user TESTs.
15963   void DeleteSelf_() { delete this; }
15964 
15965   const internal::scoped_ptr< GTEST_FLAG_SAVER_ > gtest_flag_saver_;
15966 
15967   // Often a user misspells SetUp() as Setup() and spends a long time
15968   // wondering why it is never called by Google Test.  The declaration of
15969   // the following method is solely for catching such an error at
15970   // compile time:
15971   //
15972   //   - The return type is deliberately chosen to be not void, so it
15973   //   will be a conflict if void Setup() is declared in the user's
15974   //   test fixture.
15975   //
15976   //   - This method is private, so it will be another compiler error
15977   //   if the method is called from the user's test fixture.
15978   //
15979   // DO NOT OVERRIDE THIS FUNCTION.
15980   //
15981   // If you see an error about overriding the following function or
15982   // about it being private, you have mis-spelled SetUp() as Setup().
15983   struct Setup_should_be_spelled_SetUp {};
15984   virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
15985 
15986   // We disallow copying Tests.
15987   GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
15988 };
15989 
15990 typedef internal::TimeInMillis TimeInMillis;
15991 
15992 // A copyable object representing a user specified test property which can be
15993 // output as a key/value string pair.
15994 //
15995 // Don't inherit from TestProperty as its destructor is not virtual.
15996 class TestProperty {
15997  public:
15998   // C'tor.  TestProperty does NOT have a default constructor.
15999   // Always use this constructor (with parameters) to create a
16000   // TestProperty object.
16001   TestProperty(const std::string& a_key, const std::string& a_value) :
16002     key_(a_key), value_(a_value) {
16003   }
16004 
16005   // Gets the user supplied key.
16006   const char* key() const {
16007     return key_.c_str();
16008   }
16009 
16010   // Gets the user supplied value.
16011   const char* value() const {
16012     return value_.c_str();
16013   }
16014 
16015   // Sets a new value, overriding the one supplied in the constructor.
16016   void SetValue(const std::string& new_value) {
16017     value_ = new_value;
16018   }
16019 
16020  private:
16021   // The key supplied by the user.
16022   std::string key_;
16023   // The value supplied by the user.
16024   std::string value_;
16025 };
16026 
16027 // The result of a single Test.  This includes a list of
16028 // TestPartResults, a list of TestProperties, a count of how many
16029 // death tests there are in the Test, and how much time it took to run
16030 // the Test.
16031 //
16032 // TestResult is not copyable.
16033 class GTEST_API_ TestResult {
16034  public:
16035   // Creates an empty TestResult.
16036   TestResult();
16037 
16038   // D'tor.  Do not inherit from TestResult.
16039   ~TestResult();
16040 
16041   // Gets the number of all test parts.  This is the sum of the number
16042   // of successful test parts and the number of failed test parts.
16043   int total_part_count() const;
16044 
16045   // Returns the number of the test properties.
16046   int test_property_count() const;
16047 
16048   // Returns true iff the test passed (i.e. no test part failed).
16049   bool Passed() const { return !Failed(); }
16050 
16051   // Returns true iff the test failed.
16052   bool Failed() const;
16053 
16054   // Returns true iff the test fatally failed.
16055   bool HasFatalFailure() const;
16056 
16057   // Returns true iff the test has a non-fatal failure.
16058   bool HasNonfatalFailure() const;
16059 
16060   // Returns the elapsed time, in milliseconds.
16061   TimeInMillis elapsed_time() const { return elapsed_time_; }
16062 
16063   // Returns the i-th test part result among all the results. i can range
16064   // from 0 to test_property_count() - 1. If i is not in that range, aborts
16065   // the program.
16066   const TestPartResult& GetTestPartResult(int i) const;
16067 
16068   // Returns the i-th test property. i can range from 0 to
16069   // test_property_count() - 1. If i is not in that range, aborts the
16070   // program.
16071   const TestProperty& GetTestProperty(int i) const;
16072 
16073  private:
16074   friend class TestInfo;
16075   friend class TestCase;
16076   friend class UnitTest;
16077   friend class internal::DefaultGlobalTestPartResultReporter;
16078   friend class internal::ExecDeathTest;
16079   friend class internal::TestResultAccessor;
16080   friend class internal::UnitTestImpl;
16081   friend class internal::WindowsDeathTest;
16082 
16083   // Gets the vector of TestPartResults.
16084   const std::vector<TestPartResult>& test_part_results() const {
16085     return test_part_results_;
16086   }
16087 
16088   // Gets the vector of TestProperties.
16089   const std::vector<TestProperty>& test_properties() const {
16090     return test_properties_;
16091   }
16092 
16093   // Sets the elapsed time.
16094   void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
16095 
16096   // Adds a test property to the list. The property is validated and may add
16097   // a non-fatal failure if invalid (e.g., if it conflicts with reserved
16098   // key names). If a property is already recorded for the same key, the
16099   // value will be updated, rather than storing multiple values for the same
16100   // key.  xml_element specifies the element for which the property is being
16101   // recorded and is used for validation.
16102   void RecordProperty(const std::string& xml_element,
16103                       const TestProperty& test_property);
16104 
16105   // Adds a failure if the key is a reserved attribute of Google Test
16106   // testcase tags.  Returns true if the property is valid.
16107   // TODO(russr): Validate attribute names are legal and human readable.
16108   static bool ValidateTestProperty(const std::string& xml_element,
16109                                    const TestProperty& test_property);
16110 
16111   // Adds a test part result to the list.
16112   void AddTestPartResult(const TestPartResult& test_part_result);
16113 
16114   // Returns the death test count.
16115   int death_test_count() const { return death_test_count_; }
16116 
16117   // Increments the death test count, returning the new count.
16118   int increment_death_test_count() { return ++death_test_count_; }
16119 
16120   // Clears the test part results.
16121   void ClearTestPartResults();
16122 
16123   // Clears the object.
16124   void Clear();
16125 
16126   // Protects mutable state of the property vector and of owned
16127   // properties, whose values may be updated.
16128   internal::Mutex test_properites_mutex_;
16129 
16130   // The vector of TestPartResults
16131   std::vector<TestPartResult> test_part_results_;
16132   // The vector of TestProperties
16133   std::vector<TestProperty> test_properties_;
16134   // Running count of death tests.
16135   int death_test_count_;
16136   // The elapsed time, in milliseconds.
16137   TimeInMillis elapsed_time_;
16138 
16139   // We disallow copying TestResult.
16140   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
16141 };  // class TestResult
16142 
16143 // A TestInfo object stores the following information about a test:
16144 //
16145 //   Test case name
16146 //   Test name
16147 //   Whether the test should be run
16148 //   A function pointer that creates the test object when invoked
16149 //   Test result
16150 //
16151 // The constructor of TestInfo registers itself with the UnitTest
16152 // singleton such that the RUN_ALL_TESTS() macro knows which tests to
16153 // run.
16154 class GTEST_API_ TestInfo {
16155  public:
16156   // Destructs a TestInfo object.  This function is not virtual, so
16157   // don't inherit from TestInfo.
16158   ~TestInfo();
16159 
16160   // Returns the test case name.
16161   const char* test_case_name() const { return test_case_name_.c_str(); }
16162 
16163   // Returns the test name.
16164   const char* name() const { return name_.c_str(); }
16165 
16166   // Returns the name of the parameter type, or NULL if this is not a typed
16167   // or a type-parameterized test.
16168   const char* type_param() const {
16169     if (type_param_.get() != NULL)
16170       return type_param_->c_str();
16171     return NULL;
16172   }
16173 
16174   // Returns the text representation of the value parameter, or NULL if this
16175   // is not a value-parameterized test.
16176   const char* value_param() const {
16177     if (value_param_.get() != NULL)
16178       return value_param_->c_str();
16179     return NULL;
16180   }
16181 
16182   // Returns the file name where this test is defined.
16183   const char* file() const { return location_.file.c_str(); }
16184 
16185   // Returns the line where this test is defined.
16186   int line() const { return location_.line; }
16187 
16188   // Returns true if this test should run, that is if the test is not
16189   // disabled (or it is disabled but the also_run_disabled_tests flag has
16190   // been specified) and its full name matches the user-specified filter.
16191   //
16192   // Google Test allows the user to filter the tests by their full names.
16193   // The full name of a test Bar in test case Foo is defined as
16194   // "Foo.Bar".  Only the tests that match the filter will run.
16195   //
16196   // A filter is a colon-separated list of glob (not regex) patterns,
16197   // optionally followed by a '-' and a colon-separated list of
16198   // negative patterns (tests to exclude).  A test is run if it
16199   // matches one of the positive patterns and does not match any of
16200   // the negative patterns.
16201   //
16202   // For example, *A*:Foo.* is a filter that matches any string that
16203   // contains the character 'A' or starts with "Foo.".
16204   bool should_run() const { return should_run_; }
16205 
16206   // Returns true iff this test will appear in the XML report.
16207   bool is_reportable() const {
16208     // For now, the XML report includes all tests matching the filter.
16209     // In the future, we may trim tests that are excluded because of
16210     // sharding.
16211     return matches_filter_;
16212   }
16213 
16214   // Returns the result of the test.
16215   const TestResult* result() const { return &result_; }
16216 
16217  private:
16218 #if GTEST_HAS_DEATH_TEST
16219   friend class internal::DefaultDeathTestFactory;
16220 #endif  // GTEST_HAS_DEATH_TEST
16221   friend class Test;
16222   friend class TestCase;
16223   friend class internal::UnitTestImpl;
16224   friend class internal::StreamingListenerTest;
16225   friend TestInfo* internal::MakeAndRegisterTestInfo(
16226       const char* test_case_name,
16227       const char* name,
16228       const char* type_param,
16229       const char* value_param,
16230       internal::CodeLocation code_location,
16231       internal::TypeId fixture_class_id,
16232       Test::SetUpTestCaseFunc set_up_tc,
16233       Test::TearDownTestCaseFunc tear_down_tc,
16234       internal::TestFactoryBase* factory);
16235 
16236   // Constructs a TestInfo object. The newly constructed instance assumes
16237   // ownership of the factory object.
16238   TestInfo(const std::string& test_case_name,
16239            const std::string& name,
16240            const char* a_type_param,   // NULL if not a type-parameterized test
16241            const char* a_value_param,  // NULL if not a value-parameterized test
16242            internal::CodeLocation a_code_location,
16243            internal::TypeId fixture_class_id,
16244            internal::TestFactoryBase* factory);
16245 
16246   // Increments the number of death tests encountered in this test so
16247   // far.
16248   int increment_death_test_count() {
16249     return result_.increment_death_test_count();
16250   }
16251 
16252   // Creates the test object, runs it, records its result, and then
16253   // deletes it.
16254   void Run();
16255 
16256   static void ClearTestResult(TestInfo* test_info) {
16257     test_info->result_.Clear();
16258   }
16259 
16260   // These fields are immutable properties of the test.
16261   const std::string test_case_name_;     // Test case name
16262   const std::string name_;               // Test name
16263   // Name of the parameter type, or NULL if this is not a typed or a
16264   // type-parameterized test.
16265   const internal::scoped_ptr<const ::std::string> type_param_;
16266   // Text representation of the value parameter, or NULL if this is not a
16267   // value-parameterized test.
16268   const internal::scoped_ptr<const ::std::string> value_param_;
16269   internal::CodeLocation location_;
16270   const internal::TypeId fixture_class_id_;   // ID of the test fixture class
16271   bool should_run_;                 // True iff this test should run
16272   bool is_disabled_;                // True iff this test is disabled
16273   bool matches_filter_;             // True if this test matches the
16274                                     // user-specified filter.
16275   internal::TestFactoryBase* const factory_;  // The factory that creates
16276                                               // the test object
16277 
16278   // This field is mutable and needs to be reset before running the
16279   // test for the second time.
16280   TestResult result_;
16281 
16282   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
16283 };
16284 
16285 // A test case, which consists of a vector of TestInfos.
16286 //
16287 // TestCase is not copyable.
16288 class GTEST_API_ TestCase {
16289  public:
16290   // Creates a TestCase with the given name.
16291   //
16292   // TestCase does NOT have a default constructor.  Always use this
16293   // constructor to create a TestCase object.
16294   //
16295   // Arguments:
16296   //
16297   //   name:         name of the test case
16298   //   a_type_param: the name of the test's type parameter, or NULL if
16299   //                 this is not a type-parameterized test.
16300   //   set_up_tc:    pointer to the function that sets up the test case
16301   //   tear_down_tc: pointer to the function that tears down the test case
16302   TestCase(const char* name, const char* a_type_param,
16303            Test::SetUpTestCaseFunc set_up_tc,
16304            Test::TearDownTestCaseFunc tear_down_tc);
16305 
16306   // Destructor of TestCase.
16307   virtual ~TestCase();
16308 
16309   // Gets the name of the TestCase.
16310   const char* name() const { return name_.c_str(); }
16311 
16312   // Returns the name of the parameter type, or NULL if this is not a
16313   // type-parameterized test case.
16314   const char* type_param() const {
16315     if (type_param_.get() != NULL)
16316       return type_param_->c_str();
16317     return NULL;
16318   }
16319 
16320   // Returns true if any test in this test case should run.
16321   bool should_run() const { return should_run_; }
16322 
16323   // Gets the number of successful tests in this test case.
16324   int successful_test_count() const;
16325 
16326   // Gets the number of failed tests in this test case.
16327   int failed_test_count() const;
16328 
16329   // Gets the number of disabled tests that will be reported in the XML report.
16330   int reportable_disabled_test_count() const;
16331 
16332   // Gets the number of disabled tests in this test case.
16333   int disabled_test_count() const;
16334 
16335   // Gets the number of tests to be printed in the XML report.
16336   int reportable_test_count() const;
16337 
16338   // Get the number of tests in this test case that should run.
16339   int test_to_run_count() const;
16340 
16341   // Gets the number of all tests in this test case.
16342   int total_test_count() const;
16343 
16344   // Returns true iff the test case passed.
16345   bool Passed() const { return !Failed(); }
16346 
16347   // Returns true iff the test case failed.
16348   bool Failed() const { return failed_test_count() > 0; }
16349 
16350   // Returns the elapsed time, in milliseconds.
16351   TimeInMillis elapsed_time() const { return elapsed_time_; }
16352 
16353   // Returns the i-th test among all the tests. i can range from 0 to
16354   // total_test_count() - 1. If i is not in that range, returns NULL.
16355   const TestInfo* GetTestInfo(int i) const;
16356 
16357   // Returns the TestResult that holds test properties recorded during
16358   // execution of SetUpTestCase and TearDownTestCase.
16359   const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
16360 
16361  private:
16362   friend class Test;
16363   friend class internal::UnitTestImpl;
16364 
16365   // Gets the (mutable) vector of TestInfos in this TestCase.
16366   std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
16367 
16368   // Gets the (immutable) vector of TestInfos in this TestCase.
16369   const std::vector<TestInfo*>& test_info_list() const {
16370     return test_info_list_;
16371   }
16372 
16373   // Returns the i-th test among all the tests. i can range from 0 to
16374   // total_test_count() - 1. If i is not in that range, returns NULL.
16375   TestInfo* GetMutableTestInfo(int i);
16376 
16377   // Sets the should_run member.
16378   void set_should_run(bool should) { should_run_ = should; }
16379 
16380   // Adds a TestInfo to this test case.  Will delete the TestInfo upon
16381   // destruction of the TestCase object.
16382   void AddTestInfo(TestInfo * test_info);
16383 
16384   // Clears the results of all tests in this test case.
16385   void ClearResult();
16386 
16387   // Clears the results of all tests in the given test case.
16388   static void ClearTestCaseResult(TestCase* test_case) {
16389     test_case->ClearResult();
16390   }
16391 
16392   // Runs every test in this TestCase.
16393   void Run();
16394 
16395   // Runs SetUpTestCase() for this TestCase.  This wrapper is needed
16396   // for catching exceptions thrown from SetUpTestCase().
16397   void RunSetUpTestCase() { (*set_up_tc_)(); }
16398 
16399   // Runs TearDownTestCase() for this TestCase.  This wrapper is
16400   // needed for catching exceptions thrown from TearDownTestCase().
16401   void RunTearDownTestCase() { (*tear_down_tc_)(); }
16402 
16403   // Returns true iff test passed.
16404   static bool TestPassed(const TestInfo* test_info) {
16405     return test_info->should_run() && test_info->result()->Passed();
16406   }
16407 
16408   // Returns true iff test failed.
16409   static bool TestFailed(const TestInfo* test_info) {
16410     return test_info->should_run() && test_info->result()->Failed();
16411   }
16412 
16413   // Returns true iff the test is disabled and will be reported in the XML
16414   // report.
16415   static bool TestReportableDisabled(const TestInfo* test_info) {
16416     return test_info->is_reportable() && test_info->is_disabled_;
16417   }
16418 
16419   // Returns true iff test is disabled.
16420   static bool TestDisabled(const TestInfo* test_info) {
16421     return test_info->is_disabled_;
16422   }
16423 
16424   // Returns true iff this test will appear in the XML report.
16425   static bool TestReportable(const TestInfo* test_info) {
16426     return test_info->is_reportable();
16427   }
16428 
16429   // Returns true if the given test should run.
16430   static bool ShouldRunTest(const TestInfo* test_info) {
16431     return test_info->should_run();
16432   }
16433 
16434   // Shuffles the tests in this test case.
16435   void ShuffleTests(internal::Random* random);
16436 
16437   // Restores the test order to before the first shuffle.
16438   void UnshuffleTests();
16439 
16440   // Name of the test case.
16441   std::string name_;
16442   // Name of the parameter type, or NULL if this is not a typed or a
16443   // type-parameterized test.
16444   const internal::scoped_ptr<const ::std::string> type_param_;
16445   // The vector of TestInfos in their original order.  It owns the
16446   // elements in the vector.
16447   std::vector<TestInfo*> test_info_list_;
16448   // Provides a level of indirection for the test list to allow easy
16449   // shuffling and restoring the test order.  The i-th element in this
16450   // vector is the index of the i-th test in the shuffled test list.
16451   std::vector<int> test_indices_;
16452   // Pointer to the function that sets up the test case.
16453   Test::SetUpTestCaseFunc set_up_tc_;
16454   // Pointer to the function that tears down the test case.
16455   Test::TearDownTestCaseFunc tear_down_tc_;
16456   // True iff any test in this test case should run.
16457   bool should_run_;
16458   // Elapsed time, in milliseconds.
16459   TimeInMillis elapsed_time_;
16460   // Holds test properties recorded during execution of SetUpTestCase and
16461   // TearDownTestCase.
16462   TestResult ad_hoc_test_result_;
16463 
16464   // We disallow copying TestCases.
16465   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
16466 };
16467 
16468 // An Environment object is capable of setting up and tearing down an
16469 // environment.  You should subclass this to define your own
16470 // environment(s).
16471 //
16472 // An Environment object does the set-up and tear-down in virtual
16473 // methods SetUp() and TearDown() instead of the constructor and the
16474 // destructor, as:
16475 //
16476 //   1. You cannot safely throw from a destructor.  This is a problem
16477 //      as in some cases Google Test is used where exceptions are enabled, and
16478 //      we may want to implement ASSERT_* using exceptions where they are
16479 //      available.
16480 //   2. You cannot use ASSERT_* directly in a constructor or
16481 //      destructor.
16482 class Environment {
16483  public:
16484   // The d'tor is virtual as we need to subclass Environment.
16485   virtual ~Environment() {}
16486 
16487   // Override this to define how to set up the environment.
16488   virtual void SetUp() {}
16489 
16490   // Override this to define how to tear down the environment.
16491   virtual void TearDown() {}
16492  private:
16493   // If you see an error about overriding the following function or
16494   // about it being private, you have mis-spelled SetUp() as Setup().
16495   struct Setup_should_be_spelled_SetUp {};
16496   virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
16497 };
16498 
16499 // The interface for tracing execution of tests. The methods are organized in
16500 // the order the corresponding events are fired.
16501 class TestEventListener {
16502  public:
16503   virtual ~TestEventListener() {}
16504 
16505   // Fired before any test activity starts.
16506   virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
16507 
16508   // Fired before each iteration of tests starts.  There may be more than
16509   // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
16510   // index, starting from 0.
16511   virtual void OnTestIterationStart(const UnitTest& unit_test,
16512                                     int iteration) = 0;
16513 
16514   // Fired before environment set-up for each iteration of tests starts.
16515   virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
16516 
16517   // Fired after environment set-up for each iteration of tests ends.
16518   virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
16519 
16520   // Fired before the test case starts.
16521   virtual void OnTestCaseStart(const TestCase& test_case) = 0;
16522 
16523   // Fired before the test starts.
16524   virtual void OnTestStart(const TestInfo& test_info) = 0;
16525 
16526   // Fired after a failed assertion or a SUCCEED() invocation.
16527   virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
16528 
16529   // Fired after the test ends.
16530   virtual void OnTestEnd(const TestInfo& test_info) = 0;
16531 
16532   // Fired after the test case ends.
16533   virtual void OnTestCaseEnd(const TestCase& test_case) = 0;
16534 
16535   // Fired before environment tear-down for each iteration of tests starts.
16536   virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
16537 
16538   // Fired after environment tear-down for each iteration of tests ends.
16539   virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
16540 
16541   // Fired after each iteration of tests finishes.
16542   virtual void OnTestIterationEnd(const UnitTest& unit_test,
16543                                   int iteration) = 0;
16544 
16545   // Fired after all test activities have ended.
16546   virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
16547 };
16548 
16549 // The convenience class for users who need to override just one or two
16550 // methods and are not concerned that a possible change to a signature of
16551 // the methods they override will not be caught during the build.  For
16552 // comments about each method please see the definition of TestEventListener
16553 // above.
16554 class EmptyTestEventListener : public TestEventListener {
16555  public:
16556   virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
16557   virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
16558                                     int /*iteration*/) {}
16559   virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
16560   virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
16561   virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
16562   virtual void OnTestStart(const TestInfo& /*test_info*/) {}
16563   virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}
16564   virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
16565   virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
16566   virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}
16567   virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
16568   virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
16569                                   int /*iteration*/) {}
16570   virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
16571 };
16572 
16573 // TestEventListeners lets users add listeners to track events in Google Test.
16574 class GTEST_API_ TestEventListeners {
16575  public:
16576   TestEventListeners();
16577   ~TestEventListeners();
16578 
16579   // Appends an event listener to the end of the list. Google Test assumes
16580   // the ownership of the listener (i.e. it will delete the listener when
16581   // the test program finishes).
16582   void Append(TestEventListener* listener);
16583 
16584   // Removes the given event listener from the list and returns it.  It then
16585   // becomes the caller's responsibility to delete the listener. Returns
16586   // NULL if the listener is not found in the list.
16587   TestEventListener* Release(TestEventListener* listener);
16588 
16589   // Returns the standard listener responsible for the default console
16590   // output.  Can be removed from the listeners list to shut down default
16591   // console output.  Note that removing this object from the listener list
16592   // with Release transfers its ownership to the caller and makes this
16593   // function return NULL the next time.
16594   TestEventListener* default_result_printer() const {
16595     return default_result_printer_;
16596   }
16597 
16598   // Returns the standard listener responsible for the default XML output
16599   // controlled by the --gtest_output=xml flag.  Can be removed from the
16600   // listeners list by users who want to shut down the default XML output
16601   // controlled by this flag and substitute it with custom one.  Note that
16602   // removing this object from the listener list with Release transfers its
16603   // ownership to the caller and makes this function return NULL the next
16604   // time.
16605   TestEventListener* default_xml_generator() const {
16606     return default_xml_generator_;
16607   }
16608 
16609  private:
16610   friend class TestCase;
16611   friend class TestInfo;
16612   friend class internal::DefaultGlobalTestPartResultReporter;
16613   friend class internal::NoExecDeathTest;
16614   friend class internal::TestEventListenersAccessor;
16615   friend class internal::UnitTestImpl;
16616 
16617   // Returns repeater that broadcasts the TestEventListener events to all
16618   // subscribers.
16619   TestEventListener* repeater();
16620 
16621   // Sets the default_result_printer attribute to the provided listener.
16622   // The listener is also added to the listener list and previous
16623   // default_result_printer is removed from it and deleted. The listener can
16624   // also be NULL in which case it will not be added to the list. Does
16625   // nothing if the previous and the current listener objects are the same.
16626   void SetDefaultResultPrinter(TestEventListener* listener);
16627 
16628   // Sets the default_xml_generator attribute to the provided listener.  The
16629   // listener is also added to the listener list and previous
16630   // default_xml_generator is removed from it and deleted. The listener can
16631   // also be NULL in which case it will not be added to the list. Does
16632   // nothing if the previous and the current listener objects are the same.
16633   void SetDefaultXmlGenerator(TestEventListener* listener);
16634 
16635   // Controls whether events will be forwarded by the repeater to the
16636   // listeners in the list.
16637   bool EventForwardingEnabled() const;
16638   void SuppressEventForwarding();
16639 
16640   // The actual list of listeners.
16641   internal::TestEventRepeater* repeater_;
16642   // Listener responsible for the standard result output.
16643   TestEventListener* default_result_printer_;
16644   // Listener responsible for the creation of the XML output file.
16645   TestEventListener* default_xml_generator_;
16646 
16647   // We disallow copying TestEventListeners.
16648   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
16649 };
16650 
16651 // A UnitTest consists of a vector of TestCases.
16652 //
16653 // This is a singleton class.  The only instance of UnitTest is
16654 // created when UnitTest::GetInstance() is first called.  This
16655 // instance is never deleted.
16656 //
16657 // UnitTest is not copyable.
16658 //
16659 // This class is thread-safe as long as the methods are called
16660 // according to their specification.
16661 class GTEST_API_ UnitTest {
16662  public:
16663   // Gets the singleton UnitTest object.  The first time this method
16664   // is called, a UnitTest object is constructed and returned.
16665   // Consecutive calls will return the same object.
16666   static UnitTest* GetInstance();
16667 
16668   // Runs all tests in this UnitTest object and prints the result.
16669   // Returns 0 if successful, or 1 otherwise.
16670   //
16671   // This method can only be called from the main thread.
16672   //
16673   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
16674   int Run() GTEST_MUST_USE_RESULT_;
16675 
16676   // Returns the working directory when the first TEST() or TEST_F()
16677   // was executed.  The UnitTest object owns the string.
16678   const char* original_working_dir() const;
16679 
16680   // Returns the TestCase object for the test that's currently running,
16681   // or NULL if no test is running.
16682   const TestCase* current_test_case() const
16683       GTEST_LOCK_EXCLUDED_(mutex_);
16684 
16685   // Returns the TestInfo object for the test that's currently running,
16686   // or NULL if no test is running.
16687   const TestInfo* current_test_info() const
16688       GTEST_LOCK_EXCLUDED_(mutex_);
16689 
16690   // Returns the random seed used at the start of the current test run.
16691   int random_seed() const;
16692 
16693 #if GTEST_HAS_PARAM_TEST
16694   // Returns the ParameterizedTestCaseRegistry object used to keep track of
16695   // value-parameterized tests and instantiate and register them.
16696   //
16697   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
16698   internal::ParameterizedTestCaseRegistry& parameterized_test_registry()
16699       GTEST_LOCK_EXCLUDED_(mutex_);
16700 #endif  // GTEST_HAS_PARAM_TEST
16701 
16702   // Gets the number of successful test cases.
16703   int successful_test_case_count() const;
16704 
16705   // Gets the number of failed test cases.
16706   int failed_test_case_count() const;
16707 
16708   // Gets the number of all test cases.
16709   int total_test_case_count() const;
16710 
16711   // Gets the number of all test cases that contain at least one test
16712   // that should run.
16713   int test_case_to_run_count() const;
16714 
16715   // Gets the number of successful tests.
16716   int successful_test_count() const;
16717 
16718   // Gets the number of failed tests.
16719   int failed_test_count() const;
16720 
16721   // Gets the number of disabled tests that will be reported in the XML report.
16722   int reportable_disabled_test_count() const;
16723 
16724   // Gets the number of disabled tests.
16725   int disabled_test_count() const;
16726 
16727   // Gets the number of tests to be printed in the XML report.
16728   int reportable_test_count() const;
16729 
16730   // Gets the number of all tests.
16731   int total_test_count() const;
16732 
16733   // Gets the number of tests that should run.
16734   int test_to_run_count() const;
16735 
16736   // Gets the time of the test program start, in ms from the start of the
16737   // UNIX epoch.
16738   TimeInMillis start_timestamp() const;
16739 
16740   // Gets the elapsed time, in milliseconds.
16741   TimeInMillis elapsed_time() const;
16742 
16743   // Returns true iff the unit test passed (i.e. all test cases passed).
16744   bool Passed() const;
16745 
16746   // Returns true iff the unit test failed (i.e. some test case failed
16747   // or something outside of all tests failed).
16748   bool Failed() const;
16749 
16750   // Gets the i-th test case among all the test cases. i can range from 0 to
16751   // total_test_case_count() - 1. If i is not in that range, returns NULL.
16752   const TestCase* GetTestCase(int i) const;
16753 
16754   // Returns the TestResult containing information on test failures and
16755   // properties logged outside of individual test cases.
16756   const TestResult& ad_hoc_test_result() const;
16757 
16758   // Returns the list of event listeners that can be used to track events
16759   // inside Google Test.
16760   TestEventListeners& listeners();
16761 
16762  private:
16763   // Registers and returns a global test environment.  When a test
16764   // program is run, all global test environments will be set-up in
16765   // the order they were registered.  After all tests in the program
16766   // have finished, all global test environments will be torn-down in
16767   // the *reverse* order they were registered.
16768   //
16769   // The UnitTest object takes ownership of the given environment.
16770   //
16771   // This method can only be called from the main thread.
16772   Environment* AddEnvironment(Environment* env);
16773 
16774   // Adds a TestPartResult to the current TestResult object.  All
16775   // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
16776   // eventually call this to report their results.  The user code
16777   // should use the assertion macros instead of calling this directly.
16778   void AddTestPartResult(TestPartResult::Type result_type,
16779                          const char* file_name,
16780                          int line_number,
16781                          const std::string& message,
16782                          const std::string& os_stack_trace)
16783       GTEST_LOCK_EXCLUDED_(mutex_);
16784 
16785   // Adds a TestProperty to the current TestResult object when invoked from
16786   // inside a test, to current TestCase's ad_hoc_test_result_ when invoked
16787   // from SetUpTestCase or TearDownTestCase, or to the global property set
16788   // when invoked elsewhere.  If the result already contains a property with
16789   // the same key, the value will be updated.
16790   void RecordProperty(const std::string& key, const std::string& value);
16791 
16792   // Gets the i-th test case among all the test cases. i can range from 0 to
16793   // total_test_case_count() - 1. If i is not in that range, returns NULL.
16794   TestCase* GetMutableTestCase(int i);
16795 
16796   // Accessors for the implementation object.
16797   internal::UnitTestImpl* impl() { return impl_; }
16798   const internal::UnitTestImpl* impl() const { return impl_; }
16799 
16800   // These classes and funcions are friends as they need to access private
16801   // members of UnitTest.
16802   friend class Test;
16803   friend class internal::AssertHelper;
16804   friend class internal::ScopedTrace;
16805   friend class internal::StreamingListenerTest;
16806   friend class internal::UnitTestRecordPropertyTestHelper;
16807   friend Environment* AddGlobalTestEnvironment(Environment* env);
16808   friend internal::UnitTestImpl* internal::GetUnitTestImpl();
16809   friend void internal::ReportFailureInUnknownLocation(
16810       TestPartResult::Type result_type,
16811       const std::string& message);
16812 
16813   // Creates an empty UnitTest.
16814   UnitTest();
16815 
16816   // D'tor
16817   virtual ~UnitTest();
16818 
16819   // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
16820   // Google Test trace stack.
16821   void PushGTestTrace(const internal::TraceInfo& trace)
16822       GTEST_LOCK_EXCLUDED_(mutex_);
16823 
16824   // Pops a trace from the per-thread Google Test trace stack.
16825   void PopGTestTrace()
16826       GTEST_LOCK_EXCLUDED_(mutex_);
16827 
16828   // Protects mutable state in *impl_.  This is mutable as some const
16829   // methods need to lock it too.
16830   mutable internal::Mutex mutex_;
16831 
16832   // Opaque implementation object.  This field is never changed once
16833   // the object is constructed.  We don't mark it as const here, as
16834   // doing so will cause a warning in the constructor of UnitTest.
16835   // Mutable state in *impl_ is protected by mutex_.
16836   internal::UnitTestImpl* impl_;
16837 
16838   // We disallow copying UnitTest.
16839   GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
16840 };
16841 
16842 // A convenient wrapper for adding an environment for the test
16843 // program.
16844 //
16845 // You should call this before RUN_ALL_TESTS() is called, probably in
16846 // main().  If you use gtest_main, you need to call this before main()
16847 // starts for it to take effect.  For example, you can define a global
16848 // variable like this:
16849 //
16850 //   testing::Environment* const foo_env =
16851 //       testing::AddGlobalTestEnvironment(new FooEnvironment);
16852 //
16853 // However, we strongly recommend you to write your own main() and
16854 // call AddGlobalTestEnvironment() there, as relying on initialization
16855 // of global variables makes the code harder to read and may cause
16856 // problems when you register multiple environments from different
16857 // translation units and the environments have dependencies among them
16858 // (remember that the compiler doesn't guarantee the order in which
16859 // global variables from different translation units are initialized).
16860 inline Environment* AddGlobalTestEnvironment(Environment* env) {
16861   return UnitTest::GetInstance()->AddEnvironment(env);
16862 }
16863 
16864 // Initializes Google Test.  This must be called before calling
16865 // RUN_ALL_TESTS().  In particular, it parses a command line for the
16866 // flags that Google Test recognizes.  Whenever a Google Test flag is
16867 // seen, it is removed from argv, and *argc is decremented.
16868 //
16869 // No value is returned.  Instead, the Google Test flag variables are
16870 // updated.
16871 //
16872 // Calling the function for the second time has no user-visible effect.
16873 GTEST_API_ void InitGoogleTest(int* argc, char** argv);
16874 
16875 // This overloaded version can be used in Windows programs compiled in
16876 // UNICODE mode.
16877 GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
16878 
16879 namespace internal {
16880 
16881 // Separate the error generating code from the code path to reduce the stack
16882 // frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers
16883 // when calling EXPECT_* in a tight loop.
16884 template <typename T1, typename T2>
16885 AssertionResult CmpHelperEQFailure(const char* lhs_expression,
16886                                    const char* rhs_expression,
16887                                    const T1& lhs, const T2& rhs) {
16888   return EqFailure(lhs_expression,
16889                    rhs_expression,
16890                    FormatForComparisonFailureMessage(lhs, rhs),
16891                    FormatForComparisonFailureMessage(rhs, lhs),
16892                    false);
16893 }
16894 
16895 // The helper function for {ASSERT|EXPECT}_EQ.
16896 template <typename T1, typename T2>
16897 AssertionResult CmpHelperEQ(const char* lhs_expression,
16898                             const char* rhs_expression,
16899                             const T1& lhs,
16900                             const T2& rhs) {
16901 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4389 /* signed/unsigned mismatch */)
16902   if (lhs == rhs) {
16903     return AssertionSuccess();
16904   }
16905 GTEST_DISABLE_MSC_WARNINGS_POP_()
16906 
16907   return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
16908 }
16909 
16910 // With this overloaded version, we allow anonymous enums to be used
16911 // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
16912 // can be implicitly cast to BiggestInt.
16913 GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
16914                                        const char* rhs_expression,
16915                                        BiggestInt lhs,
16916                                        BiggestInt rhs);
16917 
16918 // The helper class for {ASSERT|EXPECT}_EQ.  The template argument
16919 // lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
16920 // is a null pointer literal.  The following default implementation is
16921 // for lhs_is_null_literal being false.
16922 template <bool lhs_is_null_literal>
16923 class EqHelper {
16924  public:
16925   // This templatized version is for the general case.
16926   template <typename T1, typename T2>
16927   static AssertionResult Compare(const char* lhs_expression,
16928                                  const char* rhs_expression,
16929                                  const T1& lhs,
16930                                  const T2& rhs) {
16931     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
16932   }
16933 
16934   // With this overloaded version, we allow anonymous enums to be used
16935   // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
16936   // enums can be implicitly cast to BiggestInt.
16937   //
16938   // Even though its body looks the same as the above version, we
16939   // cannot merge the two, as it will make anonymous enums unhappy.
16940   static AssertionResult Compare(const char* lhs_expression,
16941                                  const char* rhs_expression,
16942                                  BiggestInt lhs,
16943                                  BiggestInt rhs) {
16944     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
16945   }
16946 };
16947 
16948 // This specialization is used when the first argument to ASSERT_EQ()
16949 // is a null pointer literal, like NULL, false, or 0.
16950 template <>
16951 class EqHelper<true> {
16952  public:
16953   // We define two overloaded versions of Compare().  The first
16954   // version will be picked when the second argument to ASSERT_EQ() is
16955   // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
16956   // EXPECT_EQ(false, a_bool).
16957   template <typename T1, typename T2>
16958   static AssertionResult Compare(
16959       const char* lhs_expression,
16960       const char* rhs_expression,
16961       const T1& lhs,
16962       const T2& rhs,
16963       // The following line prevents this overload from being considered if T2
16964       // is not a pointer type.  We need this because ASSERT_EQ(NULL, my_ptr)
16965       // expands to Compare("", "", NULL, my_ptr), which requires a conversion
16966       // to match the Secret* in the other overload, which would otherwise make
16967       // this template match better.
16968       typename EnableIf<!is_pointer<T2>::value>::type* = 0) {
16969     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
16970   }
16971 
16972   // This version will be picked when the second argument to ASSERT_EQ() is a
16973   // pointer, e.g. ASSERT_EQ(NULL, a_pointer).
16974   template <typename T>
16975   static AssertionResult Compare(
16976       const char* lhs_expression,
16977       const char* rhs_expression,
16978       // We used to have a second template parameter instead of Secret*.  That
16979       // template parameter would deduce to 'long', making this a better match
16980       // than the first overload even without the first overload's EnableIf.
16981       // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
16982       // non-pointer argument" (even a deduced integral argument), so the old
16983       // implementation caused warnings in user code.
16984       Secret* /* lhs (NULL) */,
16985       T* rhs) {
16986     // We already know that 'lhs' is a null pointer.
16987     return CmpHelperEQ(lhs_expression, rhs_expression,
16988                        static_cast<T*>(NULL), rhs);
16989   }
16990 };
16991 
16992 // Separate the error generating code from the code path to reduce the stack
16993 // frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers
16994 // when calling EXPECT_OP in a tight loop.
16995 template <typename T1, typename T2>
16996 AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
16997                                    const T1& val1, const T2& val2,
16998                                    const char* op) {
16999   return AssertionFailure()
17000          << "Expected: (" << expr1 << ") " << op << " (" << expr2
17001          << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
17002          << " vs " << FormatForComparisonFailureMessage(val2, val1);
17003 }
17004 
17005 // A macro for implementing the helper functions needed to implement
17006 // ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste
17007 // of similar code.
17008 //
17009 // For each templatized helper function, we also define an overloaded
17010 // version for BiggestInt in order to reduce code bloat and allow
17011 // anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
17012 // with gcc 4.
17013 //
17014 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17015 
17016 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
17017 template <typename T1, typename T2>\
17018 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
17019                                    const T1& val1, const T2& val2) {\
17020   if (val1 op val2) {\
17021     return AssertionSuccess();\
17022   } else {\
17023     return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
17024   }\
17025 }\
17026 GTEST_API_ AssertionResult CmpHelper##op_name(\
17027     const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
17028 
17029 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17030 
17031 // Implements the helper function for {ASSERT|EXPECT}_NE
17032 GTEST_IMPL_CMP_HELPER_(NE, !=);
17033 // Implements the helper function for {ASSERT|EXPECT}_LE
17034 GTEST_IMPL_CMP_HELPER_(LE, <=);
17035 // Implements the helper function for {ASSERT|EXPECT}_LT
17036 GTEST_IMPL_CMP_HELPER_(LT, <);
17037 // Implements the helper function for {ASSERT|EXPECT}_GE
17038 GTEST_IMPL_CMP_HELPER_(GE, >=);
17039 // Implements the helper function for {ASSERT|EXPECT}_GT
17040 GTEST_IMPL_CMP_HELPER_(GT, >);
17041 
17042 #undef GTEST_IMPL_CMP_HELPER_
17043 
17044 // The helper function for {ASSERT|EXPECT}_STREQ.
17045 //
17046 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17047 GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
17048                                           const char* s2_expression,
17049                                           const char* s1,
17050                                           const char* s2);
17051 
17052 // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
17053 //
17054 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17055 GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
17056                                               const char* s2_expression,
17057                                               const char* s1,
17058                                               const char* s2);
17059 
17060 // The helper function for {ASSERT|EXPECT}_STRNE.
17061 //
17062 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17063 GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
17064                                           const char* s2_expression,
17065                                           const char* s1,
17066                                           const char* s2);
17067 
17068 // The helper function for {ASSERT|EXPECT}_STRCASENE.
17069 //
17070 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17071 GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
17072                                               const char* s2_expression,
17073                                               const char* s1,
17074                                               const char* s2);
17075 
17076 
17077 // Helper function for *_STREQ on wide strings.
17078 //
17079 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17080 GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
17081                                           const char* s2_expression,
17082                                           const wchar_t* s1,
17083                                           const wchar_t* s2);
17084 
17085 // Helper function for *_STRNE on wide strings.
17086 //
17087 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17088 GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
17089                                           const char* s2_expression,
17090                                           const wchar_t* s1,
17091                                           const wchar_t* s2);
17092 
17093 }  // namespace internal
17094 
17095 // IsSubstring() and IsNotSubstring() are intended to be used as the
17096 // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
17097 // themselves.  They check whether needle is a substring of haystack
17098 // (NULL is considered a substring of itself only), and return an
17099 // appropriate error message when they fail.
17100 //
17101 // The {needle,haystack}_expr arguments are the stringified
17102 // expressions that generated the two real arguments.
17103 GTEST_API_ AssertionResult IsSubstring(
17104     const char* needle_expr, const char* haystack_expr,
17105     const char* needle, const char* haystack);
17106 GTEST_API_ AssertionResult IsSubstring(
17107     const char* needle_expr, const char* haystack_expr,
17108     const wchar_t* needle, const wchar_t* haystack);
17109 GTEST_API_ AssertionResult IsNotSubstring(
17110     const char* needle_expr, const char* haystack_expr,
17111     const char* needle, const char* haystack);
17112 GTEST_API_ AssertionResult IsNotSubstring(
17113     const char* needle_expr, const char* haystack_expr,
17114     const wchar_t* needle, const wchar_t* haystack);
17115 GTEST_API_ AssertionResult IsSubstring(
17116     const char* needle_expr, const char* haystack_expr,
17117     const ::std::string& needle, const ::std::string& haystack);
17118 GTEST_API_ AssertionResult IsNotSubstring(
17119     const char* needle_expr, const char* haystack_expr,
17120     const ::std::string& needle, const ::std::string& haystack);
17121 
17122 #if GTEST_HAS_STD_WSTRING
17123 GTEST_API_ AssertionResult IsSubstring(
17124     const char* needle_expr, const char* haystack_expr,
17125     const ::std::wstring& needle, const ::std::wstring& haystack);
17126 GTEST_API_ AssertionResult IsNotSubstring(
17127     const char* needle_expr, const char* haystack_expr,
17128     const ::std::wstring& needle, const ::std::wstring& haystack);
17129 #endif  // GTEST_HAS_STD_WSTRING
17130 
17131 namespace internal {
17132 
17133 // Helper template function for comparing floating-points.
17134 //
17135 // Template parameter:
17136 //
17137 //   RawType: the raw floating-point type (either float or double)
17138 //
17139 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17140 template <typename RawType>
17141 AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
17142                                          const char* rhs_expression,
17143                                          RawType lhs_value,
17144                                          RawType rhs_value) {
17145   const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
17146 
17147   if (lhs.AlmostEquals(rhs)) {
17148     return AssertionSuccess();
17149   }
17150 
17151   ::std::stringstream lhs_ss;
17152   lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
17153          << lhs_value;
17154 
17155   ::std::stringstream rhs_ss;
17156   rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
17157          << rhs_value;
17158 
17159   return EqFailure(lhs_expression,
17160                    rhs_expression,
17161                    StringStreamToString(&lhs_ss),
17162                    StringStreamToString(&rhs_ss),
17163                    false);
17164 }
17165 
17166 // Helper function for implementing ASSERT_NEAR.
17167 //
17168 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
17169 GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
17170                                                 const char* expr2,
17171                                                 const char* abs_error_expr,
17172                                                 double val1,
17173                                                 double val2,
17174                                                 double abs_error);
17175 
17176 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
17177 // A class that enables one to stream messages to assertion macros
17178 class GTEST_API_ AssertHelper {
17179  public:
17180   // Constructor.
17181   AssertHelper(TestPartResult::Type type,
17182                const char* file,
17183                int line,
17184                const char* message);
17185   ~AssertHelper();
17186 
17187   // Message assignment is a semantic trick to enable assertion
17188   // streaming; see the GTEST_MESSAGE_ macro below.
17189   void operator=(const Message& message) const;
17190 
17191  private:
17192   // We put our data in a struct so that the size of the AssertHelper class can
17193   // be as small as possible.  This is important because gcc is incapable of
17194   // re-using stack space even for temporary variables, so every EXPECT_EQ
17195   // reserves stack space for another AssertHelper.
17196   struct AssertHelperData {
17197     AssertHelperData(TestPartResult::Type t,
17198                      const char* srcfile,
17199                      int line_num,
17200                      const char* msg)
17201         : type(t), file(srcfile), line(line_num), message(msg) { }
17202 
17203     TestPartResult::Type const type;
17204     const char* const file;
17205     int const line;
17206     std::string const message;
17207 
17208    private:
17209     GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
17210   };
17211 
17212   AssertHelperData* const data_;
17213 
17214   GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
17215 };
17216 
17217 }  // namespace internal
17218 
17219 #if GTEST_HAS_PARAM_TEST
17220 // The pure interface class that all value-parameterized tests inherit from.
17221 // A value-parameterized class must inherit from both ::testing::Test and
17222 // ::testing::WithParamInterface. In most cases that just means inheriting
17223 // from ::testing::TestWithParam, but more complicated test hierarchies
17224 // may need to inherit from Test and WithParamInterface at different levels.
17225 //
17226 // This interface has support for accessing the test parameter value via
17227 // the GetParam() method.
17228 //
17229 // Use it with one of the parameter generator defining functions, like Range(),
17230 // Values(), ValuesIn(), Bool(), and Combine().
17231 //
17232 // class FooTest : public ::testing::TestWithParam<int> {
17233 //  protected:
17234 //   FooTest() {
17235 //     // Can use GetParam() here.
17236 //   }
17237 //   virtual ~FooTest() {
17238 //     // Can use GetParam() here.
17239 //   }
17240 //   virtual void SetUp() {
17241 //     // Can use GetParam() here.
17242 //   }
17243 //   virtual void TearDown {
17244 //     // Can use GetParam() here.
17245 //   }
17246 // };
17247 // TEST_P(FooTest, DoesBar) {
17248 //   // Can use GetParam() method here.
17249 //   Foo foo;
17250 //   ASSERT_TRUE(foo.DoesBar(GetParam()));
17251 // }
17252 // INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
17253 
17254 template <typename T>
17255 class WithParamInterface {
17256  public:
17257   typedef T ParamType;
17258   virtual ~WithParamInterface() {}
17259 
17260   // The current parameter value. Is also available in the test fixture's
17261   // constructor. This member function is non-static, even though it only
17262   // references static data, to reduce the opportunity for incorrect uses
17263   // like writing 'WithParamInterface<bool>::GetParam()' for a test that
17264   // uses a fixture whose parameter type is int.
17265   const ParamType& GetParam() const {
17266     GTEST_CHECK_(parameter_ != NULL)
17267         << "GetParam() can only be called inside a value-parameterized test "
17268         << "-- did you intend to write TEST_P instead of TEST_F?";
17269     return *parameter_;
17270   }
17271 
17272  private:
17273   // Sets parameter value. The caller is responsible for making sure the value
17274   // remains alive and unchanged throughout the current test.
17275   static void SetParam(const ParamType* parameter) {
17276     parameter_ = parameter;
17277   }
17278 
17279   // Static value used for accessing parameter during a test lifetime.
17280   static const ParamType* parameter_;
17281 
17282   // TestClass must be a subclass of WithParamInterface<T> and Test.
17283   template <class TestClass> friend class internal::ParameterizedTestFactory;
17284 };
17285 
17286 template <typename T>
17287 const T* WithParamInterface<T>::parameter_ = NULL;
17288 
17289 // Most value-parameterized classes can ignore the existence of
17290 // WithParamInterface, and can just inherit from ::testing::TestWithParam.
17291 
17292 template <typename T>
17293 class TestWithParam : public Test, public WithParamInterface<T> {
17294 };
17295 
17296 #endif  // GTEST_HAS_PARAM_TEST
17297 
17298 // Macros for indicating success/failure in test code.
17299 
17300 // ADD_FAILURE unconditionally adds a failure to the current test.
17301 // SUCCEED generates a success - it doesn't automatically make the
17302 // current test successful, as a test is only successful when it has
17303 // no failure.
17304 //
17305 // EXPECT_* verifies that a certain condition is satisfied.  If not,
17306 // it behaves like ADD_FAILURE.  In particular:
17307 //
17308 //   EXPECT_TRUE  verifies that a Boolean condition is true.
17309 //   EXPECT_FALSE verifies that a Boolean condition is false.
17310 //
17311 // FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
17312 // that they will also abort the current function on failure.  People
17313 // usually want the fail-fast behavior of FAIL and ASSERT_*, but those
17314 // writing data-driven tests often find themselves using ADD_FAILURE
17315 // and EXPECT_* more.
17316 
17317 // Generates a nonfatal failure with a generic message.
17318 #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
17319 
17320 // Generates a nonfatal failure at the given source file location with
17321 // a generic message.
17322 #define ADD_FAILURE_AT(file, line) \
17323   GTEST_MESSAGE_AT_(file, line, "Failed", \
17324                     ::testing::TestPartResult::kNonFatalFailure)
17325 
17326 // Generates a fatal failure with a generic message.
17327 #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
17328 
17329 // Define this macro to 1 to omit the definition of FAIL(), which is a
17330 // generic name and clashes with some other libraries.
17331 #if !GTEST_DONT_DEFINE_FAIL
17332 # define FAIL() GTEST_FAIL()
17333 #endif
17334 
17335 // Generates a success with a generic message.
17336 #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
17337 
17338 // Define this macro to 1 to omit the definition of SUCCEED(), which
17339 // is a generic name and clashes with some other libraries.
17340 #if !GTEST_DONT_DEFINE_SUCCEED
17341 # define SUCCEED() GTEST_SUCCEED()
17342 #endif
17343 
17344 // Macros for testing exceptions.
17345 //
17346 //    * {ASSERT|EXPECT}_THROW(statement, expected_exception):
17347 //         Tests that the statement throws the expected exception.
17348 //    * {ASSERT|EXPECT}_NO_THROW(statement):
17349 //         Tests that the statement doesn't throw any exception.
17350 //    * {ASSERT|EXPECT}_ANY_THROW(statement):
17351 //         Tests that the statement throws an exception.
17352 
17353 #define EXPECT_THROW(statement, expected_exception) \
17354   GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
17355 #define EXPECT_NO_THROW(statement) \
17356   GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
17357 #define EXPECT_ANY_THROW(statement) \
17358   GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
17359 #define ASSERT_THROW(statement, expected_exception) \
17360   GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
17361 #define ASSERT_NO_THROW(statement) \
17362   GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
17363 #define ASSERT_ANY_THROW(statement) \
17364   GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
17365 
17366 // Boolean assertions. Condition can be either a Boolean expression or an
17367 // AssertionResult. For more information on how to use AssertionResult with
17368 // these macros see comments on that class.
17369 #define EXPECT_TRUE(condition) \
17370   GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \
17371                       GTEST_NONFATAL_FAILURE_)
17372 #define EXPECT_FALSE(condition) \
17373   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
17374                       GTEST_NONFATAL_FAILURE_)
17375 #define ASSERT_TRUE(condition) \
17376   GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \
17377                       GTEST_FATAL_FAILURE_)
17378 #define ASSERT_FALSE(condition) \
17379   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
17380                       GTEST_FATAL_FAILURE_)
17381 
17382 // Includes the auto-generated header that implements a family of
17383 // generic predicate assertion macros.
17384 // Copyright 2006, Google Inc.
17385 // All rights reserved.
17386 //
17387 // Redistribution and use in source and binary forms, with or without
17388 // modification, are permitted provided that the following conditions are
17389 // met:
17390 //
17391 //     * Redistributions of source code must retain the above copyright
17392 // notice, this list of conditions and the following disclaimer.
17393 //     * Redistributions in binary form must reproduce the above
17394 // copyright notice, this list of conditions and the following disclaimer
17395 // in the documentation and/or other materials provided with the
17396 // distribution.
17397 //     * Neither the name of Google Inc. nor the names of its
17398 // contributors may be used to endorse or promote products derived from
17399 // this software without specific prior written permission.
17400 //
17401 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17402 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17403 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17404 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17405 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17406 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
17407 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
17408 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
17409 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17410 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
17411 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17412 
17413 // This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
17414 // 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
17415 //
17416 // Implements a family of generic predicate assertion macros.
17417 
17418 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
17419 #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
17420 
17421 // Makes sure this header is not included before gtest.h.
17422 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
17423 # error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.
17424 #endif  // GTEST_INCLUDE_GTEST_GTEST_H_
17425 
17426 // This header implements a family of generic predicate assertion
17427 // macros:
17428 //
17429 //   ASSERT_PRED_FORMAT1(pred_format, v1)
17430 //   ASSERT_PRED_FORMAT2(pred_format, v1, v2)
17431 //   ...
17432 //
17433 // where pred_format is a function or functor that takes n (in the
17434 // case of ASSERT_PRED_FORMATn) values and their source expression
17435 // text, and returns a testing::AssertionResult.  See the definition
17436 // of ASSERT_EQ in gtest.h for an example.
17437 //
17438 // If you don't care about formatting, you can use the more
17439 // restrictive version:
17440 //
17441 //   ASSERT_PRED1(pred, v1)
17442 //   ASSERT_PRED2(pred, v1, v2)
17443 //   ...
17444 //
17445 // where pred is an n-ary function or functor that returns bool,
17446 // and the values v1, v2, ..., must support the << operator for
17447 // streaming to std::ostream.
17448 //
17449 // We also define the EXPECT_* variations.
17450 //
17451 // For now we only support predicates whose arity is at most 5.
17452 // Please email googletestframework@googlegroups.com if you need
17453 // support for higher arities.
17454 
17455 // GTEST_ASSERT_ is the basic statement to which all of the assertions
17456 // in this file reduce.  Don't use this in your code.
17457 
17458 #define GTEST_ASSERT_(expression, on_failure) \
17459   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
17460   if (const ::testing::AssertionResult gtest_ar = (expression)) \
17461     ; \
17462   else \
17463     on_failure(gtest_ar.failure_message())
17464 
17465 
17466 // Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use
17467 // this in your code.
17468 template <typename Pred,
17469           typename T1>
17470 AssertionResult AssertPred1Helper(const char* pred_text,
17471                                   const char* e1,
17472                                   Pred pred,
17473                                   const T1& v1) {
17474   if (pred(v1)) return AssertionSuccess();
17475 
17476   return AssertionFailure() << pred_text << "("
17477                             << e1 << ") evaluates to false, where"
17478                             << "\n" << e1 << " evaluates to " << v1;
17479 }
17480 
17481 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
17482 // Don't use this in your code.
17483 #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
17484   GTEST_ASSERT_(pred_format(#v1, v1), \
17485                 on_failure)
17486 
17487 // Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use
17488 // this in your code.
17489 #define GTEST_PRED1_(pred, v1, on_failure)\
17490   GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
17491                                              #v1, \
17492                                              pred, \
17493                                              v1), on_failure)
17494 
17495 // Unary predicate assertion macros.
17496 #define EXPECT_PRED_FORMAT1(pred_format, v1) \
17497   GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
17498 #define EXPECT_PRED1(pred, v1) \
17499   GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
17500 #define ASSERT_PRED_FORMAT1(pred_format, v1) \
17501   GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
17502 #define ASSERT_PRED1(pred, v1) \
17503   GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
17504 
17505 
17506 
17507 // Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use
17508 // this in your code.
17509 template <typename Pred,
17510           typename T1,
17511           typename T2>
17512 AssertionResult AssertPred2Helper(const char* pred_text,
17513                                   const char* e1,
17514                                   const char* e2,
17515                                   Pred pred,
17516                                   const T1& v1,
17517                                   const T2& v2) {
17518   if (pred(v1, v2)) return AssertionSuccess();
17519 
17520   return AssertionFailure() << pred_text << "("
17521                             << e1 << ", "
17522                             << e2 << ") evaluates to false, where"
17523                             << "\n" << e1 << " evaluates to " << v1
17524                             << "\n" << e2 << " evaluates to " << v2;
17525 }
17526 
17527 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
17528 // Don't use this in your code.
17529 #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
17530   GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
17531                 on_failure)
17532 
17533 // Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use
17534 // this in your code.
17535 #define GTEST_PRED2_(pred, v1, v2, on_failure)\
17536   GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
17537                                              #v1, \
17538                                              #v2, \
17539                                              pred, \
17540                                              v1, \
17541                                              v2), on_failure)
17542 
17543 // Binary predicate assertion macros.
17544 #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
17545   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
17546 #define EXPECT_PRED2(pred, v1, v2) \
17547   GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
17548 #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
17549   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
17550 #define ASSERT_PRED2(pred, v1, v2) \
17551   GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
17552 
17553 
17554 
17555 // Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use
17556 // this in your code.
17557 template <typename Pred,
17558           typename T1,
17559           typename T2,
17560           typename T3>
17561 AssertionResult AssertPred3Helper(const char* pred_text,
17562                                   const char* e1,
17563                                   const char* e2,
17564                                   const char* e3,
17565                                   Pred pred,
17566                                   const T1& v1,
17567                                   const T2& v2,
17568                                   const T3& v3) {
17569   if (pred(v1, v2, v3)) return AssertionSuccess();
17570 
17571   return AssertionFailure() << pred_text << "("
17572                             << e1 << ", "
17573                             << e2 << ", "
17574                             << e3 << ") evaluates to false, where"
17575                             << "\n" << e1 << " evaluates to " << v1
17576                             << "\n" << e2 << " evaluates to " << v2
17577                             << "\n" << e3 << " evaluates to " << v3;
17578 }
17579 
17580 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
17581 // Don't use this in your code.
17582 #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
17583   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
17584                 on_failure)
17585 
17586 // Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use
17587 // this in your code.
17588 #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
17589   GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
17590                                              #v1, \
17591                                              #v2, \
17592                                              #v3, \
17593                                              pred, \
17594                                              v1, \
17595                                              v2, \
17596                                              v3), on_failure)
17597 
17598 // Ternary predicate assertion macros.
17599 #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
17600   GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
17601 #define EXPECT_PRED3(pred, v1, v2, v3) \
17602   GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
17603 #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
17604   GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
17605 #define ASSERT_PRED3(pred, v1, v2, v3) \
17606   GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
17607 
17608 
17609 
17610 // Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use
17611 // this in your code.
17612 template <typename Pred,
17613           typename T1,
17614           typename T2,
17615           typename T3,
17616           typename T4>
17617 AssertionResult AssertPred4Helper(const char* pred_text,
17618                                   const char* e1,
17619                                   const char* e2,
17620                                   const char* e3,
17621                                   const char* e4,
17622                                   Pred pred,
17623                                   const T1& v1,
17624                                   const T2& v2,
17625                                   const T3& v3,
17626                                   const T4& v4) {
17627   if (pred(v1, v2, v3, v4)) return AssertionSuccess();
17628 
17629   return AssertionFailure() << pred_text << "("
17630                             << e1 << ", "
17631                             << e2 << ", "
17632                             << e3 << ", "
17633                             << e4 << ") evaluates to false, where"
17634                             << "\n" << e1 << " evaluates to " << v1
17635                             << "\n" << e2 << " evaluates to " << v2
17636                             << "\n" << e3 << " evaluates to " << v3
17637                             << "\n" << e4 << " evaluates to " << v4;
17638 }
17639 
17640 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
17641 // Don't use this in your code.
17642 #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
17643   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
17644                 on_failure)
17645 
17646 // Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use
17647 // this in your code.
17648 #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
17649   GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
17650                                              #v1, \
17651                                              #v2, \
17652                                              #v3, \
17653                                              #v4, \
17654                                              pred, \
17655                                              v1, \
17656                                              v2, \
17657                                              v3, \
17658                                              v4), on_failure)
17659 
17660 // 4-ary predicate assertion macros.
17661 #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
17662   GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
17663 #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
17664   GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
17665 #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
17666   GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
17667 #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
17668   GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
17669 
17670 
17671 
17672 // Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use
17673 // this in your code.
17674 template <typename Pred,
17675           typename T1,
17676           typename T2,
17677           typename T3,
17678           typename T4,
17679           typename T5>
17680 AssertionResult AssertPred5Helper(const char* pred_text,
17681                                   const char* e1,
17682                                   const char* e2,
17683                                   const char* e3,
17684                                   const char* e4,
17685                                   const char* e5,
17686                                   Pred pred,
17687                                   const T1& v1,
17688                                   const T2& v2,
17689                                   const T3& v3,
17690                                   const T4& v4,
17691                                   const T5& v5) {
17692   if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
17693 
17694   return AssertionFailure() << pred_text << "("
17695                             << e1 << ", "
17696                             << e2 << ", "
17697                             << e3 << ", "
17698                             << e4 << ", "
17699                             << e5 << ") evaluates to false, where"
17700                             << "\n" << e1 << " evaluates to " << v1
17701                             << "\n" << e2 << " evaluates to " << v2
17702                             << "\n" << e3 << " evaluates to " << v3
17703                             << "\n" << e4 << " evaluates to " << v4
17704                             << "\n" << e5 << " evaluates to " << v5;
17705 }
17706 
17707 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
17708 // Don't use this in your code.
17709 #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
17710   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
17711                 on_failure)
17712 
17713 // Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use
17714 // this in your code.
17715 #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
17716   GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
17717                                              #v1, \
17718                                              #v2, \
17719                                              #v3, \
17720                                              #v4, \
17721                                              #v5, \
17722                                              pred, \
17723                                              v1, \
17724                                              v2, \
17725                                              v3, \
17726                                              v4, \
17727                                              v5), on_failure)
17728 
17729 // 5-ary predicate assertion macros.
17730 #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
17731   GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
17732 #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
17733   GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
17734 #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
17735   GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
17736 #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
17737   GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
17738 
17739 
17740 
17741 #endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
17742 
17743 // Macros for testing equalities and inequalities.
17744 //
17745 //    * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
17746 //    * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
17747 //    * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
17748 //    * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
17749 //    * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
17750 //    * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
17751 //
17752 // When they are not, Google Test prints both the tested expressions and
17753 // their actual values.  The values must be compatible built-in types,
17754 // or you will get a compiler error.  By "compatible" we mean that the
17755 // values can be compared by the respective operator.
17756 //
17757 // Note:
17758 //
17759 //   1. It is possible to make a user-defined type work with
17760 //   {ASSERT|EXPECT}_??(), but that requires overloading the
17761 //   comparison operators and is thus discouraged by the Google C++
17762 //   Usage Guide.  Therefore, you are advised to use the
17763 //   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
17764 //   equal.
17765 //
17766 //   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
17767 //   pointers (in particular, C strings).  Therefore, if you use it
17768 //   with two C strings, you are testing how their locations in memory
17769 //   are related, not how their content is related.  To compare two C
17770 //   strings by content, use {ASSERT|EXPECT}_STR*().
17771 //
17772 //   3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to
17773 //   {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you
17774 //   what the actual value is when it fails, and similarly for the
17775 //   other comparisons.
17776 //
17777 //   4. Do not depend on the order in which {ASSERT|EXPECT}_??()
17778 //   evaluate their arguments, which is undefined.
17779 //
17780 //   5. These macros evaluate their arguments exactly once.
17781 //
17782 // Examples:
17783 //
17784 //   EXPECT_NE(5, Foo());
17785 //   EXPECT_EQ(NULL, a_pointer);
17786 //   ASSERT_LT(i, array_size);
17787 //   ASSERT_GT(records.size(), 0) << "There is no record left.";
17788 
17789 #define EXPECT_EQ(val1, val2) \
17790   EXPECT_PRED_FORMAT2(::testing::internal:: \
17791                       EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
17792                       val1, val2)
17793 #define EXPECT_NE(val1, val2) \
17794   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
17795 #define EXPECT_LE(val1, val2) \
17796   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
17797 #define EXPECT_LT(val1, val2) \
17798   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
17799 #define EXPECT_GE(val1, val2) \
17800   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
17801 #define EXPECT_GT(val1, val2) \
17802   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
17803 
17804 #define GTEST_ASSERT_EQ(val1, val2) \
17805   ASSERT_PRED_FORMAT2(::testing::internal:: \
17806                       EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
17807                       val1, val2)
17808 #define GTEST_ASSERT_NE(val1, val2) \
17809   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
17810 #define GTEST_ASSERT_LE(val1, val2) \
17811   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
17812 #define GTEST_ASSERT_LT(val1, val2) \
17813   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
17814 #define GTEST_ASSERT_GE(val1, val2) \
17815   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
17816 #define GTEST_ASSERT_GT(val1, val2) \
17817   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
17818 
17819 // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
17820 // ASSERT_XY(), which clashes with some users' own code.
17821 
17822 #if !GTEST_DONT_DEFINE_ASSERT_EQ
17823 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
17824 #endif
17825 
17826 #if !GTEST_DONT_DEFINE_ASSERT_NE
17827 # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
17828 #endif
17829 
17830 #if !GTEST_DONT_DEFINE_ASSERT_LE
17831 # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
17832 #endif
17833 
17834 #if !GTEST_DONT_DEFINE_ASSERT_LT
17835 # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
17836 #endif
17837 
17838 #if !GTEST_DONT_DEFINE_ASSERT_GE
17839 # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
17840 #endif
17841 
17842 #if !GTEST_DONT_DEFINE_ASSERT_GT
17843 # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
17844 #endif
17845 
17846 // C-string Comparisons.  All tests treat NULL and any non-NULL string
17847 // as different.  Two NULLs are equal.
17848 //
17849 //    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2
17850 //    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2
17851 //    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
17852 //    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
17853 //
17854 // For wide or narrow string objects, you can use the
17855 // {ASSERT|EXPECT}_??() macros.
17856 //
17857 // Don't depend on the order in which the arguments are evaluated,
17858 // which is undefined.
17859 //
17860 // These macros evaluate their arguments exactly once.
17861 
17862 #define EXPECT_STREQ(s1, s2) \
17863   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
17864 #define EXPECT_STRNE(s1, s2) \
17865   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
17866 #define EXPECT_STRCASEEQ(s1, s2) \
17867   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
17868 #define EXPECT_STRCASENE(s1, s2)\
17869   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
17870 
17871 #define ASSERT_STREQ(s1, s2) \
17872   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
17873 #define ASSERT_STRNE(s1, s2) \
17874   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
17875 #define ASSERT_STRCASEEQ(s1, s2) \
17876   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
17877 #define ASSERT_STRCASENE(s1, s2)\
17878   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
17879 
17880 // Macros for comparing floating-point numbers.
17881 //
17882 //    * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):
17883 //         Tests that two float values are almost equal.
17884 //    * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):
17885 //         Tests that two double values are almost equal.
17886 //    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
17887 //         Tests that v1 and v2 are within the given distance to each other.
17888 //
17889 // Google Test uses ULP-based comparison to automatically pick a default
17890 // error bound that is appropriate for the operands.  See the
17891 // FloatingPoint template class in gtest-internal.h if you are
17892 // interested in the implementation details.
17893 
17894 #define EXPECT_FLOAT_EQ(val1, val2)\
17895   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
17896                       val1, val2)
17897 
17898 #define EXPECT_DOUBLE_EQ(val1, val2)\
17899   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
17900                       val1, val2)
17901 
17902 #define ASSERT_FLOAT_EQ(val1, val2)\
17903   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
17904                       val1, val2)
17905 
17906 #define ASSERT_DOUBLE_EQ(val1, val2)\
17907   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
17908                       val1, val2)
17909 
17910 #define EXPECT_NEAR(val1, val2, abs_error)\
17911   EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
17912                       val1, val2, abs_error)
17913 
17914 #define ASSERT_NEAR(val1, val2, abs_error)\
17915   ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
17916                       val1, val2, abs_error)
17917 
17918 // These predicate format functions work on floating-point values, and
17919 // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
17920 //
17921 //   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
17922 
17923 // Asserts that val1 is less than, or almost equal to, val2.  Fails
17924 // otherwise.  In particular, it fails if either val1 or val2 is NaN.
17925 GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
17926                                    float val1, float val2);
17927 GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
17928                                     double val1, double val2);
17929 
17930 
17931 #if GTEST_OS_WINDOWS
17932 
17933 // Macros that test for HRESULT failure and success, these are only useful
17934 // on Windows, and rely on Windows SDK macros and APIs to compile.
17935 //
17936 //    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
17937 //
17938 // When expr unexpectedly fails or succeeds, Google Test prints the
17939 // expected result and the actual result with both a human-readable
17940 // string representation of the error, if available, as well as the
17941 // hex result code.
17942 # define EXPECT_HRESULT_SUCCEEDED(expr) \
17943     EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
17944 
17945 # define ASSERT_HRESULT_SUCCEEDED(expr) \
17946     ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
17947 
17948 # define EXPECT_HRESULT_FAILED(expr) \
17949     EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
17950 
17951 # define ASSERT_HRESULT_FAILED(expr) \
17952     ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
17953 
17954 #endif  // GTEST_OS_WINDOWS
17955 
17956 // Macros that execute statement and check that it doesn't generate new fatal
17957 // failures in the current thread.
17958 //
17959 //   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
17960 //
17961 // Examples:
17962 //
17963 //   EXPECT_NO_FATAL_FAILURE(Process());
17964 //   ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
17965 //
17966 #define ASSERT_NO_FATAL_FAILURE(statement) \
17967     GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
17968 #define EXPECT_NO_FATAL_FAILURE(statement) \
17969     GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
17970 
17971 // Causes a trace (including the source file path, the current line
17972 // number, and the given message) to be included in every test failure
17973 // message generated by code in the current scope.  The effect is
17974 // undone when the control leaves the current scope.
17975 //
17976 // The message argument can be anything streamable to std::ostream.
17977 //
17978 // In the implementation, we include the current line number as part
17979 // of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
17980 // to appear in the same block - as long as they are on different
17981 // lines.
17982 #define SCOPED_TRACE(message) \
17983   ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
17984     __FILE__, __LINE__, ::testing::Message() << (message))
17985 
17986 // Compile-time assertion for type equality.
17987 // StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
17988 // the same type.  The value it returns is not interesting.
17989 //
17990 // Instead of making StaticAssertTypeEq a class template, we make it a
17991 // function template that invokes a helper class template.  This
17992 // prevents a user from misusing StaticAssertTypeEq<T1, T2> by
17993 // defining objects of that type.
17994 //
17995 // CAVEAT:
17996 //
17997 // When used inside a method of a class template,
17998 // StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
17999 // instantiated.  For example, given:
18000 //
18001 //   template <typename T> class Foo {
18002 //    public:
18003 //     void Bar() { testing::StaticAssertTypeEq<int, T>(); }
18004 //   };
18005 //
18006 // the code:
18007 //
18008 //   void Test1() { Foo<bool> foo; }
18009 //
18010 // will NOT generate a compiler error, as Foo<bool>::Bar() is never
18011 // actually instantiated.  Instead, you need:
18012 //
18013 //   void Test2() { Foo<bool> foo; foo.Bar(); }
18014 //
18015 // to cause a compiler error.
18016 template <typename T1, typename T2>
18017 bool StaticAssertTypeEq() {
18018   (void)internal::StaticAssertTypeEqHelper<T1, T2>();
18019   return true;
18020 }
18021 
18022 // Defines a test.
18023 //
18024 // The first parameter is the name of the test case, and the second
18025 // parameter is the name of the test within the test case.
18026 //
18027 // The convention is to end the test case name with "Test".  For
18028 // example, a test case for the Foo class can be named FooTest.
18029 //
18030 // Test code should appear between braces after an invocation of
18031 // this macro.  Example:
18032 //
18033 //   TEST(FooTest, InitializesCorrectly) {
18034 //     Foo foo;
18035 //     EXPECT_TRUE(foo.StatusIsOK());
18036 //   }
18037 
18038 // Note that we call GetTestTypeId() instead of GetTypeId<
18039 // ::testing::Test>() here to get the type ID of testing::Test.  This
18040 // is to work around a suspected linker bug when using Google Test as
18041 // a framework on Mac OS X.  The bug causes GetTypeId<
18042 // ::testing::Test>() to return different values depending on whether
18043 // the call is from the Google Test framework itself or from user test
18044 // code.  GetTestTypeId() is guaranteed to always return the same
18045 // value, as it always calls GetTypeId<>() from the Google Test
18046 // framework.
18047 #define GTEST_TEST(test_case_name, test_name)\
18048   GTEST_TEST_(test_case_name, test_name, \
18049               ::testing::Test, ::testing::internal::GetTestTypeId())
18050 
18051 // Define this macro to 1 to omit the definition of TEST(), which
18052 // is a generic name and clashes with some other libraries.
18053 #if !GTEST_DONT_DEFINE_TEST
18054 # define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
18055 #endif
18056 
18057 // Defines a test that uses a test fixture.
18058 //
18059 // The first parameter is the name of the test fixture class, which
18060 // also doubles as the test case name.  The second parameter is the
18061 // name of the test within the test case.
18062 //
18063 // A test fixture class must be declared earlier.  The user should put
18064 // his test code between braces after using this macro.  Example:
18065 //
18066 //   class FooTest : public testing::Test {
18067 //    protected:
18068 //     virtual void SetUp() { b_.AddElement(3); }
18069 //
18070 //     Foo a_;
18071 //     Foo b_;
18072 //   };
18073 //
18074 //   TEST_F(FooTest, InitializesCorrectly) {
18075 //     EXPECT_TRUE(a_.StatusIsOK());
18076 //   }
18077 //
18078 //   TEST_F(FooTest, ReturnsElementCountCorrectly) {
18079 //     EXPECT_EQ(0, a_.size());
18080 //     EXPECT_EQ(1, b_.size());
18081 //   }
18082 
18083 #define TEST_F(test_fixture, test_name)\
18084   GTEST_TEST_(test_fixture, test_name, test_fixture, \
18085               ::testing::internal::GetTypeId<test_fixture>())
18086 
18087 }  // namespace testing
18088 
18089 // Use this function in main() to run all tests.  It returns 0 if all
18090 // tests are successful, or 1 otherwise.
18091 //
18092 // RUN_ALL_TESTS() should be invoked after the command line has been
18093 // parsed by InitGoogleTest().
18094 //
18095 // This function was formerly a macro; thus, it is in the global
18096 // namespace and has an all-caps name.
18097 int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
18098 
18099 inline int RUN_ALL_TESTS() {
18100   return ::testing::UnitTest::GetInstance()->Run();
18101 }
18102 
18103 #endif  // GTEST_INCLUDE_GTEST_GTEST_H_
18104