• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
31 // The Google C++ Testing and Mocking Framework (Google Test)
32 //
33 // This header file defines the public API for Google Test.  It should be
34 // included by any test program that uses Google Test.
35 //
36 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
37 // leave some internal implementation details in this header file.
38 // They are clearly marked by comments like this:
39 //
40 //   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
41 //
42 // Such code is NOT meant to be used by a user directly, and is subject
43 // to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
44 // program!
45 //
46 // Acknowledgment: Google Test borrowed the idea of automatic test
47 // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
48 // easyUnit framework.
49 
50 // GOOGLETEST_CM0001 DO NOT DELETE
51 
52 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
53 #define GTEST_INCLUDE_GTEST_GTEST_H_
54 
55 #include <cstddef>
56 #include <limits>
57 #include <memory>
58 #include <ostream>
59 #include <type_traits>
60 #include <vector>
61 
62 // Copyright 2005, Google Inc.
63 // All rights reserved.
64 //
65 // Redistribution and use in source and binary forms, with or without
66 // modification, are permitted provided that the following conditions are
67 // met:
68 //
69 //     * Redistributions of source code must retain the above copyright
70 // notice, this list of conditions and the following disclaimer.
71 //     * Redistributions in binary form must reproduce the above
72 // copyright notice, this list of conditions and the following disclaimer
73 // in the documentation and/or other materials provided with the
74 // distribution.
75 //     * Neither the name of Google Inc. nor the names of its
76 // contributors may be used to endorse or promote products derived from
77 // this software without specific prior written permission.
78 //
79 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
80 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
81 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
82 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
83 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
84 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
85 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
89 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90 //
91 // The Google C++ Testing and Mocking Framework (Google Test)
92 //
93 // This header file declares functions and macros used internally by
94 // Google Test.  They are subject to change without notice.
95 
96 // GOOGLETEST_CM0001 DO NOT DELETE
97 
98 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
99 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
100 
101 // Copyright 2005, Google Inc.
102 // All rights reserved.
103 //
104 // Redistribution and use in source and binary forms, with or without
105 // modification, are permitted provided that the following conditions are
106 // met:
107 //
108 //     * Redistributions of source code must retain the above copyright
109 // notice, this list of conditions and the following disclaimer.
110 //     * Redistributions in binary form must reproduce the above
111 // copyright notice, this list of conditions and the following disclaimer
112 // in the documentation and/or other materials provided with the
113 // distribution.
114 //     * Neither the name of Google Inc. nor the names of its
115 // contributors may be used to endorse or promote products derived from
116 // this software without specific prior written permission.
117 //
118 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
119 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
120 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
121 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
122 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
123 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
124 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
125 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
126 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
127 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
128 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
129 //
130 // Low-level types and utilities for porting Google Test to various
131 // platforms.  All macros ending with _ and symbols defined in an
132 // internal namespace are subject to change without notice.  Code
133 // outside Google Test MUST NOT USE THEM DIRECTLY.  Macros that don't
134 // end with _ are part of Google Test's public API and can be used by
135 // code outside Google Test.
136 //
137 // This file is fundamental to Google Test.  All other Google Test source
138 // files are expected to #include this.  Therefore, it cannot #include
139 // any other Google Test header.
140 
141 // GOOGLETEST_CM0001 DO NOT DELETE
142 
143 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
144 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
145 
146 // Environment-describing macros
147 // -----------------------------
148 //
149 // Google Test can be used in many different environments.  Macros in
150 // this section tell Google Test what kind of environment it is being
151 // used in, such that Google Test can provide environment-specific
152 // features and implementations.
153 //
154 // Google Test tries to automatically detect the properties of its
155 // environment, so users usually don't need to worry about these
156 // macros.  However, the automatic detection is not perfect.
157 // Sometimes it's necessary for a user to define some of the following
158 // macros in the build script to override Google Test's decisions.
159 //
160 // If the user doesn't define a macro in the list, Google Test will
161 // provide a default definition.  After this header is #included, all
162 // macros in this list will be defined to either 1 or 0.
163 //
164 // Notes to maintainers:
165 //   - Each macro here is a user-tweakable knob; do not grow the list
166 //     lightly.
167 //   - Use #if to key off these macros.  Don't use #ifdef or "#if
168 //     defined(...)", which will not work as these macros are ALWAYS
169 //     defined.
170 //
171 //   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
172 //                              is/isn't available.
173 //   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
174 //                              are enabled.
175 //   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular
176 //                              expressions are/aren't available.
177 //   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>
178 //                              is/isn't available.
179 //   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
180 //                              enabled.
181 //   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
182 //                              std::wstring does/doesn't work (Google Test can
183 //                              be used where std::wstring is unavailable).
184 //   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
185 //                              compiler supports Microsoft's "Structured
186 //                              Exception Handling".
187 //   GTEST_HAS_STREAM_REDIRECTION
188 //                            - Define it to 1/0 to indicate whether the
189 //                              platform supports I/O stream redirection using
190 //                              dup() and dup2().
191 //   GTEST_LINKED_AS_SHARED_LIBRARY
192 //                            - Define to 1 when compiling tests that use
193 //                              Google Test as a shared library (known as
194 //                              DLL on Windows).
195 //   GTEST_CREATE_SHARED_LIBRARY
196 //                            - Define to 1 when compiling Google Test itself
197 //                              as a shared library.
198 //   GTEST_DEFAULT_DEATH_TEST_STYLE
199 //                            - The default value of --gtest_death_test_style.
200 //                              The legacy default has been "fast" in the open
201 //                              source version since 2008. The recommended value
202 //                              is "threadsafe", and can be set in
203 //                              custom/gtest-port.h.
204 
205 // Platform-indicating macros
206 // --------------------------
207 //
208 // Macros indicating the platform on which Google Test is being used
209 // (a macro is defined to 1 if compiled on the given platform;
210 // otherwise UNDEFINED -- it's never defined to 0.).  Google Test
211 // defines these macros automatically.  Code outside Google Test MUST
212 // NOT define them.
213 //
214 //   GTEST_OS_AIX      - IBM AIX
215 //   GTEST_OS_CYGWIN   - Cygwin
216 //   GTEST_OS_DRAGONFLY - DragonFlyBSD
217 //   GTEST_OS_FREEBSD  - FreeBSD
218 //   GTEST_OS_FUCHSIA  - Fuchsia
219 //   GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
220 //   GTEST_OS_HAIKU    - Haiku
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_NETBSD   - NetBSD
228 //   GTEST_OS_OPENBSD  - OpenBSD
229 //   GTEST_OS_OS2      - OS/2
230 //   GTEST_OS_QNX      - QNX
231 //   GTEST_OS_SOLARIS  - Sun Solaris
232 //   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
233 //     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
234 //     GTEST_OS_WINDOWS_MINGW    - MinGW
235 //     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
236 //     GTEST_OS_WINDOWS_PHONE    - Windows Phone
237 //     GTEST_OS_WINDOWS_RT       - Windows Store App/WinRT
238 //   GTEST_OS_ZOS      - z/OS
239 //
240 // Among the platforms, Cygwin, Linux, Mac OS X, and Windows have the
241 // most stable support.  Since core members of the Google Test project
242 // don't have access to other platforms, support for them may be less
243 // stable.  If you notice any problems on your platform, please notify
244 // googletestframework@googlegroups.com (patches for fixing them are
245 // even more welcome!).
246 //
247 // It is possible that none of the GTEST_OS_* macros are defined.
248 
249 // Feature-indicating macros
250 // -------------------------
251 //
252 // Macros indicating which Google Test features are available (a macro
253 // is defined to 1 if the corresponding feature is supported;
254 // otherwise UNDEFINED -- it's never defined to 0.).  Google Test
255 // defines these macros automatically.  Code outside Google Test MUST
256 // NOT define them.
257 //
258 // These macros are public so that portable tests can be written.
259 // Such tests typically surround code using a feature with an #if
260 // which controls that code.  For example:
261 //
262 // #if GTEST_HAS_DEATH_TEST
263 //   EXPECT_DEATH(DoSomethingDeadly());
264 // #endif
265 //
266 //   GTEST_HAS_DEATH_TEST   - death tests
267 //   GTEST_HAS_TYPED_TEST   - typed tests
268 //   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
269 //   GTEST_IS_THREADSAFE    - Google Test is thread-safe.
270 //   GOOGLETEST_CM0007 DO NOT DELETE
271 //   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with
272 //                            GTEST_HAS_POSIX_RE (see above) which users can
273 //                            define themselves.
274 //   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
275 //                            the above RE\b(s) are mutually exclusive.
276 
277 // Misc public macros
278 // ------------------
279 //
280 //   GTEST_FLAG(flag_name)  - references the variable corresponding to
281 //                            the given Google Test flag.
282 
283 // Internal utilities
284 // ------------------
285 //
286 // The following macros and utilities are for Google Test's INTERNAL
287 // use only.  Code outside Google Test MUST NOT USE THEM DIRECTLY.
288 //
289 // Macros for basic C++ coding:
290 //   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
291 //   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
292 //                              variable don't have to be used.
293 //   GTEST_DISALLOW_ASSIGN_   - disables operator=.
294 //   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
295 //   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
296 //   GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
297 //                                        suppressed (constant conditional).
298 //   GTEST_INTENTIONAL_CONST_COND_POP_  - finish code section where MSVC C4127
299 //                                        is suppressed.
300 //
301 // Synchronization:
302 //   Mutex, MutexLock, ThreadLocal, GetThreadCount()
303 //                            - synchronization primitives.
304 //
305 // Template meta programming:
306 //   IteratorTraits - partial implementation of std::iterator_traits, which
307 //                    is not available in libCstd when compiled with Sun C++.
308 //
309 //
310 // Regular expressions:
311 //   RE             - a simple regular expression class using the POSIX
312 //                    Extended Regular Expression syntax on UNIX-like platforms
313 //                    GOOGLETEST_CM0008 DO NOT DELETE
314 //                    or a reduced regular exception syntax on other
315 //                    platforms, including Windows.
316 // Logging:
317 //   GTEST_LOG_()   - logs messages at the specified severity level.
318 //   LogToStderr()  - directs all log messages to stderr.
319 //   FlushInfoLog() - flushes informational log messages.
320 //
321 // Stdout and stderr capturing:
322 //   CaptureStdout()     - starts capturing stdout.
323 //   GetCapturedStdout() - stops capturing stdout and returns the captured
324 //                         string.
325 //   CaptureStderr()     - starts capturing stderr.
326 //   GetCapturedStderr() - stops capturing stderr and returns the captured
327 //                         string.
328 //
329 // Integer types:
330 //   TypeWithSize   - maps an integer to a int type.
331 //   Int32, UInt32, Int64, UInt64, TimeInMillis
332 //                  - integers of known sizes.
333 //   BiggestInt     - the biggest signed integer type.
334 //
335 // Command-line utilities:
336 //   GTEST_DECLARE_*()  - declares a flag.
337 //   GTEST_DEFINE_*()   - defines a flag.
338 //   GetInjectableArgvs() - returns the command line as a vector of strings.
339 //
340 // Environment variable utilities:
341 //   GetEnv()             - gets the value of an environment variable.
342 //   BoolFromGTestEnv()   - parses a bool environment variable.
343 //   Int32FromGTestEnv()  - parses an Int32 environment variable.
344 //   StringFromGTestEnv() - parses a string environment variable.
345 //
346 // Deprecation warnings:
347 //   GTEST_INTERNAL_DEPRECATED(message) - attribute marking a function as
348 //                                        deprecated; calling a marked function
349 //                                        should generate a compiler warning
350 
351 #include <ctype.h>   // for isspace, etc
352 #include <stddef.h>  // for ptrdiff_t
353 #include <stdio.h>
354 #include <stdlib.h>
355 #include <string.h>
356 #include <memory>
357 #include <type_traits>
358 
359 #ifndef _WIN32_WCE
360 # include <sys/types.h>
361 # include <sys/stat.h>
362 #endif  // !_WIN32_WCE
363 
364 #if defined __APPLE__
365 # include <AvailabilityMacros.h>
366 # include <TargetConditionals.h>
367 #endif
368 
369 #include <algorithm>  // NOLINT
370 #include <iostream>   // NOLINT
371 #include <sstream>    // NOLINT
372 #include <string>     // NOLINT
373 #include <tuple>
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 and Mocking 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(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
418 #  define GTEST_OS_WINDOWS_MINGW 1
419 #  define GTEST_OS_WINDOWS 1
420 #elif defined _WIN32
421 # define GTEST_OS_WINDOWS 1
422 # ifdef _WIN32_WCE
423 #  define GTEST_OS_WINDOWS_MOBILE 1
424 # elif defined(WINAPI_FAMILY)
425 #  include <winapifamily.h>
426 #  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
427 #   define GTEST_OS_WINDOWS_DESKTOP 1
428 #  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
429 #   define GTEST_OS_WINDOWS_PHONE 1
430 #  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
431 #   define GTEST_OS_WINDOWS_RT 1
432 #  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
433 #   define GTEST_OS_WINDOWS_PHONE 1
434 #   define GTEST_OS_WINDOWS_TV_TITLE 1
435 #  else
436     // WINAPI_FAMILY defined but no known partition matched.
437     // Default to desktop.
438 #   define GTEST_OS_WINDOWS_DESKTOP 1
439 #  endif
440 # else
441 #  define GTEST_OS_WINDOWS_DESKTOP 1
442 # endif  // _WIN32_WCE
443 #elif defined __OS2__
444 # define GTEST_OS_OS2 1
445 #elif defined __APPLE__
446 # define GTEST_OS_MAC 1
447 # if TARGET_OS_IPHONE
448 #  define GTEST_OS_IOS 1
449 # endif
450 #elif defined __DragonFly__
451 # define GTEST_OS_DRAGONFLY 1
452 #elif defined __FreeBSD__
453 # define GTEST_OS_FREEBSD 1
454 #elif defined __Fuchsia__
455 # define GTEST_OS_FUCHSIA 1
456 #elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
457 # define GTEST_OS_GNU_KFREEBSD 1
458 #elif defined __linux__
459 # define GTEST_OS_LINUX 1
460 # if defined __ANDROID__
461 #  define GTEST_OS_LINUX_ANDROID 1
462 # endif
463 #elif defined __MVS__
464 # define GTEST_OS_ZOS 1
465 #elif defined(__sun) && defined(__SVR4)
466 # define GTEST_OS_SOLARIS 1
467 #elif defined(_AIX)
468 # define GTEST_OS_AIX 1
469 #elif defined(__hpux)
470 # define GTEST_OS_HPUX 1
471 #elif defined __native_client__
472 # define GTEST_OS_NACL 1
473 #elif defined __NetBSD__
474 # define GTEST_OS_NETBSD 1
475 #elif defined __OpenBSD__
476 # define GTEST_OS_OPENBSD 1
477 #elif defined __QNX__
478 # define GTEST_OS_QNX 1
479 #elif defined(__HAIKU__)
480 #define GTEST_OS_HAIKU 1
481 #endif  // __CYGWIN__
482 
483 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
484 // Copyright 2015, Google Inc.
485 // All rights reserved.
486 //
487 // Redistribution and use in source and binary forms, with or without
488 // modification, are permitted provided that the following conditions are
489 // met:
490 //
491 //     * Redistributions of source code must retain the above copyright
492 // notice, this list of conditions and the following disclaimer.
493 //     * Redistributions in binary form must reproduce the above
494 // copyright notice, this list of conditions and the following disclaimer
495 // in the documentation and/or other materials provided with the
496 // distribution.
497 //     * Neither the name of Google Inc. nor the names of its
498 // contributors may be used to endorse or promote products derived from
499 // this software without specific prior written permission.
500 //
501 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
502 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
503 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
504 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
505 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
506 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
507 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
508 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
509 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
510 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
511 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
512 //
513 // Injection point for custom user configurations. See README for details
514 //
515 // ** Custom implementation starts here **
516 
517 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
518 #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
519 
520 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
521 
522 #if !defined(GTEST_DEV_EMAIL_)
523 # define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
524 # define GTEST_FLAG_PREFIX_ "gtest_"
525 # define GTEST_FLAG_PREFIX_DASH_ "gtest-"
526 # define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
527 # define GTEST_NAME_ "Google Test"
528 # define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
529 #endif  // !defined(GTEST_DEV_EMAIL_)
530 
531 #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
532 # define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
533 #endif  // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
534 
535 // Determines the version of gcc that is used to compile this.
536 #ifdef __GNUC__
537 // 40302 means version 4.3.2.
538 # define GTEST_GCC_VER_ \
539     (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
540 #endif  // __GNUC__
541 
542 // Macros for disabling Microsoft Visual C++ warnings.
543 //
544 //   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
545 //   /* code that triggers warnings C4800 and C4385 */
546 //   GTEST_DISABLE_MSC_WARNINGS_POP_()
547 #if defined(_MSC_VER)
548 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
549     __pragma(warning(push))                        \
550     __pragma(warning(disable: warnings))
551 # define GTEST_DISABLE_MSC_WARNINGS_POP_()          \
552     __pragma(warning(pop))
553 #else
554 // Not all compilers are MSVC
555 # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
556 # define GTEST_DISABLE_MSC_WARNINGS_POP_()
557 #endif
558 
559 // Clang on Windows does not understand MSVC's pragma warning.
560 // We need clang-specific way to disable function deprecation warning.
561 #ifdef __clang__
562 # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_()                         \
563     _Pragma("clang diagnostic push")                                  \
564     _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
565     _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
566 #define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
567     _Pragma("clang diagnostic pop")
568 #else
569 # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
570     GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
571 # define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
572     GTEST_DISABLE_MSC_WARNINGS_POP_()
573 #endif
574 
575 // Brings in definitions for functions used in the testing::internal::posix
576 // namespace (read, write, close, chdir, isatty, stat). We do not currently
577 // use them on Windows Mobile.
578 #if GTEST_OS_WINDOWS
579 # if !GTEST_OS_WINDOWS_MOBILE
580 #  include <direct.h>
581 #  include <io.h>
582 # endif
583 // In order to avoid having to include <windows.h>, use forward declaration
584 #if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
585 // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
586 // separate (equivalent) structs, instead of using typedef
587 typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
588 #else
589 // Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
590 // This assumption is verified by
591 // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
592 typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
593 #endif
594 #else
595 // This assumes that non-Windows OSes provide unistd.h. For OSes where this
596 // is not the case, we need to include headers that provide the functions
597 // mentioned above.
598 # include <unistd.h>
599 # include <strings.h>
600 #endif  // GTEST_OS_WINDOWS
601 
602 #if GTEST_OS_LINUX_ANDROID
603 // Used to define __ANDROID_API__ matching the target NDK API level.
604 #  include <android/api-level.h>  // NOLINT
605 #endif
606 
607 // Defines this to true iff Google Test can use POSIX regular expressions.
608 #ifndef GTEST_HAS_POSIX_RE
609 # if GTEST_OS_LINUX_ANDROID
610 // On Android, <regex.h> is only available starting with Gingerbread.
611 #  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
612 # else
613 #  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
614 # endif
615 #endif
616 
617 #if GTEST_USES_PCRE
618 // The appropriate headers have already been included.
619 
620 #elif GTEST_HAS_POSIX_RE
621 
622 // On some platforms, <regex.h> needs someone to define size_t, and
623 // won't compile otherwise.  We can #include it here as we already
624 // included <stdlib.h>, which is guaranteed to define size_t through
625 // <stddef.h>.
626 # include <regex.h>  // NOLINT
627 
628 # define GTEST_USES_POSIX_RE 1
629 
630 #elif GTEST_OS_WINDOWS
631 
632 // <regex.h> is not available on Windows.  Use our own simple regex
633 // implementation instead.
634 # define GTEST_USES_SIMPLE_RE 1
635 
636 #else
637 
638 // <regex.h> may not be available on this platform.  Use our own
639 // simple regex implementation instead.
640 # define GTEST_USES_SIMPLE_RE 1
641 
642 #endif  // GTEST_USES_PCRE
643 
644 #ifndef GTEST_HAS_EXCEPTIONS
645 // The user didn't tell us whether exceptions are enabled, so we need
646 // to figure it out.
647 # if defined(_MSC_VER) && defined(_CPPUNWIND)
648 // MSVC defines _CPPUNWIND to 1 iff exceptions are enabled.
649 #  define GTEST_HAS_EXCEPTIONS 1
650 # elif defined(__BORLANDC__)
651 // C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
652 // macro to enable exceptions, so we'll do the same.
653 // Assumes that exceptions are enabled by default.
654 #  ifndef _HAS_EXCEPTIONS
655 #   define _HAS_EXCEPTIONS 1
656 #  endif  // _HAS_EXCEPTIONS
657 #  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
658 # elif defined(__clang__)
659 // clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,
660 // but iff cleanups are enabled after that. In Obj-C++ files, there can be
661 // cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
662 // are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
663 // exceptions starting at clang r206352, but which checked for cleanups prior to
664 // that. To reliably check for C++ exception availability with clang, check for
665 // __EXCEPTIONS && __has_feature(cxx_exceptions).
666 #  define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
667 # elif defined(__GNUC__) && __EXCEPTIONS
668 // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
669 #  define GTEST_HAS_EXCEPTIONS 1
670 # elif defined(__SUNPRO_CC)
671 // Sun Pro CC supports exceptions.  However, there is no compile-time way of
672 // detecting whether they are enabled or not.  Therefore, we assume that
673 // they are enabled unless the user tells us otherwise.
674 #  define GTEST_HAS_EXCEPTIONS 1
675 # elif defined(__IBMCPP__) && __EXCEPTIONS
676 // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
677 #  define GTEST_HAS_EXCEPTIONS 1
678 # elif defined(__HP_aCC)
679 // Exception handling is in effect by default in HP aCC compiler. It has to
680 // be turned of by +noeh compiler option if desired.
681 #  define GTEST_HAS_EXCEPTIONS 1
682 # else
683 // For other compilers, we assume exceptions are disabled to be
684 // conservative.
685 #  define GTEST_HAS_EXCEPTIONS 0
686 # endif  // defined(_MSC_VER) || defined(__BORLANDC__)
687 #endif  // GTEST_HAS_EXCEPTIONS
688 
689 #if !defined(GTEST_HAS_STD_STRING)
690 // Even though we don't use this macro any longer, we keep it in case
691 // some clients still depend on it.
692 # define GTEST_HAS_STD_STRING 1
693 #elif !GTEST_HAS_STD_STRING
694 // The user told us that ::std::string isn't available.
695 # error "::std::string isn't available."
696 #endif  // !defined(GTEST_HAS_STD_STRING)
697 
698 #ifndef GTEST_HAS_STD_WSTRING
699 // The user didn't tell us whether ::std::wstring is available, so we need
700 // to figure it out.
701 // Cygwin 1.7 and below doesn't support ::std::wstring.
702 // Solaris' libc++ doesn't support it either.  Android has
703 // no support for it at least as recent as Froyo (2.2).
704 #define GTEST_HAS_STD_WSTRING                                         \
705   (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
706      GTEST_OS_HAIKU))
707 
708 #endif  // GTEST_HAS_STD_WSTRING
709 
710 // Determines whether RTTI is available.
711 #ifndef GTEST_HAS_RTTI
712 // The user didn't tell us whether RTTI is enabled, so we need to
713 // figure it out.
714 
715 # ifdef _MSC_VER
716 
717 #  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
718 #   define GTEST_HAS_RTTI 1
719 #  else
720 #   define GTEST_HAS_RTTI 0
721 #  endif
722 
723 // Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
724 # elif defined(__GNUC__)
725 
726 #  ifdef __GXX_RTTI
727 // When building against STLport with the Android NDK and with
728 // -frtti -fno-exceptions, the build fails at link time with undefined
729 // references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
730 // so disable RTTI when detected.
731 #   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
732        !defined(__EXCEPTIONS)
733 #    define GTEST_HAS_RTTI 0
734 #   else
735 #    define GTEST_HAS_RTTI 1
736 #   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
737 #  else
738 #   define GTEST_HAS_RTTI 0
739 #  endif  // __GXX_RTTI
740 
741 // Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
742 // using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
743 // first version with C++ support.
744 # elif defined(__clang__)
745 
746 #  define GTEST_HAS_RTTI __has_feature(cxx_rtti)
747 
748 // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
749 // both the typeid and dynamic_cast features are present.
750 # elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
751 
752 #  ifdef __RTTI_ALL__
753 #   define GTEST_HAS_RTTI 1
754 #  else
755 #   define GTEST_HAS_RTTI 0
756 #  endif
757 
758 # else
759 
760 // For all other compilers, we assume RTTI is enabled.
761 #  define GTEST_HAS_RTTI 1
762 
763 # endif  // _MSC_VER
764 
765 #endif  // GTEST_HAS_RTTI
766 
767 // It's this header's responsibility to #include <typeinfo> when RTTI
768 // is enabled.
769 #if GTEST_HAS_RTTI
770 # include <typeinfo>
771 #endif
772 
773 // Determines whether Google Test can use the pthreads library.
774 #ifndef GTEST_HAS_PTHREAD
775 // The user didn't tell us explicitly, so we make reasonable assumptions about
776 // which platforms have pthreads support.
777 //
778 // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
779 // to your compiler flags.
780 #define GTEST_HAS_PTHREAD                                                      \
781   (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX ||          \
782    GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
783    GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD ||          \
784    GTEST_OS_HAIKU)
785 #endif  // GTEST_HAS_PTHREAD
786 
787 #if GTEST_HAS_PTHREAD
788 // gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
789 // true.
790 # include <pthread.h>  // NOLINT
791 
792 // For timespec and nanosleep, used below.
793 # include <time.h>  // NOLINT
794 #endif
795 
796 // Determines whether clone(2) is supported.
797 // Usually it will only be available on Linux, excluding
798 // Linux on the Itanium architecture.
799 // Also see http://linux.die.net/man/2/clone.
800 #ifndef GTEST_HAS_CLONE
801 // The user didn't tell us, so we need to figure it out.
802 
803 # if GTEST_OS_LINUX && !defined(__ia64__)
804 #  if GTEST_OS_LINUX_ANDROID
805 // On Android, clone() became available at different API levels for each 32-bit
806 // architecture.
807 #    if defined(__LP64__) || \
808         (defined(__arm__) && __ANDROID_API__ >= 9) || \
809         (defined(__mips__) && __ANDROID_API__ >= 12) || \
810         (defined(__i386__) && __ANDROID_API__ >= 17)
811 #     define GTEST_HAS_CLONE 1
812 #    else
813 #     define GTEST_HAS_CLONE 0
814 #    endif
815 #  else
816 #   define GTEST_HAS_CLONE 1
817 #  endif
818 # else
819 #  define GTEST_HAS_CLONE 0
820 # endif  // GTEST_OS_LINUX && !defined(__ia64__)
821 
822 #endif  // GTEST_HAS_CLONE
823 
824 // Determines whether to support stream redirection. This is used to test
825 // output correctness and to implement death tests.
826 #ifndef GTEST_HAS_STREAM_REDIRECTION
827 // By default, we assume that stream redirection is supported on all
828 // platforms except known mobile ones.
829 # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
830 #  define GTEST_HAS_STREAM_REDIRECTION 0
831 # else
832 #  define GTEST_HAS_STREAM_REDIRECTION 1
833 # endif  // !GTEST_OS_WINDOWS_MOBILE
834 #endif  // GTEST_HAS_STREAM_REDIRECTION
835 
836 // Determines whether to support death tests.
837 // pops up a dialog window that cannot be suppressed programmatically.
838 #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS ||             \
839      (GTEST_OS_MAC && !GTEST_OS_IOS) ||                                   \
840      (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW ||  \
841      GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \
842      GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA ||           \
843      GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU)
844 # define GTEST_HAS_DEATH_TEST 1
845 #endif
846 
847 // Determines whether to support type-driven tests.
848 
849 // Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
850 // Sun Pro CC, IBM Visual Age, and HP aCC support.
851 #if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
852     defined(__IBMCPP__) || defined(__HP_aCC)
853 # define GTEST_HAS_TYPED_TEST 1
854 # define GTEST_HAS_TYPED_TEST_P 1
855 #endif
856 
857 // Determines whether the system compiler uses UTF-16 for encoding wide strings.
858 #define GTEST_WIDE_STRING_USES_UTF16_ \
859   (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
860 
861 // Determines whether test results can be streamed to a socket.
862 #if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \
863     GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
864 # define GTEST_CAN_STREAM_RESULTS_ 1
865 #endif
866 
867 // Defines some utility macros.
868 
869 // The GNU compiler emits a warning if nested "if" statements are followed by
870 // an "else" statement and braces are not used to explicitly disambiguate the
871 // "else" binding.  This leads to problems with code like:
872 //
873 //   if (gate)
874 //     ASSERT_*(condition) << "Some message";
875 //
876 // The "switch (0) case 0:" idiom is used to suppress this.
877 #ifdef __INTEL_COMPILER
878 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
879 #else
880 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
881 #endif
882 
883 // Use this annotation at the end of a struct/class definition to
884 // prevent the compiler from optimizing away instances that are never
885 // used.  This is useful when all interesting logic happens inside the
886 // c'tor and / or d'tor.  Example:
887 //
888 //   struct Foo {
889 //     Foo() { ... }
890 //   } GTEST_ATTRIBUTE_UNUSED_;
891 //
892 // Also use it after a variable or parameter declaration to tell the
893 // compiler the variable/parameter does not have to be used.
894 #if defined(__GNUC__) && !defined(COMPILER_ICC)
895 # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
896 #elif defined(__clang__)
897 # if __has_attribute(unused)
898 #  define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
899 # endif
900 #endif
901 #ifndef GTEST_ATTRIBUTE_UNUSED_
902 # define GTEST_ATTRIBUTE_UNUSED_
903 #endif
904 
905 // Use this annotation before a function that takes a printf format string.
906 #if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)
907 # if defined(__MINGW_PRINTF_FORMAT)
908 // MinGW has two different printf implementations. Ensure the format macro
909 // matches the selected implementation. See
910 // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
911 #  define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
912        __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \
913                                  first_to_check)))
914 # else
915 #  define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
916        __attribute__((__format__(__printf__, string_index, first_to_check)))
917 # endif
918 #else
919 # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
920 #endif
921 
922 
923 // A macro to disallow operator=
924 // This should be used in the private: declarations for a class.
925 #define GTEST_DISALLOW_ASSIGN_(type) \
926   void operator=(type const &) = delete
927 
928 // A macro to disallow copy constructor and operator=
929 // This should be used in the private: declarations for a class.
930 #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
931   type(type const &) = delete; \
932   GTEST_DISALLOW_ASSIGN_(type)
933 
934 // Tell the compiler to warn about unused return values for functions declared
935 // with this macro.  The macro should be used on function declarations
936 // following the argument list:
937 //
938 //   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
939 #if defined(__GNUC__) && !defined(COMPILER_ICC)
940 # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
941 #else
942 # define GTEST_MUST_USE_RESULT_
943 #endif  // __GNUC__ && !COMPILER_ICC
944 
945 // MS C++ compiler emits warning when a conditional expression is compile time
946 // constant. In some contexts this warning is false positive and needs to be
947 // suppressed. Use the following two macros in such cases:
948 //
949 // GTEST_INTENTIONAL_CONST_COND_PUSH_()
950 // while (true) {
951 // GTEST_INTENTIONAL_CONST_COND_POP_()
952 // }
953 # define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
954     GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
955 # define GTEST_INTENTIONAL_CONST_COND_POP_() \
956     GTEST_DISABLE_MSC_WARNINGS_POP_()
957 
958 // Determine whether the compiler supports Microsoft's Structured Exception
959 // Handling.  This is supported by several Windows compilers but generally
960 // does not exist on any other system.
961 #ifndef GTEST_HAS_SEH
962 // The user didn't tell us, so we need to figure it out.
963 
964 # if defined(_MSC_VER) || defined(__BORLANDC__)
965 // These two compilers are known to support SEH.
966 #  define GTEST_HAS_SEH 1
967 # else
968 // Assume no SEH.
969 #  define GTEST_HAS_SEH 0
970 # endif
971 
972 #endif  // GTEST_HAS_SEH
973 
974 #ifndef GTEST_IS_THREADSAFE
975 
976 #define GTEST_IS_THREADSAFE                                                 \
977   (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ ||                                     \
978    (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \
979    GTEST_HAS_PTHREAD)
980 
981 #endif  // GTEST_IS_THREADSAFE
982 
983 // GTEST_API_ qualifies all symbols that must be exported. The definitions below
984 // are guarded by #ifndef to give embedders a chance to define GTEST_API_ in
985 // gtest/internal/custom/gtest-port.h
986 #ifndef GTEST_API_
987 
988 #ifdef _MSC_VER
989 # if GTEST_LINKED_AS_SHARED_LIBRARY
990 #  define GTEST_API_ __declspec(dllimport)
991 # elif GTEST_CREATE_SHARED_LIBRARY
992 #  define GTEST_API_ __declspec(dllexport)
993 # endif
994 #elif __GNUC__ >= 4 || defined(__clang__)
995 # define GTEST_API_ __attribute__((visibility ("default")))
996 #endif  // _MSC_VER
997 
998 #endif  // GTEST_API_
999 
1000 #ifndef GTEST_API_
1001 # define GTEST_API_
1002 #endif  // GTEST_API_
1003 
1004 #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
1005 # define GTEST_DEFAULT_DEATH_TEST_STYLE  "fast"
1006 #endif  // GTEST_DEFAULT_DEATH_TEST_STYLE
1007 
1008 #ifdef __GNUC__
1009 // Ask the compiler to never inline a given function.
1010 # define GTEST_NO_INLINE_ __attribute__((noinline))
1011 #else
1012 # define GTEST_NO_INLINE_
1013 #endif
1014 
1015 // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
1016 #if !defined(GTEST_HAS_CXXABI_H_)
1017 # if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
1018 #  define GTEST_HAS_CXXABI_H_ 1
1019 # else
1020 #  define GTEST_HAS_CXXABI_H_ 0
1021 # endif
1022 #endif
1023 
1024 // A function level attribute to disable checking for use of uninitialized
1025 // memory when built with MemorySanitizer.
1026 #if defined(__clang__)
1027 # if __has_feature(memory_sanitizer)
1028 #  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
1029        __attribute__((no_sanitize_memory))
1030 # else
1031 #  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
1032 # endif  // __has_feature(memory_sanitizer)
1033 #else
1034 # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
1035 #endif  // __clang__
1036 
1037 // A function level attribute to disable AddressSanitizer instrumentation.
1038 #if defined(__clang__)
1039 # if __has_feature(address_sanitizer)
1040 #  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
1041        __attribute__((no_sanitize_address))
1042 # else
1043 #  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
1044 # endif  // __has_feature(address_sanitizer)
1045 #else
1046 # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
1047 #endif  // __clang__
1048 
1049 // A function level attribute to disable HWAddressSanitizer instrumentation.
1050 #if defined(__clang__)
1051 # if __has_feature(hwaddress_sanitizer)
1052 #  define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \
1053        __attribute__((no_sanitize("hwaddress")))
1054 # else
1055 #  define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
1056 # endif  // __has_feature(hwaddress_sanitizer)
1057 #else
1058 # define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
1059 #endif  // __clang__
1060 
1061 // A function level attribute to disable ThreadSanitizer instrumentation.
1062 #if defined(__clang__)
1063 # if __has_feature(thread_sanitizer)
1064 #  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \
1065        __attribute__((no_sanitize_thread))
1066 # else
1067 #  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
1068 # endif  // __has_feature(thread_sanitizer)
1069 #else
1070 # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
1071 #endif  // __clang__
1072 
1073 namespace testing {
1074 
1075 class Message;
1076 
1077 // Legacy imports for backwards compatibility.
1078 // New code should use std:: names directly.
1079 using std::get;
1080 using std::make_tuple;
1081 using std::tuple;
1082 using std::tuple_element;
1083 using std::tuple_size;
1084 
1085 namespace internal {
1086 
1087 // A secret type that Google Test users don't know about.  It has no
1088 // definition on purpose.  Therefore it's impossible to create a
1089 // Secret object, which is what we want.
1090 class Secret;
1091 
1092 // The GTEST_COMPILE_ASSERT_ is a legacy macro used to verify that a compile
1093 // time expression is true (in new code, use static_assert instead). For
1094 // example, you could use it to verify the size of a static array:
1095 //
1096 //   GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,
1097 //                         names_incorrect_size);
1098 //
1099 // The second argument to the macro must be a valid C++ identifier. If the
1100 // expression is false, compiler will issue an error containing this identifier.
1101 #define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
1102 
1103 // StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
1104 //
1105 // This template is declared, but intentionally undefined.
1106 template <typename T1, typename T2>
1107 struct StaticAssertTypeEqHelper;
1108 
1109 template <typename T>
1110 struct StaticAssertTypeEqHelper<T, T> {
1111   enum { value = true };
1112 };
1113 
1114 // Same as std::is_same<>.
1115 template <typename T, typename U>
1116 struct IsSame {
1117   enum { value = false };
1118 };
1119 template <typename T>
1120 struct IsSame<T, T> {
1121   enum { value = true };
1122 };
1123 
1124 // Evaluates to the number of elements in 'array'.
1125 #define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
1126 
1127 // A helper for suppressing warnings on constant condition.  It just
1128 // returns 'condition'.
1129 GTEST_API_ bool IsTrue(bool condition);
1130 
1131 // Defines RE.
1132 
1133 #if GTEST_USES_PCRE
1134 // if used, PCRE is injected by custom/gtest-port.h
1135 #elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
1136 
1137 // A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended
1138 // Regular Expression syntax.
1139 class GTEST_API_ RE {
1140  public:
1141   // A copy constructor is required by the Standard to initialize object
1142   // references from r-values.
1143   RE(const RE& other) { Init(other.pattern()); }
1144 
1145   // Constructs an RE from a string.
1146   RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT
1147 
1148   RE(const char* regex) { Init(regex); }  // NOLINT
1149   ~RE();
1150 
1151   // Returns the string representation of the regex.
1152   const char* pattern() const { return pattern_; }
1153 
1154   // FullMatch(str, re) returns true iff regular expression re matches
1155   // the entire str.
1156   // PartialMatch(str, re) returns true iff regular expression re
1157   // matches a substring of str (including str itself).
1158   static bool FullMatch(const ::std::string& str, const RE& re) {
1159     return FullMatch(str.c_str(), re);
1160   }
1161   static bool PartialMatch(const ::std::string& str, const RE& re) {
1162     return PartialMatch(str.c_str(), re);
1163   }
1164 
1165   static bool FullMatch(const char* str, const RE& re);
1166   static bool PartialMatch(const char* str, const RE& re);
1167 
1168  private:
1169   void Init(const char* regex);
1170   const char* pattern_;
1171   bool is_valid_;
1172 
1173 # if GTEST_USES_POSIX_RE
1174 
1175   regex_t full_regex_;     // For FullMatch().
1176   regex_t partial_regex_;  // For PartialMatch().
1177 
1178 # else  // GTEST_USES_SIMPLE_RE
1179 
1180   const char* full_pattern_;  // For FullMatch();
1181 
1182 # endif
1183 
1184   GTEST_DISALLOW_ASSIGN_(RE);
1185 };
1186 
1187 #endif  // GTEST_USES_PCRE
1188 
1189 // Formats a source file path and a line number as they would appear
1190 // in an error message from the compiler used to compile this code.
1191 GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
1192 
1193 // Formats a file location for compiler-independent XML output.
1194 // Although this function is not platform dependent, we put it next to
1195 // FormatFileLocation in order to contrast the two functions.
1196 GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
1197                                                                int line);
1198 
1199 // Defines logging utilities:
1200 //   GTEST_LOG_(severity) - logs messages at the specified severity level. The
1201 //                          message itself is streamed into the macro.
1202 //   LogToStderr()  - directs all log messages to stderr.
1203 //   FlushInfoLog() - flushes informational log messages.
1204 
1205 enum GTestLogSeverity {
1206   GTEST_INFO,
1207   GTEST_WARNING,
1208   GTEST_ERROR,
1209   GTEST_FATAL
1210 };
1211 
1212 // Formats log entry severity, provides a stream object for streaming the
1213 // log message, and terminates the message with a newline when going out of
1214 // scope.
1215 class GTEST_API_ GTestLog {
1216  public:
1217   GTestLog(GTestLogSeverity severity, const char* file, int line);
1218 
1219   // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
1220   ~GTestLog();
1221 
1222   ::std::ostream& GetStream() { return ::std::cerr; }
1223 
1224  private:
1225   const GTestLogSeverity severity_;
1226 
1227   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
1228 };
1229 
1230 #if !defined(GTEST_LOG_)
1231 
1232 # define GTEST_LOG_(severity) \
1233     ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
1234                                   __FILE__, __LINE__).GetStream()
1235 
1236 inline void LogToStderr() {}
1237 inline void FlushInfoLog() { fflush(nullptr); }
1238 
1239 #endif  // !defined(GTEST_LOG_)
1240 
1241 #if !defined(GTEST_CHECK_)
1242 // INTERNAL IMPLEMENTATION - DO NOT USE.
1243 //
1244 // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
1245 // is not satisfied.
1246 //  Synopsys:
1247 //    GTEST_CHECK_(boolean_condition);
1248 //     or
1249 //    GTEST_CHECK_(boolean_condition) << "Additional message";
1250 //
1251 //    This checks the condition and if the condition is not satisfied
1252 //    it prints message about the condition violation, including the
1253 //    condition itself, plus additional message streamed into it, if any,
1254 //    and then it aborts the program. It aborts the program irrespective of
1255 //    whether it is built in the debug mode or not.
1256 # define GTEST_CHECK_(condition) \
1257     GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1258     if (::testing::internal::IsTrue(condition)) \
1259       ; \
1260     else \
1261       GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
1262 #endif  // !defined(GTEST_CHECK_)
1263 
1264 // An all-mode assert to verify that the given POSIX-style function
1265 // call returns 0 (indicating success).  Known limitation: this
1266 // doesn't expand to a balanced 'if' statement, so enclose the macro
1267 // in {} if you need to use it as the only statement in an 'if'
1268 // branch.
1269 #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
1270   if (const int gtest_error = (posix_call)) \
1271     GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
1272                       << gtest_error
1273 
1274 // Adds reference to a type if it is not a reference type,
1275 // otherwise leaves it unchanged.  This is the same as
1276 // tr1::add_reference, which is not widely available yet.
1277 template <typename T>
1278 struct AddReference { typedef T& type; };  // NOLINT
1279 template <typename T>
1280 struct AddReference<T&> { typedef T& type; };  // NOLINT
1281 
1282 // A handy wrapper around AddReference that works when the argument T
1283 // depends on template parameters.
1284 #define GTEST_ADD_REFERENCE_(T) \
1285     typename ::testing::internal::AddReference<T>::type
1286 
1287 // Transforms "T" into "const T&" according to standard reference collapsing
1288 // rules (this is only needed as a backport for C++98 compilers that do not
1289 // support reference collapsing). Specifically, it transforms:
1290 //
1291 //   char         ==> const char&
1292 //   const char   ==> const char&
1293 //   char&        ==> char&
1294 //   const char&  ==> const char&
1295 //
1296 // Note that the non-const reference will not have "const" added. This is
1297 // standard, and necessary so that "T" can always bind to "const T&".
1298 template <typename T>
1299 struct ConstRef { typedef const T& type; };
1300 template <typename T>
1301 struct ConstRef<T&> { typedef T& type; };
1302 
1303 // The argument T must depend on some template parameters.
1304 #define GTEST_REFERENCE_TO_CONST_(T) \
1305   typename ::testing::internal::ConstRef<T>::type
1306 
1307 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
1308 //
1309 // Use ImplicitCast_ as a safe version of static_cast for upcasting in
1310 // the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
1311 // const Foo*).  When you use ImplicitCast_, the compiler checks that
1312 // the cast is safe.  Such explicit ImplicitCast_s are necessary in
1313 // surprisingly many situations where C++ demands an exact type match
1314 // instead of an argument type convertable to a target type.
1315 //
1316 // The syntax for using ImplicitCast_ is the same as for static_cast:
1317 //
1318 //   ImplicitCast_<ToType>(expr)
1319 //
1320 // ImplicitCast_ would have been part of the C++ standard library,
1321 // but the proposal was submitted too late.  It will probably make
1322 // its way into the language in the future.
1323 //
1324 // This relatively ugly name is intentional. It prevents clashes with
1325 // similar functions users may have (e.g., implicit_cast). The internal
1326 // namespace alone is not enough because the function can be found by ADL.
1327 template<typename To>
1328 inline To ImplicitCast_(To x) { return x; }
1329 
1330 // When you upcast (that is, cast a pointer from type Foo to type
1331 // SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
1332 // always succeed.  When you downcast (that is, cast a pointer from
1333 // type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
1334 // how do you know the pointer is really of type SubclassOfFoo?  It
1335 // could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
1336 // when you downcast, you should use this macro.  In debug mode, we
1337 // use dynamic_cast<> to double-check the downcast is legal (we die
1338 // if it's not).  In normal mode, we do the efficient static_cast<>
1339 // instead.  Thus, it's important to test in debug mode to make sure
1340 // the cast is legal!
1341 //    This is the only place in the code we should use dynamic_cast<>.
1342 // In particular, you SHOULDN'T be using dynamic_cast<> in order to
1343 // do RTTI (eg code like this:
1344 //    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
1345 //    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
1346 // You should design the code some other way not to need this.
1347 //
1348 // This relatively ugly name is intentional. It prevents clashes with
1349 // similar functions users may have (e.g., down_cast). The internal
1350 // namespace alone is not enough because the function can be found by ADL.
1351 template<typename To, typename From>  // use like this: DownCast_<T*>(foo);
1352 inline To DownCast_(From* f) {  // so we only accept pointers
1353   // Ensures that To is a sub-type of From *.  This test is here only
1354   // for compile-time type checking, and has no overhead in an
1355   // optimized build at run-time, as it will be optimized away
1356   // completely.
1357   GTEST_INTENTIONAL_CONST_COND_PUSH_()
1358   if (false) {
1359   GTEST_INTENTIONAL_CONST_COND_POP_()
1360   const To to = nullptr;
1361   ::testing::internal::ImplicitCast_<From*>(to);
1362   }
1363 
1364 #if GTEST_HAS_RTTI
1365   // RTTI: debug mode only!
1366   GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);
1367 #endif
1368   return static_cast<To>(f);
1369 }
1370 
1371 // Downcasts the pointer of type Base to Derived.
1372 // Derived must be a subclass of Base. The parameter MUST
1373 // point to a class of type Derived, not any subclass of it.
1374 // When RTTI is available, the function performs a runtime
1375 // check to enforce this.
1376 template <class Derived, class Base>
1377 Derived* CheckedDowncastToActualType(Base* base) {
1378 #if GTEST_HAS_RTTI
1379   GTEST_CHECK_(typeid(*base) == typeid(Derived));
1380 #endif
1381 
1382 #if GTEST_HAS_DOWNCAST_
1383   return ::down_cast<Derived*>(base);
1384 #elif GTEST_HAS_RTTI
1385   return dynamic_cast<Derived*>(base);  // NOLINT
1386 #else
1387   return static_cast<Derived*>(base);  // Poor man's downcast.
1388 #endif
1389 }
1390 
1391 #if GTEST_HAS_STREAM_REDIRECTION
1392 
1393 // Defines the stderr capturer:
1394 //   CaptureStdout     - starts capturing stdout.
1395 //   GetCapturedStdout - stops capturing stdout and returns the captured string.
1396 //   CaptureStderr     - starts capturing stderr.
1397 //   GetCapturedStderr - stops capturing stderr and returns the captured string.
1398 //
1399 GTEST_API_ void CaptureStdout();
1400 GTEST_API_ std::string GetCapturedStdout();
1401 GTEST_API_ void CaptureStderr();
1402 GTEST_API_ std::string GetCapturedStderr();
1403 
1404 #endif  // GTEST_HAS_STREAM_REDIRECTION
1405 // Returns the size (in bytes) of a file.
1406 GTEST_API_ size_t GetFileSize(FILE* file);
1407 
1408 // Reads the entire content of a file as a string.
1409 GTEST_API_ std::string ReadEntireFile(FILE* file);
1410 
1411 // All command line arguments.
1412 GTEST_API_ std::vector<std::string> GetArgvs();
1413 
1414 #if GTEST_HAS_DEATH_TEST
1415 
1416 std::vector<std::string> GetInjectableArgvs();
1417 // Deprecated: pass the args vector by value instead.
1418 void SetInjectableArgvs(const std::vector<std::string>* new_argvs);
1419 void SetInjectableArgvs(const std::vector<std::string>& new_argvs);
1420 void ClearInjectableArgvs();
1421 
1422 #endif  // GTEST_HAS_DEATH_TEST
1423 
1424 // Defines synchronization primitives.
1425 #if GTEST_IS_THREADSAFE
1426 # if GTEST_HAS_PTHREAD
1427 // Sleeps for (roughly) n milliseconds.  This function is only for testing
1428 // Google Test's own constructs.  Don't use it in user tests, either
1429 // directly or indirectly.
1430 inline void SleepMilliseconds(int n) {
1431   const timespec time = {
1432     0,                  // 0 seconds.
1433     n * 1000L * 1000L,  // And n ms.
1434   };
1435   nanosleep(&time, nullptr);
1436 }
1437 # endif  // GTEST_HAS_PTHREAD
1438 
1439 # if GTEST_HAS_NOTIFICATION_
1440 // Notification has already been imported into the namespace.
1441 // Nothing to do here.
1442 
1443 # elif GTEST_HAS_PTHREAD
1444 // Allows a controller thread to pause execution of newly created
1445 // threads until notified.  Instances of this class must be created
1446 // and destroyed in the controller thread.
1447 //
1448 // This class is only for testing Google Test's own constructs. Do not
1449 // use it in user tests, either directly or indirectly.
1450 class Notification {
1451  public:
1452   Notification() : notified_(false) {
1453     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
1454   }
1455   ~Notification() {
1456     pthread_mutex_destroy(&mutex_);
1457   }
1458 
1459   // Notifies all threads created with this notification to start. Must
1460   // be called from the controller thread.
1461   void Notify() {
1462     pthread_mutex_lock(&mutex_);
1463     notified_ = true;
1464     pthread_mutex_unlock(&mutex_);
1465   }
1466 
1467   // Blocks until the controller thread notifies. Must be called from a test
1468   // thread.
1469   void WaitForNotification() {
1470     for (;;) {
1471       pthread_mutex_lock(&mutex_);
1472       const bool notified = notified_;
1473       pthread_mutex_unlock(&mutex_);
1474       if (notified)
1475         break;
1476       SleepMilliseconds(10);
1477     }
1478   }
1479 
1480  private:
1481   pthread_mutex_t mutex_;
1482   bool notified_;
1483 
1484   GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
1485 };
1486 
1487 # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
1488 
1489 GTEST_API_ void SleepMilliseconds(int n);
1490 
1491 // Provides leak-safe Windows kernel handle ownership.
1492 // Used in death tests and in threading support.
1493 class GTEST_API_ AutoHandle {
1494  public:
1495   // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to
1496   // avoid including <windows.h> in this header file. Including <windows.h> is
1497   // undesirable because it defines a lot of symbols and macros that tend to
1498   // conflict with client code. This assumption is verified by
1499   // WindowsTypesTest.HANDLEIsVoidStar.
1500   typedef void* Handle;
1501   AutoHandle();
1502   explicit AutoHandle(Handle handle);
1503 
1504   ~AutoHandle();
1505 
1506   Handle Get() const;
1507   void Reset();
1508   void Reset(Handle handle);
1509 
1510  private:
1511   // Returns true iff the handle is a valid handle object that can be closed.
1512   bool IsCloseable() const;
1513 
1514   Handle handle_;
1515 
1516   GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
1517 };
1518 
1519 // Allows a controller thread to pause execution of newly created
1520 // threads until notified.  Instances of this class must be created
1521 // and destroyed in the controller thread.
1522 //
1523 // This class is only for testing Google Test's own constructs. Do not
1524 // use it in user tests, either directly or indirectly.
1525 class GTEST_API_ Notification {
1526  public:
1527   Notification();
1528   void Notify();
1529   void WaitForNotification();
1530 
1531  private:
1532   AutoHandle event_;
1533 
1534   GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
1535 };
1536 # endif  // GTEST_HAS_NOTIFICATION_
1537 
1538 // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD
1539 // defined, but we don't want to use MinGW's pthreads implementation, which
1540 // has conformance problems with some versions of the POSIX standard.
1541 # if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW
1542 
1543 // As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
1544 // Consequently, it cannot select a correct instantiation of ThreadWithParam
1545 // in order to call its Run(). Introducing ThreadWithParamBase as a
1546 // non-templated base class for ThreadWithParam allows us to bypass this
1547 // problem.
1548 class ThreadWithParamBase {
1549  public:
1550   virtual ~ThreadWithParamBase() {}
1551   virtual void Run() = 0;
1552 };
1553 
1554 // pthread_create() accepts a pointer to a function type with the C linkage.
1555 // According to the Standard (7.5/1), function types with different linkages
1556 // are different even if they are otherwise identical.  Some compilers (for
1557 // example, SunStudio) treat them as different types.  Since class methods
1558 // cannot be defined with C-linkage we need to define a free C-function to
1559 // pass into pthread_create().
1560 extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
1561   static_cast<ThreadWithParamBase*>(thread)->Run();
1562   return nullptr;
1563 }
1564 
1565 // Helper class for testing Google Test's multi-threading constructs.
1566 // To use it, write:
1567 //
1568 //   void ThreadFunc(int param) { /* Do things with param */ }
1569 //   Notification thread_can_start;
1570 //   ...
1571 //   // The thread_can_start parameter is optional; you can supply NULL.
1572 //   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
1573 //   thread_can_start.Notify();
1574 //
1575 // These classes are only for testing Google Test's own constructs. Do
1576 // not use them in user tests, either directly or indirectly.
1577 template <typename T>
1578 class ThreadWithParam : public ThreadWithParamBase {
1579  public:
1580   typedef void UserThreadFunc(T);
1581 
1582   ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
1583       : func_(func),
1584         param_(param),
1585         thread_can_start_(thread_can_start),
1586         finished_(false) {
1587     ThreadWithParamBase* const base = this;
1588     // The thread can be created only after all fields except thread_
1589     // have been initialized.
1590     GTEST_CHECK_POSIX_SUCCESS_(
1591         pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));
1592   }
1593   ~ThreadWithParam() override { Join(); }
1594 
1595   void Join() {
1596     if (!finished_) {
1597       GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr));
1598       finished_ = true;
1599     }
1600   }
1601 
1602   void Run() override {
1603     if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();
1604     func_(param_);
1605   }
1606 
1607  private:
1608   UserThreadFunc* const func_;  // User-supplied thread function.
1609   const T param_;  // User-supplied parameter to the thread function.
1610   // When non-NULL, used to block execution until the controller thread
1611   // notifies.
1612   Notification* const thread_can_start_;
1613   bool finished_;  // true iff we know that the thread function has finished.
1614   pthread_t thread_;  // The native thread object.
1615 
1616   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
1617 };
1618 # endif  // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
1619          // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1620 
1621 # if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1622 // Mutex and ThreadLocal have already been imported into the namespace.
1623 // Nothing to do here.
1624 
1625 # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
1626 
1627 // Mutex implements mutex on Windows platforms.  It is used in conjunction
1628 // with class MutexLock:
1629 //
1630 //   Mutex mutex;
1631 //   ...
1632 //   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the
1633 //                            // end of the current scope.
1634 //
1635 // A static Mutex *must* be defined or declared using one of the following
1636 // macros:
1637 //   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
1638 //   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
1639 //
1640 // (A non-static Mutex is defined/declared in the usual way).
1641 class GTEST_API_ Mutex {
1642  public:
1643   enum MutexType { kStatic = 0, kDynamic = 1 };
1644   // We rely on kStaticMutex being 0 as it is to what the linker initializes
1645   // type_ in static mutexes.  critical_section_ will be initialized lazily
1646   // in ThreadSafeLazyInit().
1647   enum StaticConstructorSelector { kStaticMutex = 0 };
1648 
1649   // This constructor intentionally does nothing.  It relies on type_ being
1650   // statically initialized to 0 (effectively setting it to kStatic) and on
1651   // ThreadSafeLazyInit() to lazily initialize the rest of the members.
1652   explicit Mutex(StaticConstructorSelector /*dummy*/) {}
1653 
1654   Mutex();
1655   ~Mutex();
1656 
1657   void Lock();
1658 
1659   void Unlock();
1660 
1661   // Does nothing if the current thread holds the mutex. Otherwise, crashes
1662   // with high probability.
1663   void AssertHeld();
1664 
1665  private:
1666   // Initializes owner_thread_id_ and critical_section_ in static mutexes.
1667   void ThreadSafeLazyInit();
1668 
1669   // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503,
1670   // we assume that 0 is an invalid value for thread IDs.
1671   unsigned int owner_thread_id_;
1672 
1673   // For static mutexes, we rely on these members being initialized to zeros
1674   // by the linker.
1675   MutexType type_;
1676   long critical_section_init_phase_;  // NOLINT
1677   GTEST_CRITICAL_SECTION* critical_section_;
1678 
1679   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
1680 };
1681 
1682 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1683     extern ::testing::internal::Mutex mutex
1684 
1685 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1686     ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
1687 
1688 // We cannot name this class MutexLock because the ctor declaration would
1689 // conflict with a macro named MutexLock, which is defined on some
1690 // platforms. That macro is used as a defensive measure to prevent against
1691 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
1692 // "MutexLock l(&mu)".  Hence the typedef trick below.
1693 class GTestMutexLock {
1694  public:
1695   explicit GTestMutexLock(Mutex* mutex)
1696       : mutex_(mutex) { mutex_->Lock(); }
1697 
1698   ~GTestMutexLock() { mutex_->Unlock(); }
1699 
1700  private:
1701   Mutex* const mutex_;
1702 
1703   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
1704 };
1705 
1706 typedef GTestMutexLock MutexLock;
1707 
1708 // Base class for ValueHolder<T>.  Allows a caller to hold and delete a value
1709 // without knowing its type.
1710 class ThreadLocalValueHolderBase {
1711  public:
1712   virtual ~ThreadLocalValueHolderBase() {}
1713 };
1714 
1715 // Provides a way for a thread to send notifications to a ThreadLocal
1716 // regardless of its parameter type.
1717 class ThreadLocalBase {
1718  public:
1719   // Creates a new ValueHolder<T> object holding a default value passed to
1720   // this ThreadLocal<T>'s constructor and returns it.  It is the caller's
1721   // responsibility not to call this when the ThreadLocal<T> instance already
1722   // has a value on the current thread.
1723   virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;
1724 
1725  protected:
1726   ThreadLocalBase() {}
1727   virtual ~ThreadLocalBase() {}
1728 
1729  private:
1730   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);
1731 };
1732 
1733 // Maps a thread to a set of ThreadLocals that have values instantiated on that
1734 // thread and notifies them when the thread exits.  A ThreadLocal instance is
1735 // expected to persist until all threads it has values on have terminated.
1736 class GTEST_API_ ThreadLocalRegistry {
1737  public:
1738   // Registers thread_local_instance as having value on the current thread.
1739   // Returns a value that can be used to identify the thread from other threads.
1740   static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
1741       const ThreadLocalBase* thread_local_instance);
1742 
1743   // Invoked when a ThreadLocal instance is destroyed.
1744   static void OnThreadLocalDestroyed(
1745       const ThreadLocalBase* thread_local_instance);
1746 };
1747 
1748 class GTEST_API_ ThreadWithParamBase {
1749  public:
1750   void Join();
1751 
1752  protected:
1753   class Runnable {
1754    public:
1755     virtual ~Runnable() {}
1756     virtual void Run() = 0;
1757   };
1758 
1759   ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);
1760   virtual ~ThreadWithParamBase();
1761 
1762  private:
1763   AutoHandle thread_;
1764 };
1765 
1766 // Helper class for testing Google Test's multi-threading constructs.
1767 template <typename T>
1768 class ThreadWithParam : public ThreadWithParamBase {
1769  public:
1770   typedef void UserThreadFunc(T);
1771 
1772   ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
1773       : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {
1774   }
1775   virtual ~ThreadWithParam() {}
1776 
1777  private:
1778   class RunnableImpl : public Runnable {
1779    public:
1780     RunnableImpl(UserThreadFunc* func, T param)
1781         : func_(func),
1782           param_(param) {
1783     }
1784     virtual ~RunnableImpl() {}
1785     virtual void Run() {
1786       func_(param_);
1787     }
1788 
1789    private:
1790     UserThreadFunc* const func_;
1791     const T param_;
1792 
1793     GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);
1794   };
1795 
1796   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
1797 };
1798 
1799 // Implements thread-local storage on Windows systems.
1800 //
1801 //   // Thread 1
1802 //   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.
1803 //
1804 //   // Thread 2
1805 //   tl.set(150);  // Changes the value for thread 2 only.
1806 //   EXPECT_EQ(150, tl.get());
1807 //
1808 //   // Thread 1
1809 //   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
1810 //   tl.set(200);
1811 //   EXPECT_EQ(200, tl.get());
1812 //
1813 // The template type argument T must have a public copy constructor.
1814 // In addition, the default ThreadLocal constructor requires T to have
1815 // a public default constructor.
1816 //
1817 // The users of a TheadLocal instance have to make sure that all but one
1818 // threads (including the main one) using that instance have exited before
1819 // destroying it. Otherwise, the per-thread objects managed for them by the
1820 // ThreadLocal instance are not guaranteed to be destroyed on all platforms.
1821 //
1822 // Google Test only uses global ThreadLocal objects.  That means they
1823 // will die after main() has returned.  Therefore, no per-thread
1824 // object managed by Google Test will be leaked as long as all threads
1825 // using Google Test have exited when main() returns.
1826 template <typename T>
1827 class ThreadLocal : public ThreadLocalBase {
1828  public:
1829   ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
1830   explicit ThreadLocal(const T& value)
1831       : default_factory_(new InstanceValueHolderFactory(value)) {}
1832 
1833   ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }
1834 
1835   T* pointer() { return GetOrCreateValue(); }
1836   const T* pointer() const { return GetOrCreateValue(); }
1837   const T& get() const { return *pointer(); }
1838   void set(const T& value) { *pointer() = value; }
1839 
1840  private:
1841   // Holds a value of T.  Can be deleted via its base class without the caller
1842   // knowing the type of T.
1843   class ValueHolder : public ThreadLocalValueHolderBase {
1844    public:
1845     ValueHolder() : value_() {}
1846     explicit ValueHolder(const T& value) : value_(value) {}
1847 
1848     T* pointer() { return &value_; }
1849 
1850    private:
1851     T value_;
1852     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
1853   };
1854 
1855 
1856   T* GetOrCreateValue() const {
1857     return static_cast<ValueHolder*>(
1858         ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();
1859   }
1860 
1861   virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {
1862     return default_factory_->MakeNewHolder();
1863   }
1864 
1865   class ValueHolderFactory {
1866    public:
1867     ValueHolderFactory() {}
1868     virtual ~ValueHolderFactory() {}
1869     virtual ValueHolder* MakeNewHolder() const = 0;
1870 
1871    private:
1872     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
1873   };
1874 
1875   class DefaultValueHolderFactory : public ValueHolderFactory {
1876    public:
1877     DefaultValueHolderFactory() {}
1878     virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
1879 
1880    private:
1881     GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
1882   };
1883 
1884   class InstanceValueHolderFactory : public ValueHolderFactory {
1885    public:
1886     explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
1887     virtual ValueHolder* MakeNewHolder() const {
1888       return new ValueHolder(value_);
1889     }
1890 
1891    private:
1892     const T value_;  // The value for each thread.
1893 
1894     GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
1895   };
1896 
1897   std::unique_ptr<ValueHolderFactory> default_factory_;
1898 
1899   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
1900 };
1901 
1902 # elif GTEST_HAS_PTHREAD
1903 
1904 // MutexBase and Mutex implement mutex on pthreads-based platforms.
1905 class MutexBase {
1906  public:
1907   // Acquires this mutex.
1908   void Lock() {
1909     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
1910     owner_ = pthread_self();
1911     has_owner_ = true;
1912   }
1913 
1914   // Releases this mutex.
1915   void Unlock() {
1916     // Since the lock is being released the owner_ field should no longer be
1917     // considered valid. We don't protect writing to has_owner_ here, as it's
1918     // the caller's responsibility to ensure that the current thread holds the
1919     // mutex when this is called.
1920     has_owner_ = false;
1921     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
1922   }
1923 
1924   // Does nothing if the current thread holds the mutex. Otherwise, crashes
1925   // with high probability.
1926   void AssertHeld() const {
1927     GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
1928         << "The current thread is not holding the mutex @" << this;
1929   }
1930 
1931   // A static mutex may be used before main() is entered.  It may even
1932   // be used before the dynamic initialization stage.  Therefore we
1933   // must be able to initialize a static mutex object at link time.
1934   // This means MutexBase has to be a POD and its member variables
1935   // have to be public.
1936  public:
1937   pthread_mutex_t mutex_;  // The underlying pthread mutex.
1938   // has_owner_ indicates whether the owner_ field below contains a valid thread
1939   // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
1940   // accesses to the owner_ field should be protected by a check of this field.
1941   // An alternative might be to memset() owner_ to all zeros, but there's no
1942   // guarantee that a zero'd pthread_t is necessarily invalid or even different
1943   // from pthread_self().
1944   bool has_owner_;
1945   pthread_t owner_;  // The thread holding the mutex.
1946 };
1947 
1948 // Forward-declares a static mutex.
1949 #  define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1950      extern ::testing::internal::MutexBase mutex
1951 
1952 // Defines and statically (i.e. at link time) initializes a static mutex.
1953 // The initialization list here does not explicitly initialize each field,
1954 // instead relying on default initialization for the unspecified fields. In
1955 // particular, the owner_ field (a pthread_t) is not explicitly initialized.
1956 // This allows initialization to work whether pthread_t is a scalar or struct.
1957 // The flag -Wmissing-field-initializers must not be specified for this to work.
1958 #define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1959   ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
1960 
1961 // The Mutex class can only be used for mutexes created at runtime. It
1962 // shares its API with MutexBase otherwise.
1963 class Mutex : public MutexBase {
1964  public:
1965   Mutex() {
1966     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
1967     has_owner_ = false;
1968   }
1969   ~Mutex() {
1970     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
1971   }
1972 
1973  private:
1974   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
1975 };
1976 
1977 // We cannot name this class MutexLock because the ctor declaration would
1978 // conflict with a macro named MutexLock, which is defined on some
1979 // platforms. That macro is used as a defensive measure to prevent against
1980 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
1981 // "MutexLock l(&mu)".  Hence the typedef trick below.
1982 class GTestMutexLock {
1983  public:
1984   explicit GTestMutexLock(MutexBase* mutex)
1985       : mutex_(mutex) { mutex_->Lock(); }
1986 
1987   ~GTestMutexLock() { mutex_->Unlock(); }
1988 
1989  private:
1990   MutexBase* const mutex_;
1991 
1992   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
1993 };
1994 
1995 typedef GTestMutexLock MutexLock;
1996 
1997 // Helpers for ThreadLocal.
1998 
1999 // pthread_key_create() requires DeleteThreadLocalValue() to have
2000 // C-linkage.  Therefore it cannot be templatized to access
2001 // ThreadLocal<T>.  Hence the need for class
2002 // ThreadLocalValueHolderBase.
2003 class ThreadLocalValueHolderBase {
2004  public:
2005   virtual ~ThreadLocalValueHolderBase() {}
2006 };
2007 
2008 // Called by pthread to delete thread-local data stored by
2009 // pthread_setspecific().
2010 extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
2011   delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
2012 }
2013 
2014 // Implements thread-local storage on pthreads-based systems.
2015 template <typename T>
2016 class GTEST_API_ ThreadLocal {
2017  public:
2018   ThreadLocal()
2019       : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
2020   explicit ThreadLocal(const T& value)
2021       : key_(CreateKey()),
2022         default_factory_(new InstanceValueHolderFactory(value)) {}
2023 
2024   ~ThreadLocal() {
2025     // Destroys the managed object for the current thread, if any.
2026     DeleteThreadLocalValue(pthread_getspecific(key_));
2027 
2028     // Releases resources associated with the key.  This will *not*
2029     // delete managed objects for other threads.
2030     GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
2031   }
2032 
2033   T* pointer() { return GetOrCreateValue(); }
2034   const T* pointer() const { return GetOrCreateValue(); }
2035   const T& get() const { return *pointer(); }
2036   void set(const T& value) { *pointer() = value; }
2037 
2038  private:
2039   // Holds a value of type T.
2040   class ValueHolder : public ThreadLocalValueHolderBase {
2041    public:
2042     ValueHolder() : value_() {}
2043     explicit ValueHolder(const T& value) : value_(value) {}
2044 
2045     T* pointer() { return &value_; }
2046 
2047    private:
2048     T value_;
2049     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
2050   };
2051 
2052   static pthread_key_t CreateKey() {
2053     pthread_key_t key;
2054     // When a thread exits, DeleteThreadLocalValue() will be called on
2055     // the object managed for that thread.
2056     GTEST_CHECK_POSIX_SUCCESS_(
2057         pthread_key_create(&key, &DeleteThreadLocalValue));
2058     return key;
2059   }
2060 
2061   T* GetOrCreateValue() const {
2062     ThreadLocalValueHolderBase* const holder =
2063         static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
2064     if (holder != nullptr) {
2065       return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
2066     }
2067 
2068     ValueHolder* const new_holder = default_factory_->MakeNewHolder();
2069     ThreadLocalValueHolderBase* const holder_base = new_holder;
2070     GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
2071     return new_holder->pointer();
2072   }
2073 
2074   class ValueHolderFactory {
2075    public:
2076     ValueHolderFactory() {}
2077     virtual ~ValueHolderFactory() {}
2078     virtual ValueHolder* MakeNewHolder() const = 0;
2079 
2080    private:
2081     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
2082   };
2083 
2084   class DefaultValueHolderFactory : public ValueHolderFactory {
2085    public:
2086     DefaultValueHolderFactory() {}
2087     virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
2088 
2089    private:
2090     GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
2091   };
2092 
2093   class InstanceValueHolderFactory : public ValueHolderFactory {
2094    public:
2095     explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
2096     virtual ValueHolder* MakeNewHolder() const {
2097       return new ValueHolder(value_);
2098     }
2099 
2100    private:
2101     const T value_;  // The value for each thread.
2102 
2103     GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
2104   };
2105 
2106   // A key pthreads uses for looking up per-thread values.
2107   const pthread_key_t key_;
2108   std::unique_ptr<ValueHolderFactory> default_factory_;
2109 
2110   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
2111 };
2112 
2113 # endif  // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
2114 
2115 #else  // GTEST_IS_THREADSAFE
2116 
2117 // A dummy implementation of synchronization primitives (mutex, lock,
2118 // and thread-local variable).  Necessary for compiling Google Test where
2119 // mutex is not supported - using Google Test in multiple threads is not
2120 // supported on such platforms.
2121 
2122 class Mutex {
2123  public:
2124   Mutex() {}
2125   void Lock() {}
2126   void Unlock() {}
2127   void AssertHeld() const {}
2128 };
2129 
2130 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
2131   extern ::testing::internal::Mutex mutex
2132 
2133 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
2134 
2135 // We cannot name this class MutexLock because the ctor declaration would
2136 // conflict with a macro named MutexLock, which is defined on some
2137 // platforms. That macro is used as a defensive measure to prevent against
2138 // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
2139 // "MutexLock l(&mu)".  Hence the typedef trick below.
2140 class GTestMutexLock {
2141  public:
2142   explicit GTestMutexLock(Mutex*) {}  // NOLINT
2143 };
2144 
2145 typedef GTestMutexLock MutexLock;
2146 
2147 template <typename T>
2148 class GTEST_API_ ThreadLocal {
2149  public:
2150   ThreadLocal() : value_() {}
2151   explicit ThreadLocal(const T& value) : value_(value) {}
2152   T* pointer() { return &value_; }
2153   const T* pointer() const { return &value_; }
2154   const T& get() const { return value_; }
2155   void set(const T& value) { value_ = value; }
2156  private:
2157   T value_;
2158 };
2159 
2160 #endif  // GTEST_IS_THREADSAFE
2161 
2162 // Returns the number of threads running in the process, or 0 to indicate that
2163 // we cannot detect it.
2164 GTEST_API_ size_t GetThreadCount();
2165 
2166 template <bool bool_value>
2167 struct bool_constant {
2168   typedef bool_constant<bool_value> type;
2169   static const bool value = bool_value;
2170 };
2171 template <bool bool_value> const bool bool_constant<bool_value>::value;
2172 
2173 typedef bool_constant<false> false_type;
2174 typedef bool_constant<true> true_type;
2175 
2176 template <typename T, typename U>
2177 struct is_same : public false_type {};
2178 
2179 template <typename T>
2180 struct is_same<T, T> : public true_type {};
2181 
2182 template <typename Iterator>
2183 struct IteratorTraits {
2184   typedef typename Iterator::value_type value_type;
2185 };
2186 
2187 
2188 template <typename T>
2189 struct IteratorTraits<T*> {
2190   typedef T value_type;
2191 };
2192 
2193 template <typename T>
2194 struct IteratorTraits<const T*> {
2195   typedef T value_type;
2196 };
2197 
2198 #if GTEST_OS_WINDOWS
2199 # define GTEST_PATH_SEP_ "\\"
2200 # define GTEST_HAS_ALT_PATH_SEP_ 1
2201 // The biggest signed integer type the compiler supports.
2202 typedef __int64 BiggestInt;
2203 #else
2204 # define GTEST_PATH_SEP_ "/"
2205 # define GTEST_HAS_ALT_PATH_SEP_ 0
2206 typedef long long BiggestInt;  // NOLINT
2207 #endif  // GTEST_OS_WINDOWS
2208 
2209 // Utilities for char.
2210 
2211 // isspace(int ch) and friends accept an unsigned char or EOF.  char
2212 // may be signed, depending on the compiler (or compiler flags).
2213 // Therefore we need to cast a char to unsigned char before calling
2214 // isspace(), etc.
2215 
2216 inline bool IsAlpha(char ch) {
2217   return isalpha(static_cast<unsigned char>(ch)) != 0;
2218 }
2219 inline bool IsAlNum(char ch) {
2220   return isalnum(static_cast<unsigned char>(ch)) != 0;
2221 }
2222 inline bool IsDigit(char ch) {
2223   return isdigit(static_cast<unsigned char>(ch)) != 0;
2224 }
2225 inline bool IsLower(char ch) {
2226   return islower(static_cast<unsigned char>(ch)) != 0;
2227 }
2228 inline bool IsSpace(char ch) {
2229   return isspace(static_cast<unsigned char>(ch)) != 0;
2230 }
2231 inline bool IsUpper(char ch) {
2232   return isupper(static_cast<unsigned char>(ch)) != 0;
2233 }
2234 inline bool IsXDigit(char ch) {
2235   return isxdigit(static_cast<unsigned char>(ch)) != 0;
2236 }
2237 inline bool IsXDigit(wchar_t ch) {
2238   const unsigned char low_byte = static_cast<unsigned char>(ch);
2239   return ch == low_byte && isxdigit(low_byte) != 0;
2240 }
2241 
2242 inline char ToLower(char ch) {
2243   return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
2244 }
2245 inline char ToUpper(char ch) {
2246   return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
2247 }
2248 
2249 inline std::string StripTrailingSpaces(std::string str) {
2250   std::string::iterator it = str.end();
2251   while (it != str.begin() && IsSpace(*--it))
2252     it = str.erase(it);
2253   return str;
2254 }
2255 
2256 // The testing::internal::posix namespace holds wrappers for common
2257 // POSIX functions.  These wrappers hide the differences between
2258 // Windows/MSVC and POSIX systems.  Since some compilers define these
2259 // standard functions as macros, the wrapper cannot have the same name
2260 // as the wrapped function.
2261 
2262 namespace posix {
2263 
2264 // Functions with a different name on Windows.
2265 
2266 #if GTEST_OS_WINDOWS
2267 
2268 typedef struct _stat StatStruct;
2269 
2270 # ifdef __BORLANDC__
2271 inline int IsATTY(int fd) { return isatty(fd); }
2272 inline int StrCaseCmp(const char* s1, const char* s2) {
2273   return stricmp(s1, s2);
2274 }
2275 inline char* StrDup(const char* src) { return strdup(src); }
2276 # else  // !__BORLANDC__
2277 #  if GTEST_OS_WINDOWS_MOBILE
2278 inline int IsATTY(int /* fd */) { return 0; }
2279 #  else
2280 inline int IsATTY(int fd) { return _isatty(fd); }
2281 #  endif  // GTEST_OS_WINDOWS_MOBILE
2282 inline int StrCaseCmp(const char* s1, const char* s2) {
2283   return _stricmp(s1, s2);
2284 }
2285 inline char* StrDup(const char* src) { return _strdup(src); }
2286 # endif  // __BORLANDC__
2287 
2288 # if GTEST_OS_WINDOWS_MOBILE
2289 inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
2290 // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
2291 // time and thus not defined there.
2292 # else
2293 inline int FileNo(FILE* file) { return _fileno(file); }
2294 inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
2295 inline int RmDir(const char* dir) { return _rmdir(dir); }
2296 inline bool IsDir(const StatStruct& st) {
2297   return (_S_IFDIR & st.st_mode) != 0;
2298 }
2299 # endif  // GTEST_OS_WINDOWS_MOBILE
2300 
2301 #else
2302 
2303 typedef struct stat StatStruct;
2304 
2305 inline int FileNo(FILE* file) { return fileno(file); }
2306 inline int IsATTY(int fd) { return isatty(fd); }
2307 inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
2308 inline int StrCaseCmp(const char* s1, const char* s2) {
2309   return strcasecmp(s1, s2);
2310 }
2311 inline char* StrDup(const char* src) { return strdup(src); }
2312 inline int RmDir(const char* dir) { return rmdir(dir); }
2313 inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
2314 
2315 #endif  // GTEST_OS_WINDOWS
2316 
2317 // Functions deprecated by MSVC 8.0.
2318 
2319 GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
2320 
2321 inline const char* StrNCpy(char* dest, const char* src, size_t n) {
2322   return strncpy(dest, src, n);
2323 }
2324 
2325 // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
2326 // StrError() aren't needed on Windows CE at this time and thus not
2327 // defined there.
2328 
2329 #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
2330 inline int ChDir(const char* dir) { return chdir(dir); }
2331 #endif
2332 inline FILE* FOpen(const char* path, const char* mode) {
2333   return fopen(path, mode);
2334 }
2335 #if !GTEST_OS_WINDOWS_MOBILE
2336 inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
2337   return freopen(path, mode, stream);
2338 }
2339 inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
2340 #endif
2341 inline int FClose(FILE* fp) { return fclose(fp); }
2342 #if !GTEST_OS_WINDOWS_MOBILE
2343 inline int Read(int fd, void* buf, unsigned int count) {
2344   return static_cast<int>(read(fd, buf, count));
2345 }
2346 inline int Write(int fd, const void* buf, unsigned int count) {
2347   return static_cast<int>(write(fd, buf, count));
2348 }
2349 inline int Close(int fd) { return close(fd); }
2350 inline const char* StrError(int errnum) { return strerror(errnum); }
2351 #endif
2352 inline const char* GetEnv(const char* name) {
2353 #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
2354   // We are on Windows CE, which has no environment variables.
2355   static_cast<void>(name);  // To prevent 'unused argument' warning.
2356   return nullptr;
2357 #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
2358   // Environment variables which we programmatically clear will be set to the
2359   // empty string rather than unset (NULL).  Handle that case.
2360   const char* const env = getenv(name);
2361   return (env != nullptr && env[0] != '\0') ? env : nullptr;
2362 #else
2363   return getenv(name);
2364 #endif
2365 }
2366 
2367 GTEST_DISABLE_MSC_DEPRECATED_POP_()
2368 
2369 #if GTEST_OS_WINDOWS_MOBILE
2370 // Windows CE has no C library. The abort() function is used in
2371 // several places in Google Test. This implementation provides a reasonable
2372 // imitation of standard behaviour.
2373 [[noreturn]] void Abort();
2374 #else
2375 [[noreturn]] inline void Abort() { abort(); }
2376 #endif  // GTEST_OS_WINDOWS_MOBILE
2377 
2378 }  // namespace posix
2379 
2380 // MSVC "deprecates" snprintf and issues warnings wherever it is used.  In
2381 // order to avoid these warnings, we need to use _snprintf or _snprintf_s on
2382 // MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate
2383 // function in order to achieve that.  We use macro definition here because
2384 // snprintf is a variadic function.
2385 #if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE
2386 // MSVC 2005 and above support variadic macros.
2387 # define GTEST_SNPRINTF_(buffer, size, format, ...) \
2388      _snprintf_s(buffer, size, size, format, __VA_ARGS__)
2389 #elif defined(_MSC_VER)
2390 // Windows CE does not define _snprintf_s
2391 # define GTEST_SNPRINTF_ _snprintf
2392 #else
2393 # define GTEST_SNPRINTF_ snprintf
2394 #endif
2395 
2396 // The maximum number a BiggestInt can represent.  This definition
2397 // works no matter BiggestInt is represented in one's complement or
2398 // two's complement.
2399 //
2400 // We cannot rely on numeric_limits in STL, as __int64 and long long
2401 // are not part of standard C++ and numeric_limits doesn't need to be
2402 // defined for them.
2403 const BiggestInt kMaxBiggestInt =
2404     ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
2405 
2406 // This template class serves as a compile-time function from size to
2407 // type.  It maps a size in bytes to a primitive type with that
2408 // size. e.g.
2409 //
2410 //   TypeWithSize<4>::UInt
2411 //
2412 // is typedef-ed to be unsigned int (unsigned integer made up of 4
2413 // bytes).
2414 //
2415 // Such functionality should belong to STL, but I cannot find it
2416 // there.
2417 //
2418 // Google Test uses this class in the implementation of floating-point
2419 // comparison.
2420 //
2421 // For now it only handles UInt (unsigned int) as that's all Google Test
2422 // needs.  Other types can be easily added in the future if need
2423 // arises.
2424 template <size_t size>
2425 class TypeWithSize {
2426  public:
2427   // This prevents the user from using TypeWithSize<N> with incorrect
2428   // values of N.
2429   typedef void UInt;
2430 };
2431 
2432 // The specialization for size 4.
2433 template <>
2434 class TypeWithSize<4> {
2435  public:
2436   // unsigned int has size 4 in both gcc and MSVC.
2437   //
2438   // As base/basictypes.h doesn't compile on Windows, we cannot use
2439   // uint32, uint64, and etc here.
2440   typedef int Int;
2441   typedef unsigned int UInt;
2442 };
2443 
2444 // The specialization for size 8.
2445 template <>
2446 class TypeWithSize<8> {
2447  public:
2448 #if GTEST_OS_WINDOWS
2449   typedef __int64 Int;
2450   typedef unsigned __int64 UInt;
2451 #else
2452   typedef long long Int;  // NOLINT
2453   typedef unsigned long long UInt;  // NOLINT
2454 #endif  // GTEST_OS_WINDOWS
2455 };
2456 
2457 // Integer types of known sizes.
2458 typedef TypeWithSize<4>::Int Int32;
2459 typedef TypeWithSize<4>::UInt UInt32;
2460 typedef TypeWithSize<8>::Int Int64;
2461 typedef TypeWithSize<8>::UInt UInt64;
2462 typedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.
2463 
2464 // Utilities for command line flags and environment variables.
2465 
2466 // Macro for referencing flags.
2467 #if !defined(GTEST_FLAG)
2468 # define GTEST_FLAG(name) FLAGS_gtest_##name
2469 #endif  // !defined(GTEST_FLAG)
2470 
2471 #if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
2472 # define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
2473 #endif  // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
2474 
2475 #if !defined(GTEST_DECLARE_bool_)
2476 # define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
2477 
2478 // Macros for declaring flags.
2479 # define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
2480 # define GTEST_DECLARE_int32_(name) \
2481     GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
2482 # define GTEST_DECLARE_string_(name) \
2483     GTEST_API_ extern ::std::string GTEST_FLAG(name)
2484 
2485 // Macros for defining flags.
2486 # define GTEST_DEFINE_bool_(name, default_val, doc) \
2487     GTEST_API_ bool GTEST_FLAG(name) = (default_val)
2488 # define GTEST_DEFINE_int32_(name, default_val, doc) \
2489     GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
2490 # define GTEST_DEFINE_string_(name, default_val, doc) \
2491     GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
2492 
2493 #endif  // !defined(GTEST_DECLARE_bool_)
2494 
2495 // Thread annotations
2496 #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2497 # define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
2498 # define GTEST_LOCK_EXCLUDED_(locks)
2499 #endif  // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2500 
2501 // Parses 'str' for a 32-bit signed integer.  If successful, writes the result
2502 // to *value and returns true; otherwise leaves *value unchanged and returns
2503 // false.
2504 bool ParseInt32(const Message& src_text, const char* str, Int32* value);
2505 
2506 // Parses a bool/Int32/string from the environment variable
2507 // corresponding to the given Google Test flag.
2508 bool BoolFromGTestEnv(const char* flag, bool default_val);
2509 GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
2510 std::string OutputFlagAlsoCheckEnvVar();
2511 const char* StringFromGTestEnv(const char* flag, const char* default_val);
2512 
2513 }  // namespace internal
2514 }  // namespace testing
2515 
2516 #if !defined(GTEST_INTERNAL_DEPRECATED)
2517 
2518 // Internal Macro to mark an API deprecated, for googletest usage only
2519 // Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or
2520 // GTEST_INTERNAL_DEPRECATED(message) <return_type> myFunction(); Every usage of
2521 // a deprecated entity will trigger a warning when compiled with
2522 // `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler).
2523 // For msvc /W3 option will need to be used
2524 // Note that for 'other' compilers this macro evaluates to nothing to prevent
2525 // compilations errors.
2526 #if defined(_MSC_VER)
2527 #define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))
2528 #elif defined(__GNUC__)
2529 #define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
2530 #else
2531 #define GTEST_INTERNAL_DEPRECATED(message)
2532 #endif
2533 
2534 #endif  // !defined(GTEST_INTERNAL_DEPRECATED)
2535 
2536 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
2537 
2538 #if GTEST_OS_LINUX
2539 # include <stdlib.h>
2540 # include <sys/types.h>
2541 # include <sys/wait.h>
2542 # include <unistd.h>
2543 #endif  // GTEST_OS_LINUX
2544 
2545 #if GTEST_HAS_EXCEPTIONS
2546 # include <stdexcept>
2547 #endif
2548 
2549 #include <ctype.h>
2550 #include <float.h>
2551 #include <string.h>
2552 #include <iomanip>
2553 #include <limits>
2554 #include <map>
2555 #include <set>
2556 #include <string>
2557 #include <type_traits>
2558 #include <vector>
2559 
2560 // Copyright 2005, Google Inc.
2561 // All rights reserved.
2562 //
2563 // Redistribution and use in source and binary forms, with or without
2564 // modification, are permitted provided that the following conditions are
2565 // met:
2566 //
2567 //     * Redistributions of source code must retain the above copyright
2568 // notice, this list of conditions and the following disclaimer.
2569 //     * Redistributions in binary form must reproduce the above
2570 // copyright notice, this list of conditions and the following disclaimer
2571 // in the documentation and/or other materials provided with the
2572 // distribution.
2573 //     * Neither the name of Google Inc. nor the names of its
2574 // contributors may be used to endorse or promote products derived from
2575 // this software without specific prior written permission.
2576 //
2577 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2578 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2579 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2580 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2581 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2582 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2583 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2584 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2585 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2586 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2587 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2588 
2589 //
2590 // The Google C++ Testing and Mocking Framework (Google Test)
2591 //
2592 // This header file defines the Message class.
2593 //
2594 // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
2595 // leave some internal implementation details in this header file.
2596 // They are clearly marked by comments like this:
2597 //
2598 //   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
2599 //
2600 // Such code is NOT meant to be used by a user directly, and is subject
2601 // to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
2602 // program!
2603 
2604 // GOOGLETEST_CM0001 DO NOT DELETE
2605 
2606 #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2607 #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2608 
2609 #include <limits>
2610 #include <memory>
2611 
2612 
2613 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
2614 /* class A needs to have dll-interface to be used by clients of class B */)
2615 
2616 // Ensures that there is at least one operator<< in the global namespace.
2617 // See Message& operator<<(...) below for why.
2618 void operator<<(const testing::internal::Secret&, int);
2619 
2620 namespace testing {
2621 
2622 // The Message class works like an ostream repeater.
2623 //
2624 // Typical usage:
2625 //
2626 //   1. You stream a bunch of values to a Message object.
2627 //      It will remember the text in a stringstream.
2628 //   2. Then you stream the Message object to an ostream.
2629 //      This causes the text in the Message to be streamed
2630 //      to the ostream.
2631 //
2632 // For example;
2633 //
2634 //   testing::Message foo;
2635 //   foo << 1 << " != " << 2;
2636 //   std::cout << foo;
2637 //
2638 // will print "1 != 2".
2639 //
2640 // Message is not intended to be inherited from.  In particular, its
2641 // destructor is not virtual.
2642 //
2643 // Note that stringstream behaves differently in gcc and in MSVC.  You
2644 // can stream a NULL char pointer to it in the former, but not in the
2645 // latter (it causes an access violation if you do).  The Message
2646 // class hides this difference by treating a NULL char pointer as
2647 // "(null)".
2648 class GTEST_API_ Message {
2649  private:
2650   // The type of basic IO manipulators (endl, ends, and flush) for
2651   // narrow streams.
2652   typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
2653 
2654  public:
2655   // Constructs an empty Message.
2656   Message();
2657 
2658   // Copy constructor.
2659   Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT
2660     *ss_ << msg.GetString();
2661   }
2662 
2663   // Constructs a Message from a C-string.
2664   explicit Message(const char* str) : ss_(new ::std::stringstream) {
2665     *ss_ << str;
2666   }
2667 
2668   // Streams a non-pointer value to this object.
2669   template <typename T>
2670   inline Message& operator <<(const T& val) {
2671     // Some libraries overload << for STL containers.  These
2672     // overloads are defined in the global namespace instead of ::std.
2673     //
2674     // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
2675     // overloads are visible in either the std namespace or the global
2676     // namespace, but not other namespaces, including the testing
2677     // namespace which Google Test's Message class is in.
2678     //
2679     // To allow STL containers (and other types that has a << operator
2680     // defined in the global namespace) to be used in Google Test
2681     // assertions, testing::Message must access the custom << operator
2682     // from the global namespace.  With this using declaration,
2683     // overloads of << defined in the global namespace and those
2684     // visible via Koenig lookup are both exposed in this function.
2685     using ::operator <<;
2686     *ss_ << val;
2687     return *this;
2688   }
2689 
2690   // Streams a pointer value to this object.
2691   //
2692   // This function is an overload of the previous one.  When you
2693   // stream a pointer to a Message, this definition will be used as it
2694   // is more specialized.  (The C++ Standard, section
2695   // [temp.func.order].)  If you stream a non-pointer, then the
2696   // previous definition will be used.
2697   //
2698   // The reason for this overload is that streaming a NULL pointer to
2699   // ostream is undefined behavior.  Depending on the compiler, you
2700   // may get "0", "(nil)", "(null)", or an access violation.  To
2701   // ensure consistent result across compilers, we always treat NULL
2702   // as "(null)".
2703   template <typename T>
2704   inline Message& operator <<(T* const& pointer) {  // NOLINT
2705     if (pointer == nullptr) {
2706       *ss_ << "(null)";
2707     } else {
2708       *ss_ << pointer;
2709     }
2710     return *this;
2711   }
2712 
2713   // Since the basic IO manipulators are overloaded for both narrow
2714   // and wide streams, we have to provide this specialized definition
2715   // of operator <<, even though its body is the same as the
2716   // templatized version above.  Without this definition, streaming
2717   // endl or other basic IO manipulators to Message will confuse the
2718   // compiler.
2719   Message& operator <<(BasicNarrowIoManip val) {
2720     *ss_ << val;
2721     return *this;
2722   }
2723 
2724   // Instead of 1/0, we want to see true/false for bool values.
2725   Message& operator <<(bool b) {
2726     return *this << (b ? "true" : "false");
2727   }
2728 
2729   // These two overloads allow streaming a wide C string to a Message
2730   // using the UTF-8 encoding.
2731   Message& operator <<(const wchar_t* wide_c_str);
2732   Message& operator <<(wchar_t* wide_c_str);
2733 
2734 #if GTEST_HAS_STD_WSTRING
2735   // Converts the given wide string to a narrow string using the UTF-8
2736   // encoding, and streams the result to this Message object.
2737   Message& operator <<(const ::std::wstring& wstr);
2738 #endif  // GTEST_HAS_STD_WSTRING
2739 
2740   // Gets the text streamed to this object so far as an std::string.
2741   // Each '\0' character in the buffer is replaced with "\\0".
2742   //
2743   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
2744   std::string GetString() const;
2745 
2746  private:
2747   // We'll hold the text streamed to this object here.
2748   const std::unique_ptr< ::std::stringstream> ss_;
2749 
2750   // We declare (but don't implement) this to prevent the compiler
2751   // from implementing the assignment operator.
2752   void operator=(const Message&);
2753 };
2754 
2755 // Streams a Message to an ostream.
2756 inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
2757   return os << sb.GetString();
2758 }
2759 
2760 namespace internal {
2761 
2762 // Converts a streamable value to an std::string.  A NULL pointer is
2763 // converted to "(null)".  When the input value is a ::string,
2764 // ::std::string, ::wstring, or ::std::wstring object, each NUL
2765 // character in it is replaced with "\\0".
2766 template <typename T>
2767 std::string StreamableToString(const T& streamable) {
2768   return (Message() << streamable).GetString();
2769 }
2770 
2771 }  // namespace internal
2772 }  // namespace testing
2773 
2774 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
2775 
2776 #endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2777 // Copyright 2008, Google Inc.
2778 // All rights reserved.
2779 //
2780 // Redistribution and use in source and binary forms, with or without
2781 // modification, are permitted provided that the following conditions are
2782 // met:
2783 //
2784 //     * Redistributions of source code must retain the above copyright
2785 // notice, this list of conditions and the following disclaimer.
2786 //     * Redistributions in binary form must reproduce the above
2787 // copyright notice, this list of conditions and the following disclaimer
2788 // in the documentation and/or other materials provided with the
2789 // distribution.
2790 //     * Neither the name of Google Inc. nor the names of its
2791 // contributors may be used to endorse or promote products derived from
2792 // this software without specific prior written permission.
2793 //
2794 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2795 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2796 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2797 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2798 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2799 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2800 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2801 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2802 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2803 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2804 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2805 //
2806 // Google Test filepath utilities
2807 //
2808 // This header file declares classes and functions used internally by
2809 // Google Test.  They are subject to change without notice.
2810 //
2811 // This file is #included in gtest/internal/gtest-internal.h.
2812 // Do not include this header file separately!
2813 
2814 // GOOGLETEST_CM0001 DO NOT DELETE
2815 
2816 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
2817 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
2818 
2819 // Copyright 2005, Google Inc.
2820 // All rights reserved.
2821 //
2822 // Redistribution and use in source and binary forms, with or without
2823 // modification, are permitted provided that the following conditions are
2824 // met:
2825 //
2826 //     * Redistributions of source code must retain the above copyright
2827 // notice, this list of conditions and the following disclaimer.
2828 //     * Redistributions in binary form must reproduce the above
2829 // copyright notice, this list of conditions and the following disclaimer
2830 // in the documentation and/or other materials provided with the
2831 // distribution.
2832 //     * Neither the name of Google Inc. nor the names of its
2833 // contributors may be used to endorse or promote products derived from
2834 // this software without specific prior written permission.
2835 //
2836 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2837 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2838 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2839 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2840 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2841 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2842 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2843 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2844 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2845 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2846 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2847 //
2848 // The Google C++ Testing and Mocking Framework (Google Test)
2849 //
2850 // This header file declares the String class and functions used internally by
2851 // Google Test.  They are subject to change without notice. They should not used
2852 // by code external to Google Test.
2853 //
2854 // This header file is #included by gtest-internal.h.
2855 // It should not be #included by other files.
2856 
2857 // GOOGLETEST_CM0001 DO NOT DELETE
2858 
2859 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2860 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2861 
2862 #ifdef __BORLANDC__
2863 // string.h is not guaranteed to provide strcpy on C++ Builder.
2864 # include <mem.h>
2865 #endif
2866 
2867 #include <string.h>
2868 #include <string>
2869 
2870 
2871 namespace testing {
2872 namespace internal {
2873 
2874 // String - an abstract class holding static string utilities.
2875 class GTEST_API_ String {
2876  public:
2877   // Static utility methods
2878 
2879   // Clones a 0-terminated C string, allocating memory using new.  The
2880   // caller is responsible for deleting the return value using
2881   // delete[].  Returns the cloned string, or NULL if the input is
2882   // NULL.
2883   //
2884   // This is different from strdup() in string.h, which allocates
2885   // memory using malloc().
2886   static const char* CloneCString(const char* c_str);
2887 
2888 #if GTEST_OS_WINDOWS_MOBILE
2889   // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
2890   // able to pass strings to Win32 APIs on CE we need to convert them
2891   // to 'Unicode', UTF-16.
2892 
2893   // Creates a UTF-16 wide string from the given ANSI string, allocating
2894   // memory using new. The caller is responsible for deleting the return
2895   // value using delete[]. Returns the wide string, or NULL if the
2896   // input is NULL.
2897   //
2898   // The wide string is created using the ANSI codepage (CP_ACP) to
2899   // match the behaviour of the ANSI versions of Win32 calls and the
2900   // C runtime.
2901   static LPCWSTR AnsiToUtf16(const char* c_str);
2902 
2903   // Creates an ANSI string from the given wide string, allocating
2904   // memory using new. The caller is responsible for deleting the return
2905   // value using delete[]. Returns the ANSI string, or NULL if the
2906   // input is NULL.
2907   //
2908   // The returned string is created using the ANSI codepage (CP_ACP) to
2909   // match the behaviour of the ANSI versions of Win32 calls and the
2910   // C runtime.
2911   static const char* Utf16ToAnsi(LPCWSTR utf16_str);
2912 #endif
2913 
2914   // Compares two C strings.  Returns true iff they have the same content.
2915   //
2916   // Unlike strcmp(), this function can handle NULL argument(s).  A
2917   // NULL C string is considered different to any non-NULL C string,
2918   // including the empty string.
2919   static bool CStringEquals(const char* lhs, const char* rhs);
2920 
2921   // Converts a wide C string to a String using the UTF-8 encoding.
2922   // NULL will be converted to "(null)".  If an error occurred during
2923   // the conversion, "(failed to convert from wide string)" is
2924   // returned.
2925   static std::string ShowWideCString(const wchar_t* wide_c_str);
2926 
2927   // Compares two wide C strings.  Returns true iff they have the same
2928   // content.
2929   //
2930   // Unlike wcscmp(), this function can handle NULL argument(s).  A
2931   // NULL C string is considered different to any non-NULL C string,
2932   // including the empty string.
2933   static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
2934 
2935   // Compares two C strings, ignoring case.  Returns true iff they
2936   // have the same content.
2937   //
2938   // Unlike strcasecmp(), this function can handle NULL argument(s).
2939   // A NULL C string is considered different to any non-NULL C string,
2940   // including the empty string.
2941   static bool CaseInsensitiveCStringEquals(const char* lhs,
2942                                            const char* rhs);
2943 
2944   // Compares two wide C strings, ignoring case.  Returns true iff they
2945   // have the same content.
2946   //
2947   // Unlike wcscasecmp(), this function can handle NULL argument(s).
2948   // A NULL C string is considered different to any non-NULL wide C string,
2949   // including the empty string.
2950   // NB: The implementations on different platforms slightly differ.
2951   // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
2952   // environment variable. On GNU platform this method uses wcscasecmp
2953   // which compares according to LC_CTYPE category of the current locale.
2954   // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
2955   // current locale.
2956   static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
2957                                                const wchar_t* rhs);
2958 
2959   // Returns true iff the given string ends with the given suffix, ignoring
2960   // case. Any string is considered to end with an empty suffix.
2961   static bool EndsWithCaseInsensitive(
2962       const std::string& str, const std::string& suffix);
2963 
2964   // Formats an int value as "%02d".
2965   static std::string FormatIntWidth2(int value);  // "%02d" for width == 2
2966 
2967   // Formats an int value as "%X".
2968   static std::string FormatHexInt(int value);
2969 
2970   // Formats a byte as "%02X".
2971   static std::string FormatByte(unsigned char value);
2972 
2973  private:
2974   String();  // Not meant to be instantiated.
2975 };  // class String
2976 
2977 // Gets the content of the stringstream's buffer as an std::string.  Each '\0'
2978 // character in the buffer is replaced with "\\0".
2979 GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
2980 
2981 }  // namespace internal
2982 }  // namespace testing
2983 
2984 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2985 
2986 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
2987 /* class A needs to have dll-interface to be used by clients of class B */)
2988 
2989 namespace testing {
2990 namespace internal {
2991 
2992 // FilePath - a class for file and directory pathname manipulation which
2993 // handles platform-specific conventions (like the pathname separator).
2994 // Used for helper functions for naming files in a directory for xml output.
2995 // Except for Set methods, all methods are const or static, which provides an
2996 // "immutable value object" -- useful for peace of mind.
2997 // A FilePath with a value ending in a path separator ("like/this/") represents
2998 // a directory, otherwise it is assumed to represent a file. In either case,
2999 // it may or may not represent an actual file or directory in the file system.
3000 // Names are NOT checked for syntax correctness -- no checking for illegal
3001 // characters, malformed paths, etc.
3002 
3003 class GTEST_API_ FilePath {
3004  public:
3005   FilePath() : pathname_("") { }
3006   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
3007 
3008   explicit FilePath(const std::string& pathname) : pathname_(pathname) {
3009     Normalize();
3010   }
3011 
3012   FilePath& operator=(const FilePath& rhs) {
3013     Set(rhs);
3014     return *this;
3015   }
3016 
3017   void Set(const FilePath& rhs) {
3018     pathname_ = rhs.pathname_;
3019   }
3020 
3021   const std::string& string() const { return pathname_; }
3022   const char* c_str() const { return pathname_.c_str(); }
3023 
3024   // Returns the current working directory, or "" if unsuccessful.
3025   static FilePath GetCurrentDir();
3026 
3027   // Given directory = "dir", base_name = "test", number = 0,
3028   // extension = "xml", returns "dir/test.xml". If number is greater
3029   // than zero (e.g., 12), returns "dir/test_12.xml".
3030   // On Windows platform, uses \ as the separator rather than /.
3031   static FilePath MakeFileName(const FilePath& directory,
3032                                const FilePath& base_name,
3033                                int number,
3034                                const char* extension);
3035 
3036   // Given directory = "dir", relative_path = "test.xml",
3037   // returns "dir/test.xml".
3038   // On Windows, uses \ as the separator rather than /.
3039   static FilePath ConcatPaths(const FilePath& directory,
3040                               const FilePath& relative_path);
3041 
3042   // Returns a pathname for a file that does not currently exist. The pathname
3043   // will be directory/base_name.extension or
3044   // directory/base_name_<number>.extension if directory/base_name.extension
3045   // already exists. The number will be incremented until a pathname is found
3046   // that does not already exist.
3047   // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
3048   // There could be a race condition if two or more processes are calling this
3049   // function at the same time -- they could both pick the same filename.
3050   static FilePath GenerateUniqueFileName(const FilePath& directory,
3051                                          const FilePath& base_name,
3052                                          const char* extension);
3053 
3054   // Returns true iff the path is "".
3055   bool IsEmpty() const { return pathname_.empty(); }
3056 
3057   // If input name has a trailing separator character, removes it and returns
3058   // the name, otherwise return the name string unmodified.
3059   // On Windows platform, uses \ as the separator, other platforms use /.
3060   FilePath RemoveTrailingPathSeparator() const;
3061 
3062   // Returns a copy of the FilePath with the directory part removed.
3063   // Example: FilePath("path/to/file").RemoveDirectoryName() returns
3064   // FilePath("file"). If there is no directory part ("just_a_file"), it returns
3065   // the FilePath unmodified. If there is no file part ("just_a_dir/") it
3066   // returns an empty FilePath ("").
3067   // On Windows platform, '\' is the path separator, otherwise it is '/'.
3068   FilePath RemoveDirectoryName() const;
3069 
3070   // RemoveFileName returns the directory path with the filename removed.
3071   // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
3072   // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
3073   // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
3074   // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
3075   // On Windows platform, '\' is the path separator, otherwise it is '/'.
3076   FilePath RemoveFileName() const;
3077 
3078   // Returns a copy of the FilePath with the case-insensitive extension removed.
3079   // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
3080   // FilePath("dir/file"). If a case-insensitive extension is not
3081   // found, returns a copy of the original FilePath.
3082   FilePath RemoveExtension(const char* extension) const;
3083 
3084   // Creates directories so that path exists. Returns true if successful or if
3085   // the directories already exist; returns false if unable to create
3086   // directories for any reason. Will also return false if the FilePath does
3087   // not represent a directory (that is, it doesn't end with a path separator).
3088   bool CreateDirectoriesRecursively() const;
3089 
3090   // Create the directory so that path exists. Returns true if successful or
3091   // if the directory already exists; returns false if unable to create the
3092   // directory for any reason, including if the parent directory does not
3093   // exist. Not named "CreateDirectory" because that's a macro on Windows.
3094   bool CreateFolder() const;
3095 
3096   // Returns true if FilePath describes something in the file-system,
3097   // either a file, directory, or whatever, and that something exists.
3098   bool FileOrDirectoryExists() const;
3099 
3100   // Returns true if pathname describes a directory in the file-system
3101   // that exists.
3102   bool DirectoryExists() const;
3103 
3104   // Returns true if FilePath ends with a path separator, which indicates that
3105   // it is intended to represent a directory. Returns false otherwise.
3106   // This does NOT check that a directory (or file) actually exists.
3107   bool IsDirectory() const;
3108 
3109   // Returns true if pathname describes a root directory. (Windows has one
3110   // root directory per disk drive.)
3111   bool IsRootDirectory() const;
3112 
3113   // Returns true if pathname describes an absolute path.
3114   bool IsAbsolutePath() const;
3115 
3116  private:
3117   // Replaces multiple consecutive separators with a single separator.
3118   // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
3119   // redundancies that might be in a pathname involving "." or "..".
3120   //
3121   // A pathname with multiple consecutive separators may occur either through
3122   // user error or as a result of some scripts or APIs that generate a pathname
3123   // with a trailing separator. On other platforms the same API or script
3124   // may NOT generate a pathname with a trailing "/". Then elsewhere that
3125   // pathname may have another "/" and pathname components added to it,
3126   // without checking for the separator already being there.
3127   // The script language and operating system may allow paths like "foo//bar"
3128   // but some of the functions in FilePath will not handle that correctly. In
3129   // particular, RemoveTrailingPathSeparator() only removes one separator, and
3130   // it is called in CreateDirectoriesRecursively() assuming that it will change
3131   // a pathname from directory syntax (trailing separator) to filename syntax.
3132   //
3133   // On Windows this method also replaces the alternate path separator '/' with
3134   // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
3135   // "bar\\foo".
3136 
3137   void Normalize();
3138 
3139   // Returns a pointer to the last occurence of a valid path separator in
3140   // the FilePath. On Windows, for example, both '/' and '\' are valid path
3141   // separators. Returns NULL if no path separator was found.
3142   const char* FindLastPathSeparator() const;
3143 
3144   std::string pathname_;
3145 };  // class FilePath
3146 
3147 }  // namespace internal
3148 }  // namespace testing
3149 
3150 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
3151 
3152 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
3153 // This file was GENERATED by command:
3154 //     pump.py gtest-type-util.h.pump
3155 // DO NOT EDIT BY HAND!!!
3156 
3157 // Copyright 2008 Google Inc.
3158 // All Rights Reserved.
3159 //
3160 // Redistribution and use in source and binary forms, with or without
3161 // modification, are permitted provided that the following conditions are
3162 // met:
3163 //
3164 //     * Redistributions of source code must retain the above copyright
3165 // notice, this list of conditions and the following disclaimer.
3166 //     * Redistributions in binary form must reproduce the above
3167 // copyright notice, this list of conditions and the following disclaimer
3168 // in the documentation and/or other materials provided with the
3169 // distribution.
3170 //     * Neither the name of Google Inc. nor the names of its
3171 // contributors may be used to endorse or promote products derived from
3172 // this software without specific prior written permission.
3173 //
3174 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3175 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3176 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3177 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3178 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3179 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3180 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3181 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3182 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3183 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3184 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3185 
3186 // Type utilities needed for implementing typed and type-parameterized
3187 // tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
3188 //
3189 // Currently we support at most 50 types in a list, and at most 50
3190 // type-parameterized tests in one type-parameterized test suite.
3191 // Please contact googletestframework@googlegroups.com if you need
3192 // more.
3193 
3194 // GOOGLETEST_CM0001 DO NOT DELETE
3195 
3196 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3197 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3198 
3199 
3200 // #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
3201 // libstdc++ (which is where cxxabi.h comes from).
3202 # if GTEST_HAS_CXXABI_H_
3203 #  include <cxxabi.h>
3204 # elif defined(__HP_aCC)
3205 #  include <acxx_demangle.h>
3206 # endif  // GTEST_HASH_CXXABI_H_
3207 
3208 namespace testing {
3209 namespace internal {
3210 
3211 // Canonicalizes a given name with respect to the Standard C++ Library.
3212 // This handles removing the inline namespace within `std` that is
3213 // used by various standard libraries (e.g., `std::__1`).  Names outside
3214 // of namespace std are returned unmodified.
3215 inline std::string CanonicalizeForStdLibVersioning(std::string s) {
3216   static const char prefix[] = "std::__";
3217   if (s.compare(0, strlen(prefix), prefix) == 0) {
3218     std::string::size_type end = s.find("::", strlen(prefix));
3219     if (end != s.npos) {
3220       // Erase everything between the initial `std` and the second `::`.
3221       s.erase(strlen("std"), end - strlen("std"));
3222     }
3223   }
3224   return s;
3225 }
3226 
3227 // GetTypeName<T>() returns a human-readable name of type T.
3228 // NB: This function is also used in Google Mock, so don't move it inside of
3229 // the typed-test-only section below.
3230 template <typename T>
3231 std::string GetTypeName() {
3232 # if GTEST_HAS_RTTI
3233 
3234   const char* const name = typeid(T).name();
3235 #  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
3236   int status = 0;
3237   // gcc's implementation of typeid(T).name() mangles the type name,
3238   // so we have to demangle it.
3239 #   if GTEST_HAS_CXXABI_H_
3240   using abi::__cxa_demangle;
3241 #   endif  // GTEST_HAS_CXXABI_H_
3242   char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status);
3243   const std::string name_str(status == 0 ? readable_name : name);
3244   free(readable_name);
3245   return CanonicalizeForStdLibVersioning(name_str);
3246 #  else
3247   return name;
3248 #  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC
3249 
3250 # else
3251 
3252   return "<type>";
3253 
3254 # endif  // GTEST_HAS_RTTI
3255 }
3256 
3257 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
3258 
3259 // AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
3260 // type.  This can be used as a compile-time assertion to ensure that
3261 // two types are equal.
3262 
3263 template <typename T1, typename T2>
3264 struct AssertTypeEq;
3265 
3266 template <typename T>
3267 struct AssertTypeEq<T, T> {
3268   typedef bool type;
3269 };
3270 
3271 // A unique type used as the default value for the arguments of class
3272 // template Types.  This allows us to simulate variadic templates
3273 // (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
3274 // support directly.
3275 struct None {};
3276 
3277 // The following family of struct and struct templates are used to
3278 // represent type lists.  In particular, TypesN<T1, T2, ..., TN>
3279 // represents a type list with N types (T1, T2, ..., and TN) in it.
3280 // Except for Types0, every struct in the family has two member types:
3281 // Head for the first type in the list, and Tail for the rest of the
3282 // list.
3283 
3284 // The empty type list.
3285 struct Types0 {};
3286 
3287 // Type lists of length 1, 2, 3, and so on.
3288 
3289 template <typename T1>
3290 struct Types1 {
3291   typedef T1 Head;
3292   typedef Types0 Tail;
3293 };
3294 template <typename T1, typename T2>
3295 struct Types2 {
3296   typedef T1 Head;
3297   typedef Types1<T2> Tail;
3298 };
3299 
3300 template <typename T1, typename T2, typename T3>
3301 struct Types3 {
3302   typedef T1 Head;
3303   typedef Types2<T2, T3> Tail;
3304 };
3305 
3306 template <typename T1, typename T2, typename T3, typename T4>
3307 struct Types4 {
3308   typedef T1 Head;
3309   typedef Types3<T2, T3, T4> Tail;
3310 };
3311 
3312 template <typename T1, typename T2, typename T3, typename T4, typename T5>
3313 struct Types5 {
3314   typedef T1 Head;
3315   typedef Types4<T2, T3, T4, T5> Tail;
3316 };
3317 
3318 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3319     typename T6>
3320 struct Types6 {
3321   typedef T1 Head;
3322   typedef Types5<T2, T3, T4, T5, T6> Tail;
3323 };
3324 
3325 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3326     typename T6, typename T7>
3327 struct Types7 {
3328   typedef T1 Head;
3329   typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
3330 };
3331 
3332 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3333     typename T6, typename T7, typename T8>
3334 struct Types8 {
3335   typedef T1 Head;
3336   typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
3337 };
3338 
3339 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3340     typename T6, typename T7, typename T8, typename T9>
3341 struct Types9 {
3342   typedef T1 Head;
3343   typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
3344 };
3345 
3346 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3347     typename T6, typename T7, typename T8, typename T9, typename T10>
3348 struct Types10 {
3349   typedef T1 Head;
3350   typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
3351 };
3352 
3353 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3354     typename T6, typename T7, typename T8, typename T9, typename T10,
3355     typename T11>
3356 struct Types11 {
3357   typedef T1 Head;
3358   typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
3359 };
3360 
3361 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3362     typename T6, typename T7, typename T8, typename T9, typename T10,
3363     typename T11, typename T12>
3364 struct Types12 {
3365   typedef T1 Head;
3366   typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
3367 };
3368 
3369 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3370     typename T6, typename T7, typename T8, typename T9, typename T10,
3371     typename T11, typename T12, typename T13>
3372 struct Types13 {
3373   typedef T1 Head;
3374   typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
3375 };
3376 
3377 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3378     typename T6, typename T7, typename T8, typename T9, typename T10,
3379     typename T11, typename T12, typename T13, typename T14>
3380 struct Types14 {
3381   typedef T1 Head;
3382   typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
3383 };
3384 
3385 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3386     typename T6, typename T7, typename T8, typename T9, typename T10,
3387     typename T11, typename T12, typename T13, typename T14, typename T15>
3388 struct Types15 {
3389   typedef T1 Head;
3390   typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
3391       T15> Tail;
3392 };
3393 
3394 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3395     typename T6, typename T7, typename T8, typename T9, typename T10,
3396     typename T11, typename T12, typename T13, typename T14, typename T15,
3397     typename T16>
3398 struct Types16 {
3399   typedef T1 Head;
3400   typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3401       T16> Tail;
3402 };
3403 
3404 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3405     typename T6, typename T7, typename T8, typename T9, typename T10,
3406     typename T11, typename T12, typename T13, typename T14, typename T15,
3407     typename T16, typename T17>
3408 struct Types17 {
3409   typedef T1 Head;
3410   typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3411       T16, T17> Tail;
3412 };
3413 
3414 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3415     typename T6, typename T7, typename T8, typename T9, typename T10,
3416     typename T11, typename T12, typename T13, typename T14, typename T15,
3417     typename T16, typename T17, typename T18>
3418 struct Types18 {
3419   typedef T1 Head;
3420   typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3421       T16, T17, T18> Tail;
3422 };
3423 
3424 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3425     typename T6, typename T7, typename T8, typename T9, typename T10,
3426     typename T11, typename T12, typename T13, typename T14, typename T15,
3427     typename T16, typename T17, typename T18, typename T19>
3428 struct Types19 {
3429   typedef T1 Head;
3430   typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3431       T16, T17, T18, T19> Tail;
3432 };
3433 
3434 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3435     typename T6, typename T7, typename T8, typename T9, typename T10,
3436     typename T11, typename T12, typename T13, typename T14, typename T15,
3437     typename T16, typename T17, typename T18, typename T19, typename T20>
3438 struct Types20 {
3439   typedef T1 Head;
3440   typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3441       T16, T17, T18, T19, T20> Tail;
3442 };
3443 
3444 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3445     typename T6, typename T7, typename T8, typename T9, typename T10,
3446     typename T11, typename T12, typename T13, typename T14, typename T15,
3447     typename T16, typename T17, typename T18, typename T19, typename T20,
3448     typename T21>
3449 struct Types21 {
3450   typedef T1 Head;
3451   typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3452       T16, T17, T18, T19, T20, T21> Tail;
3453 };
3454 
3455 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3456     typename T6, typename T7, typename T8, typename T9, typename T10,
3457     typename T11, typename T12, typename T13, typename T14, typename T15,
3458     typename T16, typename T17, typename T18, typename T19, typename T20,
3459     typename T21, typename T22>
3460 struct Types22 {
3461   typedef T1 Head;
3462   typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3463       T16, T17, T18, T19, T20, T21, T22> Tail;
3464 };
3465 
3466 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3467     typename T6, typename T7, typename T8, typename T9, typename T10,
3468     typename T11, typename T12, typename T13, typename T14, typename T15,
3469     typename T16, typename T17, typename T18, typename T19, typename T20,
3470     typename T21, typename T22, typename T23>
3471 struct Types23 {
3472   typedef T1 Head;
3473   typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3474       T16, T17, T18, T19, T20, T21, T22, T23> Tail;
3475 };
3476 
3477 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3478     typename T6, typename T7, typename T8, typename T9, typename T10,
3479     typename T11, typename T12, typename T13, typename T14, typename T15,
3480     typename T16, typename T17, typename T18, typename T19, typename T20,
3481     typename T21, typename T22, typename T23, typename T24>
3482 struct Types24 {
3483   typedef T1 Head;
3484   typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3485       T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
3486 };
3487 
3488 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3489     typename T6, typename T7, typename T8, typename T9, typename T10,
3490     typename T11, typename T12, typename T13, typename T14, typename T15,
3491     typename T16, typename T17, typename T18, typename T19, typename T20,
3492     typename T21, typename T22, typename T23, typename T24, typename T25>
3493 struct Types25 {
3494   typedef T1 Head;
3495   typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3496       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
3497 };
3498 
3499 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3500     typename T6, typename T7, typename T8, typename T9, typename T10,
3501     typename T11, typename T12, typename T13, typename T14, typename T15,
3502     typename T16, typename T17, typename T18, typename T19, typename T20,
3503     typename T21, typename T22, typename T23, typename T24, typename T25,
3504     typename T26>
3505 struct Types26 {
3506   typedef T1 Head;
3507   typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3508       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
3509 };
3510 
3511 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3512     typename T6, typename T7, typename T8, typename T9, typename T10,
3513     typename T11, typename T12, typename T13, typename T14, typename T15,
3514     typename T16, typename T17, typename T18, typename T19, typename T20,
3515     typename T21, typename T22, typename T23, typename T24, typename T25,
3516     typename T26, typename T27>
3517 struct Types27 {
3518   typedef T1 Head;
3519   typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3520       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
3521 };
3522 
3523 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3524     typename T6, typename T7, typename T8, typename T9, typename T10,
3525     typename T11, typename T12, typename T13, typename T14, typename T15,
3526     typename T16, typename T17, typename T18, typename T19, typename T20,
3527     typename T21, typename T22, typename T23, typename T24, typename T25,
3528     typename T26, typename T27, typename T28>
3529 struct Types28 {
3530   typedef T1 Head;
3531   typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3532       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
3533 };
3534 
3535 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3536     typename T6, typename T7, typename T8, typename T9, typename T10,
3537     typename T11, typename T12, typename T13, typename T14, typename T15,
3538     typename T16, typename T17, typename T18, typename T19, typename T20,
3539     typename T21, typename T22, typename T23, typename T24, typename T25,
3540     typename T26, typename T27, typename T28, typename T29>
3541 struct Types29 {
3542   typedef T1 Head;
3543   typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3544       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
3545       T29> Tail;
3546 };
3547 
3548 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3549     typename T6, typename T7, typename T8, typename T9, typename T10,
3550     typename T11, typename T12, typename T13, typename T14, typename T15,
3551     typename T16, typename T17, typename T18, typename T19, typename T20,
3552     typename T21, typename T22, typename T23, typename T24, typename T25,
3553     typename T26, typename T27, typename T28, typename T29, typename T30>
3554 struct Types30 {
3555   typedef T1 Head;
3556   typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3557       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3558       T30> Tail;
3559 };
3560 
3561 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3562     typename T6, typename T7, typename T8, typename T9, typename T10,
3563     typename T11, typename T12, typename T13, typename T14, typename T15,
3564     typename T16, typename T17, typename T18, typename T19, typename T20,
3565     typename T21, typename T22, typename T23, typename T24, typename T25,
3566     typename T26, typename T27, typename T28, typename T29, typename T30,
3567     typename T31>
3568 struct Types31 {
3569   typedef T1 Head;
3570   typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3571       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3572       T30, T31> Tail;
3573 };
3574 
3575 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3576     typename T6, typename T7, typename T8, typename T9, typename T10,
3577     typename T11, typename T12, typename T13, typename T14, typename T15,
3578     typename T16, typename T17, typename T18, typename T19, typename T20,
3579     typename T21, typename T22, typename T23, typename T24, typename T25,
3580     typename T26, typename T27, typename T28, typename T29, typename T30,
3581     typename T31, typename T32>
3582 struct Types32 {
3583   typedef T1 Head;
3584   typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3585       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3586       T30, T31, T32> Tail;
3587 };
3588 
3589 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3590     typename T6, typename T7, typename T8, typename T9, typename T10,
3591     typename T11, typename T12, typename T13, typename T14, typename T15,
3592     typename T16, typename T17, typename T18, typename T19, typename T20,
3593     typename T21, typename T22, typename T23, typename T24, typename T25,
3594     typename T26, typename T27, typename T28, typename T29, typename T30,
3595     typename T31, typename T32, typename T33>
3596 struct Types33 {
3597   typedef T1 Head;
3598   typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3599       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3600       T30, T31, T32, T33> Tail;
3601 };
3602 
3603 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3604     typename T6, typename T7, typename T8, typename T9, typename T10,
3605     typename T11, typename T12, typename T13, typename T14, typename T15,
3606     typename T16, typename T17, typename T18, typename T19, typename T20,
3607     typename T21, typename T22, typename T23, typename T24, typename T25,
3608     typename T26, typename T27, typename T28, typename T29, typename T30,
3609     typename T31, typename T32, typename T33, typename T34>
3610 struct Types34 {
3611   typedef T1 Head;
3612   typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3613       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3614       T30, T31, T32, T33, T34> Tail;
3615 };
3616 
3617 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3618     typename T6, typename T7, typename T8, typename T9, typename T10,
3619     typename T11, typename T12, typename T13, typename T14, typename T15,
3620     typename T16, typename T17, typename T18, typename T19, typename T20,
3621     typename T21, typename T22, typename T23, typename T24, typename T25,
3622     typename T26, typename T27, typename T28, typename T29, typename T30,
3623     typename T31, typename T32, typename T33, typename T34, typename T35>
3624 struct Types35 {
3625   typedef T1 Head;
3626   typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3627       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3628       T30, T31, T32, T33, T34, T35> Tail;
3629 };
3630 
3631 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3632     typename T6, typename T7, typename T8, typename T9, typename T10,
3633     typename T11, typename T12, typename T13, typename T14, typename T15,
3634     typename T16, typename T17, typename T18, typename T19, typename T20,
3635     typename T21, typename T22, typename T23, typename T24, typename T25,
3636     typename T26, typename T27, typename T28, typename T29, typename T30,
3637     typename T31, typename T32, typename T33, typename T34, typename T35,
3638     typename T36>
3639 struct Types36 {
3640   typedef T1 Head;
3641   typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3642       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3643       T30, T31, T32, T33, T34, T35, T36> Tail;
3644 };
3645 
3646 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3647     typename T6, typename T7, typename T8, typename T9, typename T10,
3648     typename T11, typename T12, typename T13, typename T14, typename T15,
3649     typename T16, typename T17, typename T18, typename T19, typename T20,
3650     typename T21, typename T22, typename T23, typename T24, typename T25,
3651     typename T26, typename T27, typename T28, typename T29, typename T30,
3652     typename T31, typename T32, typename T33, typename T34, typename T35,
3653     typename T36, typename T37>
3654 struct Types37 {
3655   typedef T1 Head;
3656   typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3657       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3658       T30, T31, T32, T33, T34, T35, T36, T37> Tail;
3659 };
3660 
3661 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3662     typename T6, typename T7, typename T8, typename T9, typename T10,
3663     typename T11, typename T12, typename T13, typename T14, typename T15,
3664     typename T16, typename T17, typename T18, typename T19, typename T20,
3665     typename T21, typename T22, typename T23, typename T24, typename T25,
3666     typename T26, typename T27, typename T28, typename T29, typename T30,
3667     typename T31, typename T32, typename T33, typename T34, typename T35,
3668     typename T36, typename T37, typename T38>
3669 struct Types38 {
3670   typedef T1 Head;
3671   typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3672       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3673       T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
3674 };
3675 
3676 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3677     typename T6, typename T7, typename T8, typename T9, typename T10,
3678     typename T11, typename T12, typename T13, typename T14, typename T15,
3679     typename T16, typename T17, typename T18, typename T19, typename T20,
3680     typename T21, typename T22, typename T23, typename T24, typename T25,
3681     typename T26, typename T27, typename T28, typename T29, typename T30,
3682     typename T31, typename T32, typename T33, typename T34, typename T35,
3683     typename T36, typename T37, typename T38, typename T39>
3684 struct Types39 {
3685   typedef T1 Head;
3686   typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3687       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3688       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
3689 };
3690 
3691 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3692     typename T6, typename T7, typename T8, typename T9, typename T10,
3693     typename T11, typename T12, typename T13, typename T14, typename T15,
3694     typename T16, typename T17, typename T18, typename T19, typename T20,
3695     typename T21, typename T22, typename T23, typename T24, typename T25,
3696     typename T26, typename T27, typename T28, typename T29, typename T30,
3697     typename T31, typename T32, typename T33, typename T34, typename T35,
3698     typename T36, typename T37, typename T38, typename T39, typename T40>
3699 struct Types40 {
3700   typedef T1 Head;
3701   typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3702       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3703       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
3704 };
3705 
3706 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3707     typename T6, typename T7, typename T8, typename T9, typename T10,
3708     typename T11, typename T12, typename T13, typename T14, typename T15,
3709     typename T16, typename T17, typename T18, typename T19, typename T20,
3710     typename T21, typename T22, typename T23, typename T24, typename T25,
3711     typename T26, typename T27, typename T28, typename T29, typename T30,
3712     typename T31, typename T32, typename T33, typename T34, typename T35,
3713     typename T36, typename T37, typename T38, typename T39, typename T40,
3714     typename T41>
3715 struct Types41 {
3716   typedef T1 Head;
3717   typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3718       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3719       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
3720 };
3721 
3722 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3723     typename T6, typename T7, typename T8, typename T9, typename T10,
3724     typename T11, typename T12, typename T13, typename T14, typename T15,
3725     typename T16, typename T17, typename T18, typename T19, typename T20,
3726     typename T21, typename T22, typename T23, typename T24, typename T25,
3727     typename T26, typename T27, typename T28, typename T29, typename T30,
3728     typename T31, typename T32, typename T33, typename T34, typename T35,
3729     typename T36, typename T37, typename T38, typename T39, typename T40,
3730     typename T41, typename T42>
3731 struct Types42 {
3732   typedef T1 Head;
3733   typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3734       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3735       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
3736 };
3737 
3738 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3739     typename T6, typename T7, typename T8, typename T9, typename T10,
3740     typename T11, typename T12, typename T13, typename T14, typename T15,
3741     typename T16, typename T17, typename T18, typename T19, typename T20,
3742     typename T21, typename T22, typename T23, typename T24, typename T25,
3743     typename T26, typename T27, typename T28, typename T29, typename T30,
3744     typename T31, typename T32, typename T33, typename T34, typename T35,
3745     typename T36, typename T37, typename T38, typename T39, typename T40,
3746     typename T41, typename T42, typename T43>
3747 struct Types43 {
3748   typedef T1 Head;
3749   typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3750       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3751       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
3752       T43> Tail;
3753 };
3754 
3755 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3756     typename T6, typename T7, typename T8, typename T9, typename T10,
3757     typename T11, typename T12, typename T13, typename T14, typename T15,
3758     typename T16, typename T17, typename T18, typename T19, typename T20,
3759     typename T21, typename T22, typename T23, typename T24, typename T25,
3760     typename T26, typename T27, typename T28, typename T29, typename T30,
3761     typename T31, typename T32, typename T33, typename T34, typename T35,
3762     typename T36, typename T37, typename T38, typename T39, typename T40,
3763     typename T41, typename T42, typename T43, typename T44>
3764 struct Types44 {
3765   typedef T1 Head;
3766   typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3767       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3768       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3769       T44> Tail;
3770 };
3771 
3772 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3773     typename T6, typename T7, typename T8, typename T9, typename T10,
3774     typename T11, typename T12, typename T13, typename T14, typename T15,
3775     typename T16, typename T17, typename T18, typename T19, typename T20,
3776     typename T21, typename T22, typename T23, typename T24, typename T25,
3777     typename T26, typename T27, typename T28, typename T29, typename T30,
3778     typename T31, typename T32, typename T33, typename T34, typename T35,
3779     typename T36, typename T37, typename T38, typename T39, typename T40,
3780     typename T41, typename T42, typename T43, typename T44, typename T45>
3781 struct Types45 {
3782   typedef T1 Head;
3783   typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3784       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3785       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3786       T44, T45> Tail;
3787 };
3788 
3789 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3790     typename T6, typename T7, typename T8, typename T9, typename T10,
3791     typename T11, typename T12, typename T13, typename T14, typename T15,
3792     typename T16, typename T17, typename T18, typename T19, typename T20,
3793     typename T21, typename T22, typename T23, typename T24, typename T25,
3794     typename T26, typename T27, typename T28, typename T29, typename T30,
3795     typename T31, typename T32, typename T33, typename T34, typename T35,
3796     typename T36, typename T37, typename T38, typename T39, typename T40,
3797     typename T41, typename T42, typename T43, typename T44, typename T45,
3798     typename T46>
3799 struct Types46 {
3800   typedef T1 Head;
3801   typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3802       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3803       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3804       T44, T45, T46> Tail;
3805 };
3806 
3807 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3808     typename T6, typename T7, typename T8, typename T9, typename T10,
3809     typename T11, typename T12, typename T13, typename T14, typename T15,
3810     typename T16, typename T17, typename T18, typename T19, typename T20,
3811     typename T21, typename T22, typename T23, typename T24, typename T25,
3812     typename T26, typename T27, typename T28, typename T29, typename T30,
3813     typename T31, typename T32, typename T33, typename T34, typename T35,
3814     typename T36, typename T37, typename T38, typename T39, typename T40,
3815     typename T41, typename T42, typename T43, typename T44, typename T45,
3816     typename T46, typename T47>
3817 struct Types47 {
3818   typedef T1 Head;
3819   typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3820       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3821       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3822       T44, T45, T46, T47> Tail;
3823 };
3824 
3825 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3826     typename T6, typename T7, typename T8, typename T9, typename T10,
3827     typename T11, typename T12, typename T13, typename T14, typename T15,
3828     typename T16, typename T17, typename T18, typename T19, typename T20,
3829     typename T21, typename T22, typename T23, typename T24, typename T25,
3830     typename T26, typename T27, typename T28, typename T29, typename T30,
3831     typename T31, typename T32, typename T33, typename T34, typename T35,
3832     typename T36, typename T37, typename T38, typename T39, typename T40,
3833     typename T41, typename T42, typename T43, typename T44, typename T45,
3834     typename T46, typename T47, typename T48>
3835 struct Types48 {
3836   typedef T1 Head;
3837   typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3838       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3839       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3840       T44, T45, T46, T47, T48> Tail;
3841 };
3842 
3843 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3844     typename T6, typename T7, typename T8, typename T9, typename T10,
3845     typename T11, typename T12, typename T13, typename T14, typename T15,
3846     typename T16, typename T17, typename T18, typename T19, typename T20,
3847     typename T21, typename T22, typename T23, typename T24, typename T25,
3848     typename T26, typename T27, typename T28, typename T29, typename T30,
3849     typename T31, typename T32, typename T33, typename T34, typename T35,
3850     typename T36, typename T37, typename T38, typename T39, typename T40,
3851     typename T41, typename T42, typename T43, typename T44, typename T45,
3852     typename T46, typename T47, typename T48, typename T49>
3853 struct Types49 {
3854   typedef T1 Head;
3855   typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3856       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3857       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3858       T44, T45, T46, T47, T48, T49> Tail;
3859 };
3860 
3861 template <typename T1, typename T2, typename T3, typename T4, typename T5,
3862     typename T6, typename T7, typename T8, typename T9, typename T10,
3863     typename T11, typename T12, typename T13, typename T14, typename T15,
3864     typename T16, typename T17, typename T18, typename T19, typename T20,
3865     typename T21, typename T22, typename T23, typename T24, typename T25,
3866     typename T26, typename T27, typename T28, typename T29, typename T30,
3867     typename T31, typename T32, typename T33, typename T34, typename T35,
3868     typename T36, typename T37, typename T38, typename T39, typename T40,
3869     typename T41, typename T42, typename T43, typename T44, typename T45,
3870     typename T46, typename T47, typename T48, typename T49, typename T50>
3871 struct Types50 {
3872   typedef T1 Head;
3873   typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3874       T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3875       T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3876       T44, T45, T46, T47, T48, T49, T50> Tail;
3877 };
3878 
3879 
3880 }  // namespace internal
3881 
3882 // We don't want to require the users to write TypesN<...> directly,
3883 // as that would require them to count the length.  Types<...> is much
3884 // easier to write, but generates horrible messages when there is a
3885 // compiler error, as gcc insists on printing out each template
3886 // argument, even if it has the default value (this means Types<int>
3887 // will appear as Types<int, None, None, ..., None> in the compiler
3888 // errors).
3889 //
3890 // Our solution is to combine the best part of the two approaches: a
3891 // user would write Types<T1, ..., TN>, and Google Test will translate
3892 // that to TypesN<T1, ..., TN> internally to make error messages
3893 // readable.  The translation is done by the 'type' member of the
3894 // Types template.
3895 template <typename T1 = internal::None, typename T2 = internal::None,
3896     typename T3 = internal::None, typename T4 = internal::None,
3897     typename T5 = internal::None, typename T6 = internal::None,
3898     typename T7 = internal::None, typename T8 = internal::None,
3899     typename T9 = internal::None, typename T10 = internal::None,
3900     typename T11 = internal::None, typename T12 = internal::None,
3901     typename T13 = internal::None, typename T14 = internal::None,
3902     typename T15 = internal::None, typename T16 = internal::None,
3903     typename T17 = internal::None, typename T18 = internal::None,
3904     typename T19 = internal::None, typename T20 = internal::None,
3905     typename T21 = internal::None, typename T22 = internal::None,
3906     typename T23 = internal::None, typename T24 = internal::None,
3907     typename T25 = internal::None, typename T26 = internal::None,
3908     typename T27 = internal::None, typename T28 = internal::None,
3909     typename T29 = internal::None, typename T30 = internal::None,
3910     typename T31 = internal::None, typename T32 = internal::None,
3911     typename T33 = internal::None, typename T34 = internal::None,
3912     typename T35 = internal::None, typename T36 = internal::None,
3913     typename T37 = internal::None, typename T38 = internal::None,
3914     typename T39 = internal::None, typename T40 = internal::None,
3915     typename T41 = internal::None, typename T42 = internal::None,
3916     typename T43 = internal::None, typename T44 = internal::None,
3917     typename T45 = internal::None, typename T46 = internal::None,
3918     typename T47 = internal::None, typename T48 = internal::None,
3919     typename T49 = internal::None, typename T50 = internal::None>
3920 struct Types {
3921   typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
3922       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
3923       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
3924       T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
3925 };
3926 
3927 template <>
3928 struct Types<internal::None, internal::None, internal::None, internal::None,
3929     internal::None, internal::None, internal::None, internal::None,
3930     internal::None, internal::None, internal::None, internal::None,
3931     internal::None, internal::None, internal::None, internal::None,
3932     internal::None, internal::None, internal::None, internal::None,
3933     internal::None, internal::None, internal::None, internal::None,
3934     internal::None, internal::None, internal::None, internal::None,
3935     internal::None, internal::None, internal::None, internal::None,
3936     internal::None, internal::None, internal::None, internal::None,
3937     internal::None, internal::None, internal::None, internal::None,
3938     internal::None, internal::None, internal::None, internal::None,
3939     internal::None, internal::None, internal::None, internal::None,
3940     internal::None, internal::None> {
3941   typedef internal::Types0 type;
3942 };
3943 template <typename T1>
3944 struct Types<T1, internal::None, internal::None, internal::None,
3945     internal::None, internal::None, internal::None, internal::None,
3946     internal::None, internal::None, internal::None, internal::None,
3947     internal::None, internal::None, internal::None, internal::None,
3948     internal::None, internal::None, internal::None, internal::None,
3949     internal::None, internal::None, internal::None, internal::None,
3950     internal::None, internal::None, internal::None, internal::None,
3951     internal::None, internal::None, internal::None, internal::None,
3952     internal::None, internal::None, internal::None, internal::None,
3953     internal::None, internal::None, internal::None, internal::None,
3954     internal::None, internal::None, internal::None, internal::None,
3955     internal::None, internal::None, internal::None, internal::None,
3956     internal::None, internal::None> {
3957   typedef internal::Types1<T1> type;
3958 };
3959 template <typename T1, typename T2>
3960 struct Types<T1, T2, internal::None, internal::None, internal::None,
3961     internal::None, internal::None, internal::None, internal::None,
3962     internal::None, internal::None, internal::None, internal::None,
3963     internal::None, internal::None, internal::None, internal::None,
3964     internal::None, internal::None, internal::None, internal::None,
3965     internal::None, internal::None, internal::None, internal::None,
3966     internal::None, internal::None, internal::None, internal::None,
3967     internal::None, internal::None, internal::None, internal::None,
3968     internal::None, internal::None, internal::None, internal::None,
3969     internal::None, internal::None, internal::None, internal::None,
3970     internal::None, internal::None, internal::None, internal::None,
3971     internal::None, internal::None, internal::None, internal::None,
3972     internal::None> {
3973   typedef internal::Types2<T1, T2> type;
3974 };
3975 template <typename T1, typename T2, typename T3>
3976 struct Types<T1, T2, T3, internal::None, internal::None, internal::None,
3977     internal::None, internal::None, internal::None, internal::None,
3978     internal::None, internal::None, internal::None, internal::None,
3979     internal::None, internal::None, internal::None, internal::None,
3980     internal::None, internal::None, internal::None, internal::None,
3981     internal::None, internal::None, internal::None, internal::None,
3982     internal::None, internal::None, internal::None, internal::None,
3983     internal::None, internal::None, internal::None, internal::None,
3984     internal::None, internal::None, internal::None, internal::None,
3985     internal::None, internal::None, internal::None, internal::None,
3986     internal::None, internal::None, internal::None, internal::None,
3987     internal::None, internal::None, internal::None, internal::None> {
3988   typedef internal::Types3<T1, T2, T3> type;
3989 };
3990 template <typename T1, typename T2, typename T3, typename T4>
3991 struct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,
3992     internal::None, internal::None, internal::None, internal::None,
3993     internal::None, internal::None, internal::None, internal::None,
3994     internal::None, internal::None, internal::None, internal::None,
3995     internal::None, internal::None, internal::None, internal::None,
3996     internal::None, internal::None, internal::None, internal::None,
3997     internal::None, internal::None, internal::None, internal::None,
3998     internal::None, internal::None, internal::None, internal::None,
3999     internal::None, internal::None, internal::None, internal::None,
4000     internal::None, internal::None, internal::None, internal::None,
4001     internal::None, internal::None, internal::None, internal::None,
4002     internal::None, internal::None, internal::None> {
4003   typedef internal::Types4<T1, T2, T3, T4> type;
4004 };
4005 template <typename T1, typename T2, typename T3, typename T4, typename T5>
4006 struct Types<T1, T2, T3, T4, T5, internal::None, internal::None,
4007     internal::None, internal::None, internal::None, internal::None,
4008     internal::None, internal::None, internal::None, internal::None,
4009     internal::None, internal::None, internal::None, internal::None,
4010     internal::None, internal::None, internal::None, internal::None,
4011     internal::None, internal::None, internal::None, internal::None,
4012     internal::None, internal::None, internal::None, internal::None,
4013     internal::None, internal::None, internal::None, internal::None,
4014     internal::None, internal::None, internal::None, internal::None,
4015     internal::None, internal::None, internal::None, internal::None,
4016     internal::None, internal::None, internal::None, internal::None,
4017     internal::None, internal::None, internal::None> {
4018   typedef internal::Types5<T1, T2, T3, T4, T5> type;
4019 };
4020 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4021     typename T6>
4022 struct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,
4023     internal::None, internal::None, internal::None, internal::None,
4024     internal::None, internal::None, internal::None, internal::None,
4025     internal::None, internal::None, internal::None, internal::None,
4026     internal::None, internal::None, internal::None, internal::None,
4027     internal::None, internal::None, internal::None, internal::None,
4028     internal::None, internal::None, internal::None, internal::None,
4029     internal::None, internal::None, internal::None, internal::None,
4030     internal::None, internal::None, internal::None, internal::None,
4031     internal::None, internal::None, internal::None, internal::None,
4032     internal::None, internal::None, internal::None, internal::None,
4033     internal::None, internal::None> {
4034   typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
4035 };
4036 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4037     typename T6, typename T7>
4038 struct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,
4039     internal::None, internal::None, internal::None, internal::None,
4040     internal::None, internal::None, internal::None, internal::None,
4041     internal::None, internal::None, internal::None, internal::None,
4042     internal::None, internal::None, internal::None, internal::None,
4043     internal::None, internal::None, internal::None, internal::None,
4044     internal::None, internal::None, internal::None, internal::None,
4045     internal::None, internal::None, internal::None, internal::None,
4046     internal::None, internal::None, internal::None, internal::None,
4047     internal::None, internal::None, internal::None, internal::None,
4048     internal::None, internal::None, internal::None, internal::None,
4049     internal::None> {
4050   typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
4051 };
4052 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4053     typename T6, typename T7, typename T8>
4054 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,
4055     internal::None, internal::None, internal::None, internal::None,
4056     internal::None, internal::None, internal::None, internal::None,
4057     internal::None, internal::None, internal::None, internal::None,
4058     internal::None, internal::None, internal::None, internal::None,
4059     internal::None, internal::None, internal::None, internal::None,
4060     internal::None, internal::None, internal::None, internal::None,
4061     internal::None, internal::None, internal::None, internal::None,
4062     internal::None, internal::None, internal::None, internal::None,
4063     internal::None, internal::None, internal::None, internal::None,
4064     internal::None, internal::None, internal::None, internal::None> {
4065   typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
4066 };
4067 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4068     typename T6, typename T7, typename T8, typename T9>
4069 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,
4070     internal::None, internal::None, internal::None, internal::None,
4071     internal::None, internal::None, internal::None, internal::None,
4072     internal::None, internal::None, internal::None, internal::None,
4073     internal::None, internal::None, internal::None, internal::None,
4074     internal::None, internal::None, internal::None, internal::None,
4075     internal::None, internal::None, internal::None, internal::None,
4076     internal::None, internal::None, internal::None, internal::None,
4077     internal::None, internal::None, internal::None, internal::None,
4078     internal::None, internal::None, internal::None, internal::None,
4079     internal::None, internal::None, internal::None, internal::None> {
4080   typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
4081 };
4082 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4083     typename T6, typename T7, typename T8, typename T9, typename T10>
4084 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,
4085     internal::None, internal::None, internal::None, internal::None,
4086     internal::None, internal::None, internal::None, internal::None,
4087     internal::None, internal::None, internal::None, internal::None,
4088     internal::None, internal::None, internal::None, internal::None,
4089     internal::None, internal::None, internal::None, internal::None,
4090     internal::None, internal::None, internal::None, internal::None,
4091     internal::None, internal::None, internal::None, internal::None,
4092     internal::None, internal::None, internal::None, internal::None,
4093     internal::None, internal::None, internal::None, internal::None,
4094     internal::None, internal::None, internal::None> {
4095   typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
4096 };
4097 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4098     typename T6, typename T7, typename T8, typename T9, typename T10,
4099     typename T11>
4100 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,
4101     internal::None, internal::None, internal::None, internal::None,
4102     internal::None, internal::None, internal::None, internal::None,
4103     internal::None, internal::None, internal::None, internal::None,
4104     internal::None, internal::None, internal::None, internal::None,
4105     internal::None, internal::None, internal::None, internal::None,
4106     internal::None, internal::None, internal::None, internal::None,
4107     internal::None, internal::None, internal::None, internal::None,
4108     internal::None, internal::None, internal::None, internal::None,
4109     internal::None, internal::None, internal::None, internal::None,
4110     internal::None, internal::None> {
4111   typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
4112 };
4113 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4114     typename T6, typename T7, typename T8, typename T9, typename T10,
4115     typename T11, typename T12>
4116 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,
4117     internal::None, internal::None, internal::None, internal::None,
4118     internal::None, internal::None, internal::None, internal::None,
4119     internal::None, internal::None, internal::None, internal::None,
4120     internal::None, internal::None, internal::None, internal::None,
4121     internal::None, internal::None, internal::None, internal::None,
4122     internal::None, internal::None, internal::None, internal::None,
4123     internal::None, internal::None, internal::None, internal::None,
4124     internal::None, internal::None, internal::None, internal::None,
4125     internal::None, internal::None, internal::None, internal::None,
4126     internal::None> {
4127   typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
4128       T12> type;
4129 };
4130 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4131     typename T6, typename T7, typename T8, typename T9, typename T10,
4132     typename T11, typename T12, typename T13>
4133 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
4134     internal::None, internal::None, internal::None, internal::None,
4135     internal::None, internal::None, internal::None, internal::None,
4136     internal::None, internal::None, internal::None, internal::None,
4137     internal::None, internal::None, internal::None, internal::None,
4138     internal::None, internal::None, internal::None, internal::None,
4139     internal::None, internal::None, internal::None, internal::None,
4140     internal::None, internal::None, internal::None, internal::None,
4141     internal::None, internal::None, internal::None, internal::None,
4142     internal::None, internal::None, internal::None, internal::None,
4143     internal::None> {
4144   typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4145       T13> type;
4146 };
4147 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4148     typename T6, typename T7, typename T8, typename T9, typename T10,
4149     typename T11, typename T12, typename T13, typename T14>
4150 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4151     internal::None, internal::None, internal::None, internal::None,
4152     internal::None, internal::None, internal::None, internal::None,
4153     internal::None, internal::None, internal::None, internal::None,
4154     internal::None, internal::None, internal::None, internal::None,
4155     internal::None, internal::None, internal::None, internal::None,
4156     internal::None, internal::None, internal::None, internal::None,
4157     internal::None, internal::None, internal::None, internal::None,
4158     internal::None, internal::None, internal::None, internal::None,
4159     internal::None, internal::None, internal::None, internal::None> {
4160   typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4161       T13, T14> type;
4162 };
4163 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4164     typename T6, typename T7, typename T8, typename T9, typename T10,
4165     typename T11, typename T12, typename T13, typename T14, typename T15>
4166 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4167     internal::None, internal::None, internal::None, internal::None,
4168     internal::None, internal::None, internal::None, internal::None,
4169     internal::None, internal::None, internal::None, internal::None,
4170     internal::None, internal::None, internal::None, internal::None,
4171     internal::None, internal::None, internal::None, internal::None,
4172     internal::None, internal::None, internal::None, internal::None,
4173     internal::None, internal::None, internal::None, internal::None,
4174     internal::None, internal::None, internal::None, internal::None,
4175     internal::None, internal::None, internal::None> {
4176   typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4177       T13, T14, T15> type;
4178 };
4179 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4180     typename T6, typename T7, typename T8, typename T9, typename T10,
4181     typename T11, typename T12, typename T13, typename T14, typename T15,
4182     typename T16>
4183 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4184     T16, internal::None, internal::None, internal::None, internal::None,
4185     internal::None, internal::None, internal::None, internal::None,
4186     internal::None, internal::None, internal::None, internal::None,
4187     internal::None, internal::None, internal::None, internal::None,
4188     internal::None, internal::None, internal::None, internal::None,
4189     internal::None, internal::None, internal::None, internal::None,
4190     internal::None, internal::None, internal::None, internal::None,
4191     internal::None, internal::None, internal::None, internal::None,
4192     internal::None, internal::None> {
4193   typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4194       T13, T14, T15, T16> type;
4195 };
4196 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4197     typename T6, typename T7, typename T8, typename T9, typename T10,
4198     typename T11, typename T12, typename T13, typename T14, typename T15,
4199     typename T16, typename T17>
4200 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4201     T16, T17, internal::None, internal::None, internal::None, internal::None,
4202     internal::None, internal::None, internal::None, internal::None,
4203     internal::None, internal::None, internal::None, internal::None,
4204     internal::None, internal::None, internal::None, internal::None,
4205     internal::None, internal::None, internal::None, internal::None,
4206     internal::None, internal::None, internal::None, internal::None,
4207     internal::None, internal::None, internal::None, internal::None,
4208     internal::None, internal::None, internal::None, internal::None,
4209     internal::None> {
4210   typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4211       T13, T14, T15, T16, T17> type;
4212 };
4213 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4214     typename T6, typename T7, typename T8, typename T9, typename T10,
4215     typename T11, typename T12, typename T13, typename T14, typename T15,
4216     typename T16, typename T17, typename T18>
4217 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4218     T16, T17, T18, internal::None, internal::None, internal::None,
4219     internal::None, internal::None, internal::None, internal::None,
4220     internal::None, internal::None, internal::None, internal::None,
4221     internal::None, internal::None, internal::None, internal::None,
4222     internal::None, internal::None, internal::None, internal::None,
4223     internal::None, internal::None, internal::None, internal::None,
4224     internal::None, internal::None, internal::None, internal::None,
4225     internal::None, internal::None, internal::None, internal::None,
4226     internal::None> {
4227   typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4228       T13, T14, T15, T16, T17, T18> type;
4229 };
4230 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4231     typename T6, typename T7, typename T8, typename T9, typename T10,
4232     typename T11, typename T12, typename T13, typename T14, typename T15,
4233     typename T16, typename T17, typename T18, typename T19>
4234 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4235     T16, T17, T18, T19, internal::None, internal::None, internal::None,
4236     internal::None, internal::None, internal::None, internal::None,
4237     internal::None, internal::None, internal::None, internal::None,
4238     internal::None, internal::None, internal::None, internal::None,
4239     internal::None, internal::None, internal::None, internal::None,
4240     internal::None, internal::None, internal::None, internal::None,
4241     internal::None, internal::None, internal::None, internal::None,
4242     internal::None, internal::None, internal::None, internal::None> {
4243   typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4244       T13, T14, T15, T16, T17, T18, T19> type;
4245 };
4246 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4247     typename T6, typename T7, typename T8, typename T9, typename T10,
4248     typename T11, typename T12, typename T13, typename T14, typename T15,
4249     typename T16, typename T17, typename T18, typename T19, typename T20>
4250 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4251     T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,
4252     internal::None, internal::None, internal::None, internal::None,
4253     internal::None, internal::None, internal::None, internal::None,
4254     internal::None, internal::None, internal::None, internal::None,
4255     internal::None, internal::None, internal::None, internal::None,
4256     internal::None, internal::None, internal::None, internal::None,
4257     internal::None, internal::None, internal::None, internal::None,
4258     internal::None, internal::None, internal::None> {
4259   typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4260       T13, T14, T15, T16, T17, T18, T19, T20> type;
4261 };
4262 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4263     typename T6, typename T7, typename T8, typename T9, typename T10,
4264     typename T11, typename T12, typename T13, typename T14, typename T15,
4265     typename T16, typename T17, typename T18, typename T19, typename T20,
4266     typename T21>
4267 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4268     T16, T17, T18, T19, T20, T21, internal::None, internal::None,
4269     internal::None, internal::None, internal::None, internal::None,
4270     internal::None, internal::None, internal::None, internal::None,
4271     internal::None, internal::None, internal::None, internal::None,
4272     internal::None, internal::None, internal::None, internal::None,
4273     internal::None, internal::None, internal::None, internal::None,
4274     internal::None, internal::None, internal::None, internal::None,
4275     internal::None, internal::None, internal::None> {
4276   typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4277       T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
4278 };
4279 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4280     typename T6, typename T7, typename T8, typename T9, typename T10,
4281     typename T11, typename T12, typename T13, typename T14, typename T15,
4282     typename T16, typename T17, typename T18, typename T19, typename T20,
4283     typename T21, typename T22>
4284 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4285     T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,
4286     internal::None, internal::None, internal::None, internal::None,
4287     internal::None, internal::None, internal::None, internal::None,
4288     internal::None, internal::None, internal::None, internal::None,
4289     internal::None, internal::None, internal::None, internal::None,
4290     internal::None, internal::None, internal::None, internal::None,
4291     internal::None, internal::None, internal::None, internal::None,
4292     internal::None, internal::None> {
4293   typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4294       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
4295 };
4296 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4297     typename T6, typename T7, typename T8, typename T9, typename T10,
4298     typename T11, typename T12, typename T13, typename T14, typename T15,
4299     typename T16, typename T17, typename T18, typename T19, typename T20,
4300     typename T21, typename T22, typename T23>
4301 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4302     T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,
4303     internal::None, internal::None, internal::None, internal::None,
4304     internal::None, internal::None, internal::None, internal::None,
4305     internal::None, internal::None, internal::None, internal::None,
4306     internal::None, internal::None, internal::None, internal::None,
4307     internal::None, internal::None, internal::None, internal::None,
4308     internal::None, internal::None, internal::None, internal::None,
4309     internal::None> {
4310   typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4311       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
4312 };
4313 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4314     typename T6, typename T7, typename T8, typename T9, typename T10,
4315     typename T11, typename T12, typename T13, typename T14, typename T15,
4316     typename T16, typename T17, typename T18, typename T19, typename T20,
4317     typename T21, typename T22, typename T23, typename T24>
4318 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4319     T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,
4320     internal::None, internal::None, internal::None, internal::None,
4321     internal::None, internal::None, internal::None, internal::None,
4322     internal::None, internal::None, internal::None, internal::None,
4323     internal::None, internal::None, internal::None, internal::None,
4324     internal::None, internal::None, internal::None, internal::None,
4325     internal::None, internal::None, internal::None, internal::None,
4326     internal::None> {
4327   typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4328       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
4329 };
4330 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4331     typename T6, typename T7, typename T8, typename T9, typename T10,
4332     typename T11, typename T12, typename T13, typename T14, typename T15,
4333     typename T16, typename T17, typename T18, typename T19, typename T20,
4334     typename T21, typename T22, typename T23, typename T24, typename T25>
4335 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4336     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,
4337     internal::None, internal::None, internal::None, internal::None,
4338     internal::None, internal::None, internal::None, internal::None,
4339     internal::None, internal::None, internal::None, internal::None,
4340     internal::None, internal::None, internal::None, internal::None,
4341     internal::None, internal::None, internal::None, internal::None,
4342     internal::None, internal::None, internal::None, internal::None> {
4343   typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4344       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
4345 };
4346 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4347     typename T6, typename T7, typename T8, typename T9, typename T10,
4348     typename T11, typename T12, typename T13, typename T14, typename T15,
4349     typename T16, typename T17, typename T18, typename T19, typename T20,
4350     typename T21, typename T22, typename T23, typename T24, typename T25,
4351     typename T26>
4352 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4353     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,
4354     internal::None, internal::None, internal::None, internal::None,
4355     internal::None, internal::None, internal::None, internal::None,
4356     internal::None, internal::None, internal::None, internal::None,
4357     internal::None, internal::None, internal::None, internal::None,
4358     internal::None, internal::None, internal::None, internal::None,
4359     internal::None, internal::None, internal::None> {
4360   typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4361       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
4362       T26> type;
4363 };
4364 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4365     typename T6, typename T7, typename T8, typename T9, typename T10,
4366     typename T11, typename T12, typename T13, typename T14, typename T15,
4367     typename T16, typename T17, typename T18, typename T19, typename T20,
4368     typename T21, typename T22, typename T23, typename T24, typename T25,
4369     typename T26, typename T27>
4370 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4371     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,
4372     internal::None, internal::None, internal::None, internal::None,
4373     internal::None, internal::None, internal::None, internal::None,
4374     internal::None, internal::None, internal::None, internal::None,
4375     internal::None, internal::None, internal::None, internal::None,
4376     internal::None, internal::None, internal::None, internal::None,
4377     internal::None, internal::None> {
4378   typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4379       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4380       T27> type;
4381 };
4382 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4383     typename T6, typename T7, typename T8, typename T9, typename T10,
4384     typename T11, typename T12, typename T13, typename T14, typename T15,
4385     typename T16, typename T17, typename T18, typename T19, typename T20,
4386     typename T21, typename T22, typename T23, typename T24, typename T25,
4387     typename T26, typename T27, typename T28>
4388 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4389     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
4390     internal::None, internal::None, internal::None, internal::None,
4391     internal::None, internal::None, internal::None, internal::None,
4392     internal::None, internal::None, internal::None, internal::None,
4393     internal::None, internal::None, internal::None, internal::None,
4394     internal::None, internal::None, internal::None, internal::None,
4395     internal::None, internal::None> {
4396   typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4397       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4398       T27, T28> type;
4399 };
4400 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4401     typename T6, typename T7, typename T8, typename T9, typename T10,
4402     typename T11, typename T12, typename T13, typename T14, typename T15,
4403     typename T16, typename T17, typename T18, typename T19, typename T20,
4404     typename T21, typename T22, typename T23, typename T24, typename T25,
4405     typename T26, typename T27, typename T28, typename T29>
4406 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4407     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
4408     internal::None, internal::None, internal::None, internal::None,
4409     internal::None, internal::None, internal::None, internal::None,
4410     internal::None, internal::None, internal::None, internal::None,
4411     internal::None, internal::None, internal::None, internal::None,
4412     internal::None, internal::None, internal::None, internal::None,
4413     internal::None> {
4414   typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4415       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4416       T27, T28, T29> type;
4417 };
4418 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4419     typename T6, typename T7, typename T8, typename T9, typename T10,
4420     typename T11, typename T12, typename T13, typename T14, typename T15,
4421     typename T16, typename T17, typename T18, typename T19, typename T20,
4422     typename T21, typename T22, typename T23, typename T24, typename T25,
4423     typename T26, typename T27, typename T28, typename T29, typename T30>
4424 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4425     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4426     internal::None, internal::None, internal::None, internal::None,
4427     internal::None, internal::None, internal::None, internal::None,
4428     internal::None, internal::None, internal::None, internal::None,
4429     internal::None, internal::None, internal::None, internal::None,
4430     internal::None, internal::None, internal::None, internal::None> {
4431   typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4432       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4433       T27, T28, T29, T30> type;
4434 };
4435 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4436     typename T6, typename T7, typename T8, typename T9, typename T10,
4437     typename T11, typename T12, typename T13, typename T14, typename T15,
4438     typename T16, typename T17, typename T18, typename T19, typename T20,
4439     typename T21, typename T22, typename T23, typename T24, typename T25,
4440     typename T26, typename T27, typename T28, typename T29, typename T30,
4441     typename T31>
4442 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4443     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4444     T31, internal::None, internal::None, internal::None, internal::None,
4445     internal::None, internal::None, internal::None, internal::None,
4446     internal::None, internal::None, internal::None, internal::None,
4447     internal::None, internal::None, internal::None, internal::None,
4448     internal::None, internal::None, internal::None> {
4449   typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4450       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4451       T27, T28, T29, T30, T31> type;
4452 };
4453 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4454     typename T6, typename T7, typename T8, typename T9, typename T10,
4455     typename T11, typename T12, typename T13, typename T14, typename T15,
4456     typename T16, typename T17, typename T18, typename T19, typename T20,
4457     typename T21, typename T22, typename T23, typename T24, typename T25,
4458     typename T26, typename T27, typename T28, typename T29, typename T30,
4459     typename T31, typename T32>
4460 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4461     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4462     T31, T32, internal::None, internal::None, internal::None, internal::None,
4463     internal::None, internal::None, internal::None, internal::None,
4464     internal::None, internal::None, internal::None, internal::None,
4465     internal::None, internal::None, internal::None, internal::None,
4466     internal::None, internal::None> {
4467   typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4468       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4469       T27, T28, T29, T30, T31, T32> type;
4470 };
4471 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4472     typename T6, typename T7, typename T8, typename T9, typename T10,
4473     typename T11, typename T12, typename T13, typename T14, typename T15,
4474     typename T16, typename T17, typename T18, typename T19, typename T20,
4475     typename T21, typename T22, typename T23, typename T24, typename T25,
4476     typename T26, typename T27, typename T28, typename T29, typename T30,
4477     typename T31, typename T32, typename T33>
4478 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4479     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4480     T31, T32, T33, internal::None, internal::None, internal::None,
4481     internal::None, internal::None, internal::None, internal::None,
4482     internal::None, internal::None, internal::None, internal::None,
4483     internal::None, internal::None, internal::None, internal::None,
4484     internal::None, internal::None> {
4485   typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4486       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4487       T27, T28, T29, T30, T31, T32, T33> type;
4488 };
4489 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4490     typename T6, typename T7, typename T8, typename T9, typename T10,
4491     typename T11, typename T12, typename T13, typename T14, typename T15,
4492     typename T16, typename T17, typename T18, typename T19, typename T20,
4493     typename T21, typename T22, typename T23, typename T24, typename T25,
4494     typename T26, typename T27, typename T28, typename T29, typename T30,
4495     typename T31, typename T32, typename T33, typename T34>
4496 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4497     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4498     T31, T32, T33, T34, internal::None, internal::None, internal::None,
4499     internal::None, internal::None, internal::None, internal::None,
4500     internal::None, internal::None, internal::None, internal::None,
4501     internal::None, internal::None, internal::None, internal::None,
4502     internal::None> {
4503   typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4504       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4505       T27, T28, T29, T30, T31, T32, T33, T34> type;
4506 };
4507 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4508     typename T6, typename T7, typename T8, typename T9, typename T10,
4509     typename T11, typename T12, typename T13, typename T14, typename T15,
4510     typename T16, typename T17, typename T18, typename T19, typename T20,
4511     typename T21, typename T22, typename T23, typename T24, typename T25,
4512     typename T26, typename T27, typename T28, typename T29, typename T30,
4513     typename T31, typename T32, typename T33, typename T34, typename T35>
4514 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4515     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4516     T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,
4517     internal::None, internal::None, internal::None, internal::None,
4518     internal::None, internal::None, internal::None, internal::None,
4519     internal::None, internal::None, internal::None, internal::None> {
4520   typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4521       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4522       T27, T28, T29, T30, T31, T32, T33, T34, T35> type;
4523 };
4524 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4525     typename T6, typename T7, typename T8, typename T9, typename T10,
4526     typename T11, typename T12, typename T13, typename T14, typename T15,
4527     typename T16, typename T17, typename T18, typename T19, typename T20,
4528     typename T21, typename T22, typename T23, typename T24, typename T25,
4529     typename T26, typename T27, typename T28, typename T29, typename T30,
4530     typename T31, typename T32, typename T33, typename T34, typename T35,
4531     typename T36>
4532 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4533     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4534     T31, T32, T33, T34, T35, T36, internal::None, internal::None,
4535     internal::None, internal::None, internal::None, internal::None,
4536     internal::None, internal::None, internal::None, internal::None,
4537     internal::None, internal::None, internal::None, internal::None> {
4538   typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4539       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4540       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
4541 };
4542 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4543     typename T6, typename T7, typename T8, typename T9, typename T10,
4544     typename T11, typename T12, typename T13, typename T14, typename T15,
4545     typename T16, typename T17, typename T18, typename T19, typename T20,
4546     typename T21, typename T22, typename T23, typename T24, typename T25,
4547     typename T26, typename T27, typename T28, typename T29, typename T30,
4548     typename T31, typename T32, typename T33, typename T34, typename T35,
4549     typename T36, typename T37>
4550 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4551     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4552     T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,
4553     internal::None, internal::None, internal::None, internal::None,
4554     internal::None, internal::None, internal::None, internal::None,
4555     internal::None, internal::None, internal::None> {
4556   typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4557       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4558       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
4559 };
4560 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4561     typename T6, typename T7, typename T8, typename T9, typename T10,
4562     typename T11, typename T12, typename T13, typename T14, typename T15,
4563     typename T16, typename T17, typename T18, typename T19, typename T20,
4564     typename T21, typename T22, typename T23, typename T24, typename T25,
4565     typename T26, typename T27, typename T28, typename T29, typename T30,
4566     typename T31, typename T32, typename T33, typename T34, typename T35,
4567     typename T36, typename T37, typename T38>
4568 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4569     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4570     T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,
4571     internal::None, internal::None, internal::None, internal::None,
4572     internal::None, internal::None, internal::None, internal::None,
4573     internal::None, internal::None> {
4574   typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4575       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4576       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
4577 };
4578 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4579     typename T6, typename T7, typename T8, typename T9, typename T10,
4580     typename T11, typename T12, typename T13, typename T14, typename T15,
4581     typename T16, typename T17, typename T18, typename T19, typename T20,
4582     typename T21, typename T22, typename T23, typename T24, typename T25,
4583     typename T26, typename T27, typename T28, typename T29, typename T30,
4584     typename T31, typename T32, typename T33, typename T34, typename T35,
4585     typename T36, typename T37, typename T38, typename T39>
4586 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4587     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4588     T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,
4589     internal::None, internal::None, internal::None, internal::None,
4590     internal::None, internal::None, internal::None, internal::None,
4591     internal::None, internal::None> {
4592   typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4593       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4594       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
4595 };
4596 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4597     typename T6, typename T7, typename T8, typename T9, typename T10,
4598     typename T11, typename T12, typename T13, typename T14, typename T15,
4599     typename T16, typename T17, typename T18, typename T19, typename T20,
4600     typename T21, typename T22, typename T23, typename T24, typename T25,
4601     typename T26, typename T27, typename T28, typename T29, typename T30,
4602     typename T31, typename T32, typename T33, typename T34, typename T35,
4603     typename T36, typename T37, typename T38, typename T39, typename T40>
4604 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4605     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4606     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,
4607     internal::None, internal::None, internal::None, internal::None,
4608     internal::None, internal::None, internal::None, internal::None,
4609     internal::None> {
4610   typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4611       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4612       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
4613       T40> type;
4614 };
4615 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4616     typename T6, typename T7, typename T8, typename T9, typename T10,
4617     typename T11, typename T12, typename T13, typename T14, typename T15,
4618     typename T16, typename T17, typename T18, typename T19, typename T20,
4619     typename T21, typename T22, typename T23, typename T24, typename T25,
4620     typename T26, typename T27, typename T28, typename T29, typename T30,
4621     typename T31, typename T32, typename T33, typename T34, typename T35,
4622     typename T36, typename T37, typename T38, typename T39, typename T40,
4623     typename T41>
4624 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4625     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4626     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,
4627     internal::None, internal::None, internal::None, internal::None,
4628     internal::None, internal::None, internal::None, internal::None> {
4629   typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4630       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4631       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4632       T41> type;
4633 };
4634 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4635     typename T6, typename T7, typename T8, typename T9, typename T10,
4636     typename T11, typename T12, typename T13, typename T14, typename T15,
4637     typename T16, typename T17, typename T18, typename T19, typename T20,
4638     typename T21, typename T22, typename T23, typename T24, typename T25,
4639     typename T26, typename T27, typename T28, typename T29, typename T30,
4640     typename T31, typename T32, typename T33, typename T34, typename T35,
4641     typename T36, typename T37, typename T38, typename T39, typename T40,
4642     typename T41, typename T42>
4643 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4644     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4645     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,
4646     internal::None, internal::None, internal::None, internal::None,
4647     internal::None, internal::None, internal::None> {
4648   typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4649       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4650       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4651       T41, T42> type;
4652 };
4653 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4654     typename T6, typename T7, typename T8, typename T9, typename T10,
4655     typename T11, typename T12, typename T13, typename T14, typename T15,
4656     typename T16, typename T17, typename T18, typename T19, typename T20,
4657     typename T21, typename T22, typename T23, typename T24, typename T25,
4658     typename T26, typename T27, typename T28, typename T29, typename T30,
4659     typename T31, typename T32, typename T33, typename T34, typename T35,
4660     typename T36, typename T37, typename T38, typename T39, typename T40,
4661     typename T41, typename T42, typename T43>
4662 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4663     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4664     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
4665     internal::None, internal::None, internal::None, internal::None,
4666     internal::None, internal::None, internal::None> {
4667   typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4668       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4669       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4670       T41, T42, T43> type;
4671 };
4672 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4673     typename T6, typename T7, typename T8, typename T9, typename T10,
4674     typename T11, typename T12, typename T13, typename T14, typename T15,
4675     typename T16, typename T17, typename T18, typename T19, typename T20,
4676     typename T21, typename T22, typename T23, typename T24, typename T25,
4677     typename T26, typename T27, typename T28, typename T29, typename T30,
4678     typename T31, typename T32, typename T33, typename T34, typename T35,
4679     typename T36, typename T37, typename T38, typename T39, typename T40,
4680     typename T41, typename T42, typename T43, typename T44>
4681 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4682     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4683     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
4684     internal::None, internal::None, internal::None, internal::None,
4685     internal::None, internal::None> {
4686   typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4687       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4688       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4689       T41, T42, T43, T44> type;
4690 };
4691 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4692     typename T6, typename T7, typename T8, typename T9, typename T10,
4693     typename T11, typename T12, typename T13, typename T14, typename T15,
4694     typename T16, typename T17, typename T18, typename T19, typename T20,
4695     typename T21, typename T22, typename T23, typename T24, typename T25,
4696     typename T26, typename T27, typename T28, typename T29, typename T30,
4697     typename T31, typename T32, typename T33, typename T34, typename T35,
4698     typename T36, typename T37, typename T38, typename T39, typename T40,
4699     typename T41, typename T42, typename T43, typename T44, typename T45>
4700 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4701     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4702     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4703     internal::None, internal::None, internal::None, internal::None,
4704     internal::None> {
4705   typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4706       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4707       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4708       T41, T42, T43, T44, T45> type;
4709 };
4710 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4711     typename T6, typename T7, typename T8, typename T9, typename T10,
4712     typename T11, typename T12, typename T13, typename T14, typename T15,
4713     typename T16, typename T17, typename T18, typename T19, typename T20,
4714     typename T21, typename T22, typename T23, typename T24, typename T25,
4715     typename T26, typename T27, typename T28, typename T29, typename T30,
4716     typename T31, typename T32, typename T33, typename T34, typename T35,
4717     typename T36, typename T37, typename T38, typename T39, typename T40,
4718     typename T41, typename T42, typename T43, typename T44, typename T45,
4719     typename T46>
4720 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4721     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4722     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4723     T46, internal::None, internal::None, internal::None, internal::None> {
4724   typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4725       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4726       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4727       T41, T42, T43, T44, T45, T46> type;
4728 };
4729 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4730     typename T6, typename T7, typename T8, typename T9, typename T10,
4731     typename T11, typename T12, typename T13, typename T14, typename T15,
4732     typename T16, typename T17, typename T18, typename T19, typename T20,
4733     typename T21, typename T22, typename T23, typename T24, typename T25,
4734     typename T26, typename T27, typename T28, typename T29, typename T30,
4735     typename T31, typename T32, typename T33, typename T34, typename T35,
4736     typename T36, typename T37, typename T38, typename T39, typename T40,
4737     typename T41, typename T42, typename T43, typename T44, typename T45,
4738     typename T46, typename T47>
4739 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4740     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4741     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4742     T46, T47, internal::None, internal::None, internal::None> {
4743   typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4744       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4745       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4746       T41, T42, T43, T44, T45, T46, T47> type;
4747 };
4748 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4749     typename T6, typename T7, typename T8, typename T9, typename T10,
4750     typename T11, typename T12, typename T13, typename T14, typename T15,
4751     typename T16, typename T17, typename T18, typename T19, typename T20,
4752     typename T21, typename T22, typename T23, typename T24, typename T25,
4753     typename T26, typename T27, typename T28, typename T29, typename T30,
4754     typename T31, typename T32, typename T33, typename T34, typename T35,
4755     typename T36, typename T37, typename T38, typename T39, typename T40,
4756     typename T41, typename T42, typename T43, typename T44, typename T45,
4757     typename T46, typename T47, typename T48>
4758 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4759     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4760     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4761     T46, T47, T48, internal::None, internal::None> {
4762   typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4763       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4764       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4765       T41, T42, T43, T44, T45, T46, T47, T48> type;
4766 };
4767 template <typename T1, typename T2, typename T3, typename T4, typename T5,
4768     typename T6, typename T7, typename T8, typename T9, typename T10,
4769     typename T11, typename T12, typename T13, typename T14, typename T15,
4770     typename T16, typename T17, typename T18, typename T19, typename T20,
4771     typename T21, typename T22, typename T23, typename T24, typename T25,
4772     typename T26, typename T27, typename T28, typename T29, typename T30,
4773     typename T31, typename T32, typename T33, typename T34, typename T35,
4774     typename T36, typename T37, typename T38, typename T39, typename T40,
4775     typename T41, typename T42, typename T43, typename T44, typename T45,
4776     typename T46, typename T47, typename T48, typename T49>
4777 struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4778     T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4779     T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4780     T46, T47, T48, T49, internal::None> {
4781   typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4782       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4783       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4784       T41, T42, T43, T44, T45, T46, T47, T48, T49> type;
4785 };
4786 
4787 namespace internal {
4788 
4789 # define GTEST_TEMPLATE_ template <typename T> class
4790 
4791 // The template "selector" struct TemplateSel<Tmpl> is used to
4792 // represent Tmpl, which must be a class template with one type
4793 // parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined
4794 // as the type Tmpl<T>.  This allows us to actually instantiate the
4795 // template "selected" by TemplateSel<Tmpl>.
4796 //
4797 // This trick is necessary for simulating typedef for class templates,
4798 // which C++ doesn't support directly.
4799 template <GTEST_TEMPLATE_ Tmpl>
4800 struct TemplateSel {
4801   template <typename T>
4802   struct Bind {
4803     typedef Tmpl<T> type;
4804   };
4805 };
4806 
4807 # define GTEST_BIND_(TmplSel, T) \
4808   TmplSel::template Bind<T>::type
4809 
4810 // A unique struct template used as the default value for the
4811 // arguments of class template Templates.  This allows us to simulate
4812 // variadic templates (e.g. Templates<int>, Templates<int, double>,
4813 // and etc), which C++ doesn't support directly.
4814 template <typename T>
4815 struct NoneT {};
4816 
4817 // The following family of struct and struct templates are used to
4818 // represent template lists.  In particular, TemplatesN<T1, T2, ...,
4819 // TN> represents a list of N templates (T1, T2, ..., and TN).  Except
4820 // for Templates0, every struct in the family has two member types:
4821 // Head for the selector of the first template in the list, and Tail
4822 // for the rest of the list.
4823 
4824 // The empty template list.
4825 struct Templates0 {};
4826 
4827 // Template lists of length 1, 2, 3, and so on.
4828 
4829 template <GTEST_TEMPLATE_ T1>
4830 struct Templates1 {
4831   typedef TemplateSel<T1> Head;
4832   typedef Templates0 Tail;
4833 };
4834 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
4835 struct Templates2 {
4836   typedef TemplateSel<T1> Head;
4837   typedef Templates1<T2> Tail;
4838 };
4839 
4840 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
4841 struct Templates3 {
4842   typedef TemplateSel<T1> Head;
4843   typedef Templates2<T2, T3> Tail;
4844 };
4845 
4846 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4847     GTEST_TEMPLATE_ T4>
4848 struct Templates4 {
4849   typedef TemplateSel<T1> Head;
4850   typedef Templates3<T2, T3, T4> Tail;
4851 };
4852 
4853 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4854     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
4855 struct Templates5 {
4856   typedef TemplateSel<T1> Head;
4857   typedef Templates4<T2, T3, T4, T5> Tail;
4858 };
4859 
4860 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4861     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
4862 struct Templates6 {
4863   typedef TemplateSel<T1> Head;
4864   typedef Templates5<T2, T3, T4, T5, T6> Tail;
4865 };
4866 
4867 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4868     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4869     GTEST_TEMPLATE_ T7>
4870 struct Templates7 {
4871   typedef TemplateSel<T1> Head;
4872   typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;
4873 };
4874 
4875 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4876     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4877     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
4878 struct Templates8 {
4879   typedef TemplateSel<T1> Head;
4880   typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;
4881 };
4882 
4883 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4884     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4885     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
4886 struct Templates9 {
4887   typedef TemplateSel<T1> Head;
4888   typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
4889 };
4890 
4891 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4892     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4893     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4894     GTEST_TEMPLATE_ T10>
4895 struct Templates10 {
4896   typedef TemplateSel<T1> Head;
4897   typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
4898 };
4899 
4900 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4901     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4902     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4903     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
4904 struct Templates11 {
4905   typedef TemplateSel<T1> Head;
4906   typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
4907 };
4908 
4909 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4910     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4911     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4912     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
4913 struct Templates12 {
4914   typedef TemplateSel<T1> Head;
4915   typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
4916 };
4917 
4918 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4919     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4920     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4921     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4922     GTEST_TEMPLATE_ T13>
4923 struct Templates13 {
4924   typedef TemplateSel<T1> Head;
4925   typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
4926 };
4927 
4928 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4929     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4930     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4931     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4932     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
4933 struct Templates14 {
4934   typedef TemplateSel<T1> Head;
4935   typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
4936       T14> Tail;
4937 };
4938 
4939 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4940     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4941     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4942     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4943     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
4944 struct Templates15 {
4945   typedef TemplateSel<T1> Head;
4946   typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4947       T15> Tail;
4948 };
4949 
4950 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4951     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4952     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4953     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4954     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
4955     GTEST_TEMPLATE_ T16>
4956 struct Templates16 {
4957   typedef TemplateSel<T1> Head;
4958   typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4959       T15, T16> Tail;
4960 };
4961 
4962 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4963     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4964     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4965     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4966     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
4967     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
4968 struct Templates17 {
4969   typedef TemplateSel<T1> Head;
4970   typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4971       T15, T16, T17> Tail;
4972 };
4973 
4974 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4975     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4976     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4977     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4978     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
4979     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
4980 struct Templates18 {
4981   typedef TemplateSel<T1> Head;
4982   typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4983       T15, T16, T17, T18> Tail;
4984 };
4985 
4986 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4987     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4988     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4989     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4990     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
4991     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
4992     GTEST_TEMPLATE_ T19>
4993 struct Templates19 {
4994   typedef TemplateSel<T1> Head;
4995   typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4996       T15, T16, T17, T18, T19> Tail;
4997 };
4998 
4999 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5000     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5001     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5002     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5003     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5004     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5005     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
5006 struct Templates20 {
5007   typedef TemplateSel<T1> Head;
5008   typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5009       T15, T16, T17, T18, T19, T20> Tail;
5010 };
5011 
5012 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5013     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5014     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5015     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5016     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5017     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5018     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
5019 struct Templates21 {
5020   typedef TemplateSel<T1> Head;
5021   typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5022       T15, T16, T17, T18, T19, T20, T21> Tail;
5023 };
5024 
5025 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5026     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5027     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5028     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5029     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5030     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5031     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5032     GTEST_TEMPLATE_ T22>
5033 struct Templates22 {
5034   typedef TemplateSel<T1> Head;
5035   typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5036       T15, T16, T17, T18, T19, T20, T21, T22> Tail;
5037 };
5038 
5039 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5040     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5041     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5042     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5043     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5044     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5045     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5046     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
5047 struct Templates23 {
5048   typedef TemplateSel<T1> Head;
5049   typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5050       T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;
5051 };
5052 
5053 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5054     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5055     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5056     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5057     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5058     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5059     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5060     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
5061 struct Templates24 {
5062   typedef TemplateSel<T1> Head;
5063   typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5064       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
5065 };
5066 
5067 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5068     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5069     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5070     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5071     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5072     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5073     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5074     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5075     GTEST_TEMPLATE_ T25>
5076 struct Templates25 {
5077   typedef TemplateSel<T1> Head;
5078   typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5079       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
5080 };
5081 
5082 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5083     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5084     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5085     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5086     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5087     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5088     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5089     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5090     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
5091 struct Templates26 {
5092   typedef TemplateSel<T1> Head;
5093   typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5094       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
5095 };
5096 
5097 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5098     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5099     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5100     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5101     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5102     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5103     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5104     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5105     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
5106 struct Templates27 {
5107   typedef TemplateSel<T1> Head;
5108   typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5109       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
5110 };
5111 
5112 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5113     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5114     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5115     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5116     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5117     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5118     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5119     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5120     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5121     GTEST_TEMPLATE_ T28>
5122 struct Templates28 {
5123   typedef TemplateSel<T1> Head;
5124   typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5125       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
5126       T28> Tail;
5127 };
5128 
5129 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5130     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5131     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5132     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5133     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5134     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5135     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5136     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5137     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5138     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
5139 struct Templates29 {
5140   typedef TemplateSel<T1> Head;
5141   typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5142       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5143       T29> Tail;
5144 };
5145 
5146 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5147     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5148     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5149     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5150     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5151     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5152     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5153     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5154     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5155     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
5156 struct Templates30 {
5157   typedef TemplateSel<T1> Head;
5158   typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5159       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5160       T29, T30> Tail;
5161 };
5162 
5163 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5164     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5165     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5166     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5167     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5168     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5169     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5170     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5171     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5172     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5173     GTEST_TEMPLATE_ T31>
5174 struct Templates31 {
5175   typedef TemplateSel<T1> Head;
5176   typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5177       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5178       T29, T30, T31> Tail;
5179 };
5180 
5181 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5182     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5183     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5184     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5185     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5186     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5187     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5188     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5189     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5190     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5191     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
5192 struct Templates32 {
5193   typedef TemplateSel<T1> Head;
5194   typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5195       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5196       T29, T30, T31, T32> Tail;
5197 };
5198 
5199 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5200     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5201     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5202     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5203     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5204     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5205     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5206     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5207     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5208     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5209     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
5210 struct Templates33 {
5211   typedef TemplateSel<T1> Head;
5212   typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5213       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5214       T29, T30, T31, T32, T33> Tail;
5215 };
5216 
5217 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5218     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5219     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5220     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5221     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5222     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5223     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5224     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5225     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5226     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5227     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5228     GTEST_TEMPLATE_ T34>
5229 struct Templates34 {
5230   typedef TemplateSel<T1> Head;
5231   typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5232       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5233       T29, T30, T31, T32, T33, T34> Tail;
5234 };
5235 
5236 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5237     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5238     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5239     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5240     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5241     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5242     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5243     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5244     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5245     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5246     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5247     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
5248 struct Templates35 {
5249   typedef TemplateSel<T1> Head;
5250   typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5251       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5252       T29, T30, T31, T32, T33, T34, T35> Tail;
5253 };
5254 
5255 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5256     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5257     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5258     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5259     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5260     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5261     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5262     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5263     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5264     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5265     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5266     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
5267 struct Templates36 {
5268   typedef TemplateSel<T1> Head;
5269   typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5270       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5271       T29, T30, T31, T32, T33, T34, T35, T36> Tail;
5272 };
5273 
5274 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5275     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5276     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5277     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5278     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5279     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5280     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5281     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5282     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5283     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5284     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5285     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5286     GTEST_TEMPLATE_ T37>
5287 struct Templates37 {
5288   typedef TemplateSel<T1> Head;
5289   typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5290       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5291       T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;
5292 };
5293 
5294 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5295     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5296     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5297     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5298     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5299     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5300     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5301     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5302     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5303     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5304     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5305     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5306     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
5307 struct Templates38 {
5308   typedef TemplateSel<T1> Head;
5309   typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5310       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5311       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
5312 };
5313 
5314 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5315     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5316     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5317     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5318     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5319     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5320     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5321     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5322     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5323     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5324     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5325     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5326     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
5327 struct Templates39 {
5328   typedef TemplateSel<T1> Head;
5329   typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5330       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5331       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
5332 };
5333 
5334 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5335     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5336     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5337     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5338     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5339     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5340     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5341     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5342     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5343     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5344     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5345     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5346     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5347     GTEST_TEMPLATE_ T40>
5348 struct Templates40 {
5349   typedef TemplateSel<T1> Head;
5350   typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5351       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5352       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
5353 };
5354 
5355 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5356     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5357     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5358     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5359     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5360     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5361     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5362     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5363     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5364     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5365     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5366     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5367     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5368     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
5369 struct Templates41 {
5370   typedef TemplateSel<T1> Head;
5371   typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5372       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5373       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
5374 };
5375 
5376 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5377     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5378     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5379     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5380     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5381     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5382     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5383     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5384     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5385     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5386     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5387     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5388     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5389     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
5390 struct Templates42 {
5391   typedef TemplateSel<T1> Head;
5392   typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5393       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5394       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
5395       T42> Tail;
5396 };
5397 
5398 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5399     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5400     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5401     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5402     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5403     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5404     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5405     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5406     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5407     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5408     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5409     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5410     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5411     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5412     GTEST_TEMPLATE_ T43>
5413 struct Templates43 {
5414   typedef TemplateSel<T1> Head;
5415   typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5416       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5417       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5418       T43> Tail;
5419 };
5420 
5421 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5422     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5423     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5424     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5425     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5426     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5427     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5428     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5429     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5430     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5431     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5432     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5433     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5434     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5435     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
5436 struct Templates44 {
5437   typedef TemplateSel<T1> Head;
5438   typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5439       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5440       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5441       T43, T44> Tail;
5442 };
5443 
5444 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5445     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5446     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5447     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5448     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5449     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5450     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5451     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5452     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5453     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5454     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5455     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5456     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5457     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5458     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
5459 struct Templates45 {
5460   typedef TemplateSel<T1> Head;
5461   typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5462       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5463       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5464       T43, T44, T45> Tail;
5465 };
5466 
5467 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5468     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5469     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5470     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5471     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5472     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5473     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5474     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5475     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5476     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5477     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5478     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5479     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5480     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5481     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5482     GTEST_TEMPLATE_ T46>
5483 struct Templates46 {
5484   typedef TemplateSel<T1> Head;
5485   typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5486       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5487       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5488       T43, T44, T45, T46> Tail;
5489 };
5490 
5491 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5492     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5493     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5494     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5495     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5496     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5497     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5498     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5499     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5500     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5501     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5502     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5503     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5504     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5505     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5506     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
5507 struct Templates47 {
5508   typedef TemplateSel<T1> Head;
5509   typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5510       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5511       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5512       T43, T44, T45, T46, T47> Tail;
5513 };
5514 
5515 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5516     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5517     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5518     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5519     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5520     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5521     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5522     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5523     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5524     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5525     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5526     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5527     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5528     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5529     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5530     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
5531 struct Templates48 {
5532   typedef TemplateSel<T1> Head;
5533   typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5534       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5535       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5536       T43, T44, T45, T46, T47, T48> Tail;
5537 };
5538 
5539 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5540     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5541     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5542     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5543     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5544     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5545     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5546     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5547     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5548     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5549     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5550     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5551     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5552     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5553     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5554     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
5555     GTEST_TEMPLATE_ T49>
5556 struct Templates49 {
5557   typedef TemplateSel<T1> Head;
5558   typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5559       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5560       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5561       T43, T44, T45, T46, T47, T48, T49> Tail;
5562 };
5563 
5564 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5565     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5566     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5567     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5568     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5569     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5570     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5571     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5572     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5573     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5574     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5575     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5576     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5577     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5578     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5579     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
5580     GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>
5581 struct Templates50 {
5582   typedef TemplateSel<T1> Head;
5583   typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5584       T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5585       T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5586       T43, T44, T45, T46, T47, T48, T49, T50> Tail;
5587 };
5588 
5589 
5590 // We don't want to require the users to write TemplatesN<...> directly,
5591 // as that would require them to count the length.  Templates<...> is much
5592 // easier to write, but generates horrible messages when there is a
5593 // compiler error, as gcc insists on printing out each template
5594 // argument, even if it has the default value (this means Templates<list>
5595 // will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
5596 // errors).
5597 //
5598 // Our solution is to combine the best part of the two approaches: a
5599 // user would write Templates<T1, ..., TN>, and Google Test will translate
5600 // that to TemplatesN<T1, ..., TN> internally to make error messages
5601 // readable.  The translation is done by the 'type' member of the
5602 // Templates template.
5603 template <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,
5604     GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,
5605     GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,
5606     GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,
5607     GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,
5608     GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,
5609     GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,
5610     GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,
5611     GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,
5612     GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,
5613     GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,
5614     GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,
5615     GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,
5616     GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,
5617     GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,
5618     GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,
5619     GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,
5620     GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,
5621     GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,
5622     GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,
5623     GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,
5624     GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,
5625     GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,
5626     GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,
5627     GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>
5628 struct Templates {
5629   typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5630       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
5631       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
5632       T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
5633 };
5634 
5635 template <>
5636 struct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5637     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5638     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5639     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5640     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5641     NoneT> {
5642   typedef Templates0 type;
5643 };
5644 template <GTEST_TEMPLATE_ T1>
5645 struct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5646     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5647     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5648     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5649     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5650     NoneT> {
5651   typedef Templates1<T1> type;
5652 };
5653 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
5654 struct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5655     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5656     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5657     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5658     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5659     NoneT> {
5660   typedef Templates2<T1, T2> type;
5661 };
5662 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
5663 struct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5664     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5665     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5666     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5667     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5668   typedef Templates3<T1, T2, T3> type;
5669 };
5670 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5671     GTEST_TEMPLATE_ T4>
5672 struct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5673     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5674     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5675     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5676     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5677   typedef Templates4<T1, T2, T3, T4> type;
5678 };
5679 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5680     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
5681 struct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5682     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5683     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5684     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5685     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5686   typedef Templates5<T1, T2, T3, T4, T5> type;
5687 };
5688 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5689     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
5690 struct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,
5691     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5692     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5693     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5694     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5695   typedef Templates6<T1, T2, T3, T4, T5, T6> type;
5696 };
5697 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5698     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5699     GTEST_TEMPLATE_ T7>
5700 struct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,
5701     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5702     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5703     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5704     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5705   typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;
5706 };
5707 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5708     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5709     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
5710 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,
5711     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5712     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5713     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5714     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5715   typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;
5716 };
5717 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5718     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5719     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
5720 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,
5721     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5722     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5723     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5724     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5725   typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
5726 };
5727 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5728     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5729     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5730     GTEST_TEMPLATE_ T10>
5731 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,
5732     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5733     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5734     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5735     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5736   typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
5737 };
5738 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5739     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5740     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5741     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
5742 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,
5743     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5744     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5745     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5746     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5747   typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
5748 };
5749 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5750     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5751     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5752     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
5753 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,
5754     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5755     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5756     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5757     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5758   typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;
5759 };
5760 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5761     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5762     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5763     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5764     GTEST_TEMPLATE_ T13>
5765 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,
5766     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5767     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5768     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5769     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5770   typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
5771       T13> type;
5772 };
5773 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5774     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5775     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5776     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5777     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
5778 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5779     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5780     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5781     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5782     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5783   typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5784       T14> type;
5785 };
5786 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5787     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5788     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5789     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5790     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
5791 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5792     T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5793     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5794     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5795     NoneT, NoneT, NoneT, NoneT, NoneT> {
5796   typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5797       T14, T15> type;
5798 };
5799 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5800     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5801     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5802     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5803     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5804     GTEST_TEMPLATE_ T16>
5805 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5806     T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5807     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5808     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5809     NoneT, NoneT, NoneT, NoneT, NoneT> {
5810   typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5811       T14, T15, T16> type;
5812 };
5813 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5814     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5815     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5816     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5817     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5818     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
5819 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5820     T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5821     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5822     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5823     NoneT, NoneT, NoneT, NoneT, NoneT> {
5824   typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5825       T14, T15, T16, T17> type;
5826 };
5827 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5828     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5829     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5830     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5831     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5832     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
5833 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5834     T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5835     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5836     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5837     NoneT, NoneT, NoneT, NoneT> {
5838   typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5839       T14, T15, T16, T17, T18> type;
5840 };
5841 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5842     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5843     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5844     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5845     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5846     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5847     GTEST_TEMPLATE_ T19>
5848 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5849     T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5850     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5851     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5852     NoneT, NoneT, NoneT, NoneT> {
5853   typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5854       T14, T15, T16, T17, T18, T19> type;
5855 };
5856 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5857     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5858     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5859     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5860     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5861     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5862     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
5863 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5864     T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5865     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5866     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5867     NoneT, NoneT, NoneT, NoneT> {
5868   typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5869       T14, T15, T16, T17, T18, T19, T20> type;
5870 };
5871 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5872     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5873     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5874     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5875     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5876     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5877     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
5878 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5879     T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,
5880     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5881     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5882     NoneT, NoneT, NoneT, NoneT> {
5883   typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5884       T14, T15, T16, T17, T18, T19, T20, T21> type;
5885 };
5886 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5887     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5888     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5889     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5890     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5891     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5892     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5893     GTEST_TEMPLATE_ T22>
5894 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5895     T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,
5896     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5897     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5898     NoneT, NoneT, NoneT> {
5899   typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5900       T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
5901 };
5902 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5903     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5904     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5905     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5906     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5907     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5908     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5909     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
5910 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5911     T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,
5912     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5913     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5914     NoneT, NoneT, NoneT> {
5915   typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5916       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
5917 };
5918 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5919     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5920     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5921     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5922     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5923     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5924     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5925     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
5926 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5927     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,
5928     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5929     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5930     NoneT, NoneT, NoneT> {
5931   typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5932       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
5933 };
5934 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5935     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5936     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5937     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5938     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5939     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5940     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5941     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5942     GTEST_TEMPLATE_ T25>
5943 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5944     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,
5945     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5946     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5947     NoneT, NoneT> {
5948   typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5949       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
5950 };
5951 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5952     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5953     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5954     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5955     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5956     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5957     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5958     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5959     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
5960 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5961     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,
5962     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5963     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5964     NoneT, NoneT> {
5965   typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5966       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;
5967 };
5968 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5969     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5970     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5971     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5972     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5973     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5974     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5975     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5976     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
5977 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5978     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,
5979     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5980     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5981     NoneT, NoneT> {
5982   typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5983       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
5984       T27> type;
5985 };
5986 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5987     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5988     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5989     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5990     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5991     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5992     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5993     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5994     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5995     GTEST_TEMPLATE_ T28>
5996 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5997     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5998     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5999     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6000     NoneT, NoneT> {
6001   typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6002       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6003       T28> type;
6004 };
6005 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6006     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6007     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6008     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6009     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6010     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6011     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6012     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6013     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6014     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
6015 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6016     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6017     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6018     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6019     NoneT> {
6020   typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6021       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6022       T28, T29> type;
6023 };
6024 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6025     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6026     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6027     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6028     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6029     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6030     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6031     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6032     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6033     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
6034 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6035     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6036     T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6037     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6038   typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6039       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6040       T28, T29, T30> type;
6041 };
6042 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6043     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6044     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6045     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6046     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6047     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6048     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6049     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6050     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6051     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6052     GTEST_TEMPLATE_ T31>
6053 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6054     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6055     T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6056     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6057   typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6058       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6059       T28, T29, T30, T31> type;
6060 };
6061 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6062     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6063     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6064     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6065     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6066     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6067     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6068     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6069     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6070     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6071     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
6072 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6073     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6074     T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6075     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6076   typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6077       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6078       T28, T29, T30, T31, T32> type;
6079 };
6080 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6081     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6082     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6083     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6084     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6085     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6086     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6087     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6088     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6089     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6090     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
6091 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6092     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6093     T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6094     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6095   typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6096       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6097       T28, T29, T30, T31, T32, T33> type;
6098 };
6099 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6100     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6101     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6102     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6103     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6104     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6105     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6106     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6107     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6108     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6109     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6110     GTEST_TEMPLATE_ T34>
6111 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6112     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6113     T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6114     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6115   typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6116       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6117       T28, T29, T30, T31, T32, T33, T34> type;
6118 };
6119 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6120     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6121     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6122     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6123     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6124     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6125     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6126     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6127     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6128     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6129     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6130     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
6131 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6132     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6133     T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6134     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6135   typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6136       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6137       T28, T29, T30, T31, T32, T33, T34, T35> type;
6138 };
6139 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6140     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6141     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6142     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6143     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6144     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6145     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6146     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6147     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6148     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6149     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6150     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
6151 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6152     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6153     T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,
6154     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6155   typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6156       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6157       T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
6158 };
6159 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6160     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6161     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6162     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6163     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6164     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6165     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6166     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6167     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6168     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6169     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6170     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6171     GTEST_TEMPLATE_ T37>
6172 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6173     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6174     T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,
6175     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6176   typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6177       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6178       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
6179 };
6180 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6181     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6182     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6183     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6184     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6185     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6186     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6187     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6188     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6189     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6190     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6191     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6192     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
6193 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6194     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6195     T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,
6196     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6197   typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6198       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6199       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
6200 };
6201 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6202     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6203     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6204     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6205     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6206     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6207     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6208     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6209     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6210     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6211     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6212     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6213     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
6214 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6215     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6216     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,
6217     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6218   typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6219       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6220       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
6221 };
6222 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6223     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6224     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6225     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6226     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6227     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6228     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6229     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6230     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6231     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6232     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6233     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6234     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6235     GTEST_TEMPLATE_ T40>
6236 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6237     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6238     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,
6239     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6240   typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6241       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6242       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;
6243 };
6244 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6245     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6246     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6247     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6248     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6249     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6250     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6251     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6252     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6253     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6254     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6255     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6256     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6257     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
6258 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6259     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6260     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,
6261     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6262   typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6263       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6264       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
6265       T41> type;
6266 };
6267 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6268     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6269     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6270     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6271     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6272     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6273     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6274     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6275     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6276     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6277     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6278     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6279     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6280     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
6281 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6282     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6283     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,
6284     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6285   typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6286       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6287       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6288       T42> type;
6289 };
6290 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6291     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6292     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6293     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6294     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6295     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6296     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6297     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6298     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6299     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6300     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6301     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6302     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6303     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6304     GTEST_TEMPLATE_ T43>
6305 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6306     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6307     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
6308     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6309   typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6310       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6311       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6312       T42, T43> type;
6313 };
6314 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6315     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6316     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6317     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6318     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6319     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6320     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6321     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6322     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6323     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6324     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6325     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6326     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6327     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6328     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
6329 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6330     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6331     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6332     NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6333   typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6334       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6335       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6336       T42, T43, T44> type;
6337 };
6338 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6339     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6340     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6341     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6342     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6343     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6344     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6345     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6346     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6347     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6348     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6349     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6350     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6351     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6352     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
6353 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6354     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6355     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6356     T45, NoneT, NoneT, NoneT, NoneT, NoneT> {
6357   typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6358       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6359       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6360       T42, T43, T44, T45> type;
6361 };
6362 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6363     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6364     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6365     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6366     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6367     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6368     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6369     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6370     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6371     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6372     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6373     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6374     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6375     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6376     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6377     GTEST_TEMPLATE_ T46>
6378 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6379     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6380     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6381     T45, T46, NoneT, NoneT, NoneT, NoneT> {
6382   typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6383       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6384       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6385       T42, T43, T44, T45, T46> type;
6386 };
6387 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6388     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6389     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6390     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6391     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6392     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6393     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6394     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6395     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6396     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6397     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6398     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6399     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6400     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6401     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6402     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
6403 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6404     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6405     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6406     T45, T46, T47, NoneT, NoneT, NoneT> {
6407   typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6408       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6409       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6410       T42, T43, T44, T45, T46, T47> type;
6411 };
6412 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6413     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6414     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6415     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6416     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6417     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6418     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6419     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6420     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6421     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6422     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6423     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6424     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6425     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6426     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6427     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
6428 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6429     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6430     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6431     T45, T46, T47, T48, NoneT, NoneT> {
6432   typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6433       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6434       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6435       T42, T43, T44, T45, T46, T47, T48> type;
6436 };
6437 template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6438     GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6439     GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6440     GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6441     GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6442     GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6443     GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6444     GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6445     GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6446     GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6447     GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6448     GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6449     GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6450     GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6451     GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6452     GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
6453     GTEST_TEMPLATE_ T49>
6454 struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6455     T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6456     T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6457     T45, T46, T47, T48, T49, NoneT> {
6458   typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6459       T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6460       T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6461       T42, T43, T44, T45, T46, T47, T48, T49> type;
6462 };
6463 
6464 // The TypeList template makes it possible to use either a single type
6465 // or a Types<...> list in TYPED_TEST_SUITE() and
6466 // INSTANTIATE_TYPED_TEST_SUITE_P().
6467 
6468 template <typename T>
6469 struct TypeList {
6470   typedef Types1<T> type;
6471 };
6472 
6473 template <typename T1, typename T2, typename T3, typename T4, typename T5,
6474     typename T6, typename T7, typename T8, typename T9, typename T10,
6475     typename T11, typename T12, typename T13, typename T14, typename T15,
6476     typename T16, typename T17, typename T18, typename T19, typename T20,
6477     typename T21, typename T22, typename T23, typename T24, typename T25,
6478     typename T26, typename T27, typename T28, typename T29, typename T30,
6479     typename T31, typename T32, typename T33, typename T34, typename T35,
6480     typename T36, typename T37, typename T38, typename T39, typename T40,
6481     typename T41, typename T42, typename T43, typename T44, typename T45,
6482     typename T46, typename T47, typename T48, typename T49, typename T50>
6483 struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6484     T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
6485     T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
6486     T44, T45, T46, T47, T48, T49, T50> > {
6487   typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
6488       T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
6489       T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
6490       T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;
6491 };
6492 
6493 #endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
6494 
6495 }  // namespace internal
6496 }  // namespace testing
6497 
6498 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
6499 
6500 // Due to C++ preprocessor weirdness, we need double indirection to
6501 // concatenate two tokens when one of them is __LINE__.  Writing
6502 //
6503 //   foo ## __LINE__
6504 //
6505 // will result in the token foo__LINE__, instead of foo followed by
6506 // the current line number.  For more details, see
6507 // http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
6508 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
6509 #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
6510 
6511 // Stringifies its argument.
6512 #define GTEST_STRINGIFY_(name) #name
6513 
6514 namespace proto2 { class Message; }
6515 
6516 namespace testing {
6517 
6518 // Forward declarations.
6519 
6520 class AssertionResult;                 // Result of an assertion.
6521 class Message;                         // Represents a failure message.
6522 class Test;                            // Represents a test.
6523 class TestInfo;                        // Information about a test.
6524 class TestPartResult;                  // Result of a test part.
6525 class UnitTest;                        // A collection of test suites.
6526 
6527 template <typename T>
6528 ::std::string PrintToString(const T& value);
6529 
6530 namespace internal {
6531 
6532 struct TraceInfo;                      // Information about a trace point.
6533 class TestInfoImpl;                    // Opaque implementation of TestInfo
6534 class UnitTestImpl;                    // Opaque implementation of UnitTest
6535 
6536 // The text used in failure messages to indicate the start of the
6537 // stack trace.
6538 GTEST_API_ extern const char kStackTraceMarker[];
6539 
6540 // An IgnoredValue object can be implicitly constructed from ANY value.
6541 class IgnoredValue {
6542   struct Sink {};
6543  public:
6544   // This constructor template allows any value to be implicitly
6545   // converted to IgnoredValue.  The object has no data member and
6546   // doesn't try to remember anything about the argument.  We
6547   // deliberately omit the 'explicit' keyword in order to allow the
6548   // conversion to be implicit.
6549   // Disable the conversion if T already has a magical conversion operator.
6550   // Otherwise we get ambiguity.
6551   template <typename T,
6552             typename std::enable_if<!std::is_convertible<T, Sink>::value,
6553                                     int>::type = 0>
6554   IgnoredValue(const T& /* ignored */) {}  // NOLINT(runtime/explicit)
6555 };
6556 
6557 // Appends the user-supplied message to the Google-Test-generated message.
6558 GTEST_API_ std::string AppendUserMessage(
6559     const std::string& gtest_msg, const Message& user_msg);
6560 
6561 #if GTEST_HAS_EXCEPTIONS
6562 
6563 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \
6564 /* an exported class was derived from a class that was not exported */)
6565 
6566 // This exception is thrown by (and only by) a failed Google Test
6567 // assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
6568 // are enabled).  We derive it from std::runtime_error, which is for
6569 // errors presumably detectable only at run time.  Since
6570 // std::runtime_error inherits from std::exception, many testing
6571 // frameworks know how to extract and print the message inside it.
6572 class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
6573  public:
6574   explicit GoogleTestFailureException(const TestPartResult& failure);
6575 };
6576 
6577 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4275
6578 
6579 #endif  // GTEST_HAS_EXCEPTIONS
6580 
6581 namespace edit_distance {
6582 // Returns the optimal edits to go from 'left' to 'right'.
6583 // All edits cost the same, with replace having lower priority than
6584 // add/remove.
6585 // Simple implementation of the Wagner-Fischer algorithm.
6586 // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
6587 enum EditType { kMatch, kAdd, kRemove, kReplace };
6588 GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
6589     const std::vector<size_t>& left, const std::vector<size_t>& right);
6590 
6591 // Same as above, but the input is represented as strings.
6592 GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
6593     const std::vector<std::string>& left,
6594     const std::vector<std::string>& right);
6595 
6596 // Create a diff of the input strings in Unified diff format.
6597 GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
6598                                          const std::vector<std::string>& right,
6599                                          size_t context = 2);
6600 
6601 }  // namespace edit_distance
6602 
6603 // Calculate the diff between 'left' and 'right' and return it in unified diff
6604 // format.
6605 // If not null, stores in 'total_line_count' the total number of lines found
6606 // in left + right.
6607 GTEST_API_ std::string DiffStrings(const std::string& left,
6608                                    const std::string& right,
6609                                    size_t* total_line_count);
6610 
6611 // Constructs and returns the message for an equality assertion
6612 // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
6613 //
6614 // The first four parameters are the expressions used in the assertion
6615 // and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
6616 // where foo is 5 and bar is 6, we have:
6617 //
6618 //   expected_expression: "foo"
6619 //   actual_expression:   "bar"
6620 //   expected_value:      "5"
6621 //   actual_value:        "6"
6622 //
6623 // The ignoring_case parameter is true iff the assertion is a
6624 // *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
6625 // be inserted into the message.
6626 GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
6627                                      const char* actual_expression,
6628                                      const std::string& expected_value,
6629                                      const std::string& actual_value,
6630                                      bool ignoring_case);
6631 
6632 // Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
6633 GTEST_API_ std::string GetBoolAssertionFailureMessage(
6634     const AssertionResult& assertion_result,
6635     const char* expression_text,
6636     const char* actual_predicate_value,
6637     const char* expected_predicate_value);
6638 
6639 // This template class represents an IEEE floating-point number
6640 // (either single-precision or double-precision, depending on the
6641 // template parameters).
6642 //
6643 // The purpose of this class is to do more sophisticated number
6644 // comparison.  (Due to round-off error, etc, it's very unlikely that
6645 // two floating-points will be equal exactly.  Hence a naive
6646 // comparison by the == operation often doesn't work.)
6647 //
6648 // Format of IEEE floating-point:
6649 //
6650 //   The most-significant bit being the leftmost, an IEEE
6651 //   floating-point looks like
6652 //
6653 //     sign_bit exponent_bits fraction_bits
6654 //
6655 //   Here, sign_bit is a single bit that designates the sign of the
6656 //   number.
6657 //
6658 //   For float, there are 8 exponent bits and 23 fraction bits.
6659 //
6660 //   For double, there are 11 exponent bits and 52 fraction bits.
6661 //
6662 //   More details can be found at
6663 //   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
6664 //
6665 // Template parameter:
6666 //
6667 //   RawType: the raw floating-point type (either float or double)
6668 template <typename RawType>
6669 class FloatingPoint {
6670  public:
6671   // Defines the unsigned integer type that has the same size as the
6672   // floating point number.
6673   typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
6674 
6675   // Constants.
6676 
6677   // # of bits in a number.
6678   static const size_t kBitCount = 8*sizeof(RawType);
6679 
6680   // # of fraction bits in a number.
6681   static const size_t kFractionBitCount =
6682     std::numeric_limits<RawType>::digits - 1;
6683 
6684   // # of exponent bits in a number.
6685   static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
6686 
6687   // The mask for the sign bit.
6688   static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
6689 
6690   // The mask for the fraction bits.
6691   static const Bits kFractionBitMask =
6692     ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
6693 
6694   // The mask for the exponent bits.
6695   static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
6696 
6697   // How many ULP's (Units in the Last Place) we want to tolerate when
6698   // comparing two numbers.  The larger the value, the more error we
6699   // allow.  A 0 value means that two numbers must be exactly the same
6700   // to be considered equal.
6701   //
6702   // The maximum error of a single floating-point operation is 0.5
6703   // units in the last place.  On Intel CPU's, all floating-point
6704   // calculations are done with 80-bit precision, while double has 64
6705   // bits.  Therefore, 4 should be enough for ordinary use.
6706   //
6707   // See the following article for more details on ULP:
6708   // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
6709   static const size_t kMaxUlps = 4;
6710 
6711   // Constructs a FloatingPoint from a raw floating-point number.
6712   //
6713   // On an Intel CPU, passing a non-normalized NAN (Not a Number)
6714   // around may change its bits, although the new value is guaranteed
6715   // to be also a NAN.  Therefore, don't expect this constructor to
6716   // preserve the bits in x when x is a NAN.
6717   explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
6718 
6719   // Static methods
6720 
6721   // Reinterprets a bit pattern as a floating-point number.
6722   //
6723   // This function is needed to test the AlmostEquals() method.
6724   static RawType ReinterpretBits(const Bits bits) {
6725     FloatingPoint fp(0);
6726     fp.u_.bits_ = bits;
6727     return fp.u_.value_;
6728   }
6729 
6730   // Returns the floating-point number that represent positive infinity.
6731   static RawType Infinity() {
6732     return ReinterpretBits(kExponentBitMask);
6733   }
6734 
6735   // Returns the maximum representable finite floating-point number.
6736   static RawType Max();
6737 
6738   // Non-static methods
6739 
6740   // Returns the bits that represents this number.
6741   const Bits &bits() const { return u_.bits_; }
6742 
6743   // Returns the exponent bits of this number.
6744   Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
6745 
6746   // Returns the fraction bits of this number.
6747   Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
6748 
6749   // Returns the sign bit of this number.
6750   Bits sign_bit() const { return kSignBitMask & u_.bits_; }
6751 
6752   // Returns true iff this is NAN (not a number).
6753   bool is_nan() const {
6754     // It's a NAN if the exponent bits are all ones and the fraction
6755     // bits are not entirely zeros.
6756     return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
6757   }
6758 
6759   // Returns true iff this number is at most kMaxUlps ULP's away from
6760   // rhs.  In particular, this function:
6761   //
6762   //   - returns false if either number is (or both are) NAN.
6763   //   - treats really large numbers as almost equal to infinity.
6764   //   - thinks +0.0 and -0.0 are 0 DLP's apart.
6765   bool AlmostEquals(const FloatingPoint& rhs) const {
6766     // The IEEE standard says that any comparison operation involving
6767     // a NAN must return false.
6768     if (is_nan() || rhs.is_nan()) return false;
6769 
6770     return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
6771         <= kMaxUlps;
6772   }
6773 
6774  private:
6775   // The data type used to store the actual floating-point number.
6776   union FloatingPointUnion {
6777     RawType value_;  // The raw floating-point number.
6778     Bits bits_;      // The bits that represent the number.
6779   };
6780 
6781   // Converts an integer from the sign-and-magnitude representation to
6782   // the biased representation.  More precisely, let N be 2 to the
6783   // power of (kBitCount - 1), an integer x is represented by the
6784   // unsigned number x + N.
6785   //
6786   // For instance,
6787   //
6788   //   -N + 1 (the most negative number representable using
6789   //          sign-and-magnitude) is represented by 1;
6790   //   0      is represented by N; and
6791   //   N - 1  (the biggest number representable using
6792   //          sign-and-magnitude) is represented by 2N - 1.
6793   //
6794   // Read http://en.wikipedia.org/wiki/Signed_number_representations
6795   // for more details on signed number representations.
6796   static Bits SignAndMagnitudeToBiased(const Bits &sam) {
6797     if (kSignBitMask & sam) {
6798       // sam represents a negative number.
6799       return ~sam + 1;
6800     } else {
6801       // sam represents a positive number.
6802       return kSignBitMask | sam;
6803     }
6804   }
6805 
6806   // Given two numbers in the sign-and-magnitude representation,
6807   // returns the distance between them as an unsigned number.
6808   static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
6809                                                      const Bits &sam2) {
6810     const Bits biased1 = SignAndMagnitudeToBiased(sam1);
6811     const Bits biased2 = SignAndMagnitudeToBiased(sam2);
6812     return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
6813   }
6814 
6815   FloatingPointUnion u_;
6816 };
6817 
6818 // We cannot use std::numeric_limits<T>::max() as it clashes with the max()
6819 // macro defined by <windows.h>.
6820 template <>
6821 inline float FloatingPoint<float>::Max() { return FLT_MAX; }
6822 template <>
6823 inline double FloatingPoint<double>::Max() { return DBL_MAX; }
6824 
6825 // Typedefs the instances of the FloatingPoint template class that we
6826 // care to use.
6827 typedef FloatingPoint<float> Float;
6828 typedef FloatingPoint<double> Double;
6829 
6830 // In order to catch the mistake of putting tests that use different
6831 // test fixture classes in the same test suite, we need to assign
6832 // unique IDs to fixture classes and compare them.  The TypeId type is
6833 // used to hold such IDs.  The user should treat TypeId as an opaque
6834 // type: the only operation allowed on TypeId values is to compare
6835 // them for equality using the == operator.
6836 typedef const void* TypeId;
6837 
6838 template <typename T>
6839 class TypeIdHelper {
6840  public:
6841   // dummy_ must not have a const type.  Otherwise an overly eager
6842   // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
6843   // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
6844   static bool dummy_;
6845 };
6846 
6847 template <typename T>
6848 bool TypeIdHelper<T>::dummy_ = false;
6849 
6850 // GetTypeId<T>() returns the ID of type T.  Different values will be
6851 // returned for different types.  Calling the function twice with the
6852 // same type argument is guaranteed to return the same ID.
6853 template <typename T>
6854 TypeId GetTypeId() {
6855   // The compiler is required to allocate a different
6856   // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
6857   // the template.  Therefore, the address of dummy_ is guaranteed to
6858   // be unique.
6859   return &(TypeIdHelper<T>::dummy_);
6860 }
6861 
6862 // Returns the type ID of ::testing::Test.  Always call this instead
6863 // of GetTypeId< ::testing::Test>() to get the type ID of
6864 // ::testing::Test, as the latter may give the wrong result due to a
6865 // suspected linker bug when compiling Google Test as a Mac OS X
6866 // framework.
6867 GTEST_API_ TypeId GetTestTypeId();
6868 
6869 // Defines the abstract factory interface that creates instances
6870 // of a Test object.
6871 class TestFactoryBase {
6872  public:
6873   virtual ~TestFactoryBase() {}
6874 
6875   // Creates a test instance to run. The instance is both created and destroyed
6876   // within TestInfoImpl::Run()
6877   virtual Test* CreateTest() = 0;
6878 
6879  protected:
6880   TestFactoryBase() {}
6881 
6882  private:
6883   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
6884 };
6885 
6886 // This class provides implementation of TeastFactoryBase interface.
6887 // It is used in TEST and TEST_F macros.
6888 template <class TestClass>
6889 class TestFactoryImpl : public TestFactoryBase {
6890  public:
6891   Test* CreateTest() override { return new TestClass; }
6892 };
6893 
6894 #if GTEST_OS_WINDOWS
6895 
6896 // Predicate-formatters for implementing the HRESULT checking macros
6897 // {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
6898 // We pass a long instead of HRESULT to avoid causing an
6899 // include dependency for the HRESULT type.
6900 GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
6901                                             long hr);  // NOLINT
6902 GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
6903                                             long hr);  // NOLINT
6904 
6905 #endif  // GTEST_OS_WINDOWS
6906 
6907 // Types of SetUpTestSuite() and TearDownTestSuite() functions.
6908 using SetUpTestSuiteFunc = void (*)();
6909 using TearDownTestSuiteFunc = void (*)();
6910 
6911 struct CodeLocation {
6912   CodeLocation(const std::string& a_file, int a_line)
6913       : file(a_file), line(a_line) {}
6914 
6915   std::string file;
6916   int line;
6917 };
6918 
6919 //  Helper to identify which setup function for TestCase / TestSuite to call.
6920 //  Only one function is allowed, either TestCase or TestSute but not both.
6921 
6922 // Utility functions to help SuiteApiResolver
6923 using SetUpTearDownSuiteFuncType = void (*)();
6924 
6925 inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(
6926     SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) {
6927   return a == def ? nullptr : a;
6928 }
6929 
6930 template <typename T>
6931 //  Note that SuiteApiResolver inherits from T because
6932 //  SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way
6933 //  SuiteApiResolver can access them.
6934 struct SuiteApiResolver : T {
6935   // testing::Test is only forward declared at this point. So we make it a
6936   // dependend class for the compiler to be OK with it.
6937   using Test =
6938       typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;
6939 
6940   static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite() {
6941     SetUpTearDownSuiteFuncType test_case_fp =
6942         GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase);
6943     SetUpTearDownSuiteFuncType test_suite_fp =
6944         GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite);
6945 
6946     GTEST_CHECK_(!test_case_fp || !test_suite_fp)
6947         << "Test can not provide both SetUpTestSuite and SetUpTestCase, please "
6948            "make sure there is only one present ";
6949 
6950     return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
6951   }
6952 
6953   static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite() {
6954     SetUpTearDownSuiteFuncType test_case_fp =
6955         GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase);
6956     SetUpTearDownSuiteFuncType test_suite_fp =
6957         GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite);
6958 
6959     GTEST_CHECK_(!test_case_fp || !test_suite_fp)
6960         << "Test can not provide both TearDownTestSuite and TearDownTestCase,"
6961            " please make sure there is only one present ";
6962 
6963     return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
6964   }
6965 };
6966 
6967 // Creates a new TestInfo object and registers it with Google Test;
6968 // returns the created object.
6969 //
6970 // Arguments:
6971 //
6972 //   test_suite_name:   name of the test suite
6973 //   name:             name of the test
6974 //   type_param        the name of the test's type parameter, or NULL if
6975 //                     this is not a typed or a type-parameterized test.
6976 //   value_param       text representation of the test's value parameter,
6977 //                     or NULL if this is not a type-parameterized test.
6978 //   code_location:    code location where the test is defined
6979 //   fixture_class_id: ID of the test fixture class
6980 //   set_up_tc:        pointer to the function that sets up the test suite
6981 //   tear_down_tc:     pointer to the function that tears down the test suite
6982 //   factory:          pointer to the factory that creates a test object.
6983 //                     The newly created TestInfo instance will assume
6984 //                     ownership of the factory object.
6985 GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
6986     const char* test_suite_name, const char* name, const char* type_param,
6987     const char* value_param, CodeLocation code_location,
6988     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
6989     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
6990 
6991 // If *pstr starts with the given prefix, modifies *pstr to be right
6992 // past the prefix and returns true; otherwise leaves *pstr unchanged
6993 // and returns false.  None of pstr, *pstr, and prefix can be NULL.
6994 GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
6995 
6996 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
6997 
6998 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
6999 /* class A needs to have dll-interface to be used by clients of class B */)
7000 
7001 // State of the definition of a type-parameterized test suite.
7002 class GTEST_API_ TypedTestSuitePState {
7003  public:
7004   TypedTestSuitePState() : registered_(false) {}
7005 
7006   // Adds the given test name to defined_test_names_ and return true
7007   // if the test suite hasn't been registered; otherwise aborts the
7008   // program.
7009   bool AddTestName(const char* file, int line, const char* case_name,
7010                    const char* test_name) {
7011     if (registered_) {
7012       fprintf(stderr,
7013               "%s Test %s must be defined before "
7014               "REGISTER_TYPED_TEST_SUITE_P(%s, ...).\n",
7015               FormatFileLocation(file, line).c_str(), test_name, case_name);
7016       fflush(stderr);
7017       posix::Abort();
7018     }
7019     registered_tests_.insert(
7020         ::std::make_pair(test_name, CodeLocation(file, line)));
7021     return true;
7022   }
7023 
7024   bool TestExists(const std::string& test_name) const {
7025     return registered_tests_.count(test_name) > 0;
7026   }
7027 
7028   const CodeLocation& GetCodeLocation(const std::string& test_name) const {
7029     RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
7030     GTEST_CHECK_(it != registered_tests_.end());
7031     return it->second;
7032   }
7033 
7034   // Verifies that registered_tests match the test names in
7035   // defined_test_names_; returns registered_tests if successful, or
7036   // aborts the program otherwise.
7037   const char* VerifyRegisteredTestNames(
7038       const char* file, int line, const char* registered_tests);
7039 
7040  private:
7041   typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
7042 
7043   bool registered_;
7044   RegisteredTestsMap registered_tests_;
7045 };
7046 
7047 //  Legacy API is deprecated but still available
7048 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
7049 using TypedTestCasePState = TypedTestSuitePState;
7050 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
7051 
7052 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
7053 
7054 // Skips to the first non-space char after the first comma in 'str';
7055 // returns NULL if no comma is found in 'str'.
7056 inline const char* SkipComma(const char* str) {
7057   const char* comma = strchr(str, ',');
7058   if (comma == nullptr) {
7059     return nullptr;
7060   }
7061   while (IsSpace(*(++comma))) {}
7062   return comma;
7063 }
7064 
7065 // Returns the prefix of 'str' before the first comma in it; returns
7066 // the entire string if it contains no comma.
7067 inline std::string GetPrefixUntilComma(const char* str) {
7068   const char* comma = strchr(str, ',');
7069   return comma == nullptr ? str : std::string(str, comma);
7070 }
7071 
7072 // Splits a given string on a given delimiter, populating a given
7073 // vector with the fields.
7074 void SplitString(const ::std::string& str, char delimiter,
7075                  ::std::vector< ::std::string>* dest);
7076 
7077 // The default argument to the template below for the case when the user does
7078 // not provide a name generator.
7079 struct DefaultNameGenerator {
7080   template <typename T>
7081   static std::string GetName(int i) {
7082     return StreamableToString(i);
7083   }
7084 };
7085 
7086 template <typename Provided = DefaultNameGenerator>
7087 struct NameGeneratorSelector {
7088   typedef Provided type;
7089 };
7090 
7091 template <typename NameGenerator>
7092 void GenerateNamesRecursively(Types0, std::vector<std::string>*, int) {}
7093 
7094 template <typename NameGenerator, typename Types>
7095 void GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) {
7096   result->push_back(NameGenerator::template GetName<typename Types::Head>(i));
7097   GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result,
7098                                           i + 1);
7099 }
7100 
7101 template <typename NameGenerator, typename Types>
7102 std::vector<std::string> GenerateNames() {
7103   std::vector<std::string> result;
7104   GenerateNamesRecursively<NameGenerator>(Types(), &result, 0);
7105   return result;
7106 }
7107 
7108 // TypeParameterizedTest<Fixture, TestSel, Types>::Register()
7109 // registers a list of type-parameterized tests with Google Test.  The
7110 // return value is insignificant - we just need to return something
7111 // such that we can call this function in a namespace scope.
7112 //
7113 // Implementation note: The GTEST_TEMPLATE_ macro declares a template
7114 // template parameter.  It's defined in gtest-type-util.h.
7115 template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
7116 class TypeParameterizedTest {
7117  public:
7118   // 'index' is the index of the test in the type list 'Types'
7119   // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
7120   // Types).  Valid values for 'index' are [0, N - 1] where N is the
7121   // length of Types.
7122   static bool Register(const char* prefix, const CodeLocation& code_location,
7123                        const char* case_name, const char* test_names, int index,
7124                        const std::vector<std::string>& type_names =
7125                            GenerateNames<DefaultNameGenerator, Types>()) {
7126     typedef typename Types::Head Type;
7127     typedef Fixture<Type> FixtureClass;
7128     typedef typename GTEST_BIND_(TestSel, Type) TestClass;
7129 
7130     // First, registers the first type-parameterized test in the type
7131     // list.
7132     MakeAndRegisterTestInfo(
7133         (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
7134          "/" + type_names[index])
7135             .c_str(),
7136         StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
7137         GetTypeName<Type>().c_str(),
7138         nullptr,  // No value parameter.
7139         code_location, GetTypeId<FixtureClass>(),
7140         SuiteApiResolver<TestClass>::GetSetUpCaseOrSuite(),
7141         SuiteApiResolver<TestClass>::GetTearDownCaseOrSuite(),
7142         new TestFactoryImpl<TestClass>);
7143 
7144     // Next, recurses (at compile time) with the tail of the type list.
7145     return TypeParameterizedTest<Fixture, TestSel,
7146                                  typename Types::Tail>::Register(prefix,
7147                                                                  code_location,
7148                                                                  case_name,
7149                                                                  test_names,
7150                                                                  index + 1,
7151                                                                  type_names);
7152   }
7153 };
7154 
7155 // The base case for the compile time recursion.
7156 template <GTEST_TEMPLATE_ Fixture, class TestSel>
7157 class TypeParameterizedTest<Fixture, TestSel, Types0> {
7158  public:
7159   static bool Register(const char* /*prefix*/, const CodeLocation&,
7160                        const char* /*case_name*/, const char* /*test_names*/,
7161                        int /*index*/,
7162                        const std::vector<std::string>& =
7163                            std::vector<std::string>() /*type_names*/) {
7164     return true;
7165   }
7166 };
7167 
7168 // TypeParameterizedTestSuite<Fixture, Tests, Types>::Register()
7169 // registers *all combinations* of 'Tests' and 'Types' with Google
7170 // Test.  The return value is insignificant - we just need to return
7171 // something such that we can call this function in a namespace scope.
7172 template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
7173 class TypeParameterizedTestSuite {
7174  public:
7175   static bool Register(const char* prefix, CodeLocation code_location,
7176                        const TypedTestSuitePState* state, const char* case_name,
7177                        const char* test_names,
7178                        const std::vector<std::string>& type_names =
7179                            GenerateNames<DefaultNameGenerator, Types>()) {
7180     std::string test_name = StripTrailingSpaces(
7181         GetPrefixUntilComma(test_names));
7182     if (!state->TestExists(test_name)) {
7183       fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
7184               case_name, test_name.c_str(),
7185               FormatFileLocation(code_location.file.c_str(),
7186                                  code_location.line).c_str());
7187       fflush(stderr);
7188       posix::Abort();
7189     }
7190     const CodeLocation& test_location = state->GetCodeLocation(test_name);
7191 
7192     typedef typename Tests::Head Head;
7193 
7194     // First, register the first test in 'Test' for each type in 'Types'.
7195     TypeParameterizedTest<Fixture, Head, Types>::Register(
7196         prefix, test_location, case_name, test_names, 0, type_names);
7197 
7198     // Next, recurses (at compile time) with the tail of the test list.
7199     return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
7200                                       Types>::Register(prefix, code_location,
7201                                                        state, case_name,
7202                                                        SkipComma(test_names),
7203                                                        type_names);
7204   }
7205 };
7206 
7207 // The base case for the compile time recursion.
7208 template <GTEST_TEMPLATE_ Fixture, typename Types>
7209 class TypeParameterizedTestSuite<Fixture, Templates0, Types> {
7210  public:
7211   static bool Register(const char* /*prefix*/, const CodeLocation&,
7212                        const TypedTestSuitePState* /*state*/,
7213                        const char* /*case_name*/, const char* /*test_names*/,
7214                        const std::vector<std::string>& =
7215                            std::vector<std::string>() /*type_names*/) {
7216     return true;
7217   }
7218 };
7219 
7220 #endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
7221 
7222 // Returns the current OS stack trace as an std::string.
7223 //
7224 // The maximum number of stack frames to be included is specified by
7225 // the gtest_stack_trace_depth flag.  The skip_count parameter
7226 // specifies the number of top frames to be skipped, which doesn't
7227 // count against the number of frames to be included.
7228 //
7229 // For example, if Foo() calls Bar(), which in turn calls
7230 // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
7231 // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
7232 GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
7233     UnitTest* unit_test, int skip_count);
7234 
7235 // Helpers for suppressing warnings on unreachable code or constant
7236 // condition.
7237 
7238 // Always returns true.
7239 GTEST_API_ bool AlwaysTrue();
7240 
7241 // Always returns false.
7242 inline bool AlwaysFalse() { return !AlwaysTrue(); }
7243 
7244 // Helper for suppressing false warning from Clang on a const char*
7245 // variable declared in a conditional expression always being NULL in
7246 // the else branch.
7247 struct GTEST_API_ ConstCharPtr {
7248   ConstCharPtr(const char* str) : value(str) {}
7249   operator bool() const { return true; }
7250   const char* value;
7251 };
7252 
7253 // A simple Linear Congruential Generator for generating random
7254 // numbers with a uniform distribution.  Unlike rand() and srand(), it
7255 // doesn't use global state (and therefore can't interfere with user
7256 // code).  Unlike rand_r(), it's portable.  An LCG isn't very random,
7257 // but it's good enough for our purposes.
7258 class GTEST_API_ Random {
7259  public:
7260   static const UInt32 kMaxRange = 1u << 31;
7261 
7262   explicit Random(UInt32 seed) : state_(seed) {}
7263 
7264   void Reseed(UInt32 seed) { state_ = seed; }
7265 
7266   // Generates a random number from [0, range).  Crashes if 'range' is
7267   // 0 or greater than kMaxRange.
7268   UInt32 Generate(UInt32 range);
7269 
7270  private:
7271   UInt32 state_;
7272   GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
7273 };
7274 
7275 // Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
7276 // compiler error iff T1 and T2 are different types.
7277 template <typename T1, typename T2>
7278 struct CompileAssertTypesEqual;
7279 
7280 template <typename T>
7281 struct CompileAssertTypesEqual<T, T> {
7282 };
7283 
7284 // Removes the reference from a type if it is a reference type,
7285 // otherwise leaves it unchanged.  This is the same as
7286 // tr1::remove_reference, which is not widely available yet.
7287 template <typename T>
7288 struct RemoveReference { typedef T type; };  // NOLINT
7289 template <typename T>
7290 struct RemoveReference<T&> { typedef T type; };  // NOLINT
7291 
7292 // A handy wrapper around RemoveReference that works when the argument
7293 // T depends on template parameters.
7294 #define GTEST_REMOVE_REFERENCE_(T) \
7295     typename ::testing::internal::RemoveReference<T>::type
7296 
7297 // Removes const from a type if it is a const type, otherwise leaves
7298 // it unchanged.  This is the same as tr1::remove_const, which is not
7299 // widely available yet.
7300 template <typename T>
7301 struct RemoveConst { typedef T type; };  // NOLINT
7302 template <typename T>
7303 struct RemoveConst<const T> { typedef T type; };  // NOLINT
7304 
7305 // MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
7306 // definition to fail to remove the const in 'const int[3]' and 'const
7307 // char[3][4]'.  The following specialization works around the bug.
7308 template <typename T, size_t N>
7309 struct RemoveConst<const T[N]> {
7310   typedef typename RemoveConst<T>::type type[N];
7311 };
7312 
7313 // A handy wrapper around RemoveConst that works when the argument
7314 // T depends on template parameters.
7315 #define GTEST_REMOVE_CONST_(T) \
7316     typename ::testing::internal::RemoveConst<T>::type
7317 
7318 // Turns const U&, U&, const U, and U all into U.
7319 #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
7320     GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
7321 
7322 // IsAProtocolMessage<T>::value is a compile-time bool constant that's
7323 // true iff T is type proto2::Message or a subclass of it.
7324 template <typename T>
7325 struct IsAProtocolMessage
7326     : public bool_constant<
7327   std::is_convertible<const T*, const ::proto2::Message*>::value> {
7328 };
7329 
7330 // When the compiler sees expression IsContainerTest<C>(0), if C is an
7331 // STL-style container class, the first overload of IsContainerTest
7332 // will be viable (since both C::iterator* and C::const_iterator* are
7333 // valid types and NULL can be implicitly converted to them).  It will
7334 // be picked over the second overload as 'int' is a perfect match for
7335 // the type of argument 0.  If C::iterator or C::const_iterator is not
7336 // a valid type, the first overload is not viable, and the second
7337 // overload will be picked.  Therefore, we can determine whether C is
7338 // a container class by checking the type of IsContainerTest<C>(0).
7339 // The value of the expression is insignificant.
7340 //
7341 // In C++11 mode we check the existence of a const_iterator and that an
7342 // iterator is properly implemented for the container.
7343 //
7344 // For pre-C++11 that we look for both C::iterator and C::const_iterator.
7345 // The reason is that C++ injects the name of a class as a member of the
7346 // class itself (e.g. you can refer to class iterator as either
7347 // 'iterator' or 'iterator::iterator').  If we look for C::iterator
7348 // only, for example, we would mistakenly think that a class named
7349 // iterator is an STL container.
7350 //
7351 // Also note that the simpler approach of overloading
7352 // IsContainerTest(typename C::const_iterator*) and
7353 // IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
7354 typedef int IsContainer;
7355 template <class C,
7356           class Iterator = decltype(::std::declval<const C&>().begin()),
7357           class = decltype(::std::declval<const C&>().end()),
7358           class = decltype(++::std::declval<Iterator&>()),
7359           class = decltype(*::std::declval<Iterator>()),
7360           class = typename C::const_iterator>
7361 IsContainer IsContainerTest(int /* dummy */) {
7362   return 0;
7363 }
7364 
7365 typedef char IsNotContainer;
7366 template <class C>
7367 IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
7368 
7369 // Trait to detect whether a type T is a hash table.
7370 // The heuristic used is that the type contains an inner type `hasher` and does
7371 // not contain an inner type `reverse_iterator`.
7372 // If the container is iterable in reverse, then order might actually matter.
7373 template <typename T>
7374 struct IsHashTable {
7375  private:
7376   template <typename U>
7377   static char test(typename U::hasher*, typename U::reverse_iterator*);
7378   template <typename U>
7379   static int test(typename U::hasher*, ...);
7380   template <typename U>
7381   static char test(...);
7382 
7383  public:
7384   static const bool value = sizeof(test<T>(nullptr, nullptr)) == sizeof(int);
7385 };
7386 
7387 template <typename T>
7388 const bool IsHashTable<T>::value;
7389 
7390 template <typename C,
7391           bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)>
7392 struct IsRecursiveContainerImpl;
7393 
7394 template <typename C>
7395 struct IsRecursiveContainerImpl<C, false> : public false_type {};
7396 
7397 // Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to
7398 // obey the same inconsistencies as the IsContainerTest, namely check if
7399 // something is a container is relying on only const_iterator in C++11 and
7400 // is relying on both const_iterator and iterator otherwise
7401 template <typename C>
7402 struct IsRecursiveContainerImpl<C, true> {
7403   using value_type = decltype(*std::declval<typename C::const_iterator>());
7404   using type =
7405       is_same<typename std::remove_const<
7406                   typename std::remove_reference<value_type>::type>::type,
7407               C>;
7408 };
7409 
7410 // IsRecursiveContainer<Type> is a unary compile-time predicate that
7411 // evaluates whether C is a recursive container type. A recursive container
7412 // type is a container type whose value_type is equal to the container type
7413 // itself. An example for a recursive container type is
7414 // boost::filesystem::path, whose iterator has a value_type that is equal to
7415 // boost::filesystem::path.
7416 template <typename C>
7417 struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
7418 
7419 // EnableIf<condition>::type is void when 'Cond' is true, and
7420 // undefined when 'Cond' is false.  To use SFINAE to make a function
7421 // overload only apply when a particular expression is true, add
7422 // "typename EnableIf<expression>::type* = 0" as the last parameter.
7423 template<bool> struct EnableIf;
7424 template<> struct EnableIf<true> { typedef void type; };  // NOLINT
7425 
7426 // Utilities for native arrays.
7427 
7428 // ArrayEq() compares two k-dimensional native arrays using the
7429 // elements' operator==, where k can be any integer >= 0.  When k is
7430 // 0, ArrayEq() degenerates into comparing a single pair of values.
7431 
7432 template <typename T, typename U>
7433 bool ArrayEq(const T* lhs, size_t size, const U* rhs);
7434 
7435 // This generic version is used when k is 0.
7436 template <typename T, typename U>
7437 inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
7438 
7439 // This overload is used when k >= 1.
7440 template <typename T, typename U, size_t N>
7441 inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
7442   return internal::ArrayEq(lhs, N, rhs);
7443 }
7444 
7445 // This helper reduces code bloat.  If we instead put its logic inside
7446 // the previous ArrayEq() function, arrays with different sizes would
7447 // lead to different copies of the template code.
7448 template <typename T, typename U>
7449 bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
7450   for (size_t i = 0; i != size; i++) {
7451     if (!internal::ArrayEq(lhs[i], rhs[i]))
7452       return false;
7453   }
7454   return true;
7455 }
7456 
7457 // Finds the first element in the iterator range [begin, end) that
7458 // equals elem.  Element may be a native array type itself.
7459 template <typename Iter, typename Element>
7460 Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
7461   for (Iter it = begin; it != end; ++it) {
7462     if (internal::ArrayEq(*it, elem))
7463       return it;
7464   }
7465   return end;
7466 }
7467 
7468 // CopyArray() copies a k-dimensional native array using the elements'
7469 // operator=, where k can be any integer >= 0.  When k is 0,
7470 // CopyArray() degenerates into copying a single value.
7471 
7472 template <typename T, typename U>
7473 void CopyArray(const T* from, size_t size, U* to);
7474 
7475 // This generic version is used when k is 0.
7476 template <typename T, typename U>
7477 inline void CopyArray(const T& from, U* to) { *to = from; }
7478 
7479 // This overload is used when k >= 1.
7480 template <typename T, typename U, size_t N>
7481 inline void CopyArray(const T(&from)[N], U(*to)[N]) {
7482   internal::CopyArray(from, N, *to);
7483 }
7484 
7485 // This helper reduces code bloat.  If we instead put its logic inside
7486 // the previous CopyArray() function, arrays with different sizes
7487 // would lead to different copies of the template code.
7488 template <typename T, typename U>
7489 void CopyArray(const T* from, size_t size, U* to) {
7490   for (size_t i = 0; i != size; i++) {
7491     internal::CopyArray(from[i], to + i);
7492   }
7493 }
7494 
7495 // The relation between an NativeArray object (see below) and the
7496 // native array it represents.
7497 // We use 2 different structs to allow non-copyable types to be used, as long
7498 // as RelationToSourceReference() is passed.
7499 struct RelationToSourceReference {};
7500 struct RelationToSourceCopy {};
7501 
7502 // Adapts a native array to a read-only STL-style container.  Instead
7503 // of the complete STL container concept, this adaptor only implements
7504 // members useful for Google Mock's container matchers.  New members
7505 // should be added as needed.  To simplify the implementation, we only
7506 // support Element being a raw type (i.e. having no top-level const or
7507 // reference modifier).  It's the client's responsibility to satisfy
7508 // this requirement.  Element can be an array type itself (hence
7509 // multi-dimensional arrays are supported).
7510 template <typename Element>
7511 class NativeArray {
7512  public:
7513   // STL-style container typedefs.
7514   typedef Element value_type;
7515   typedef Element* iterator;
7516   typedef const Element* const_iterator;
7517 
7518   // Constructs from a native array. References the source.
7519   NativeArray(const Element* array, size_t count, RelationToSourceReference) {
7520     InitRef(array, count);
7521   }
7522 
7523   // Constructs from a native array. Copies the source.
7524   NativeArray(const Element* array, size_t count, RelationToSourceCopy) {
7525     InitCopy(array, count);
7526   }
7527 
7528   // Copy constructor.
7529   NativeArray(const NativeArray& rhs) {
7530     (this->*rhs.clone_)(rhs.array_, rhs.size_);
7531   }
7532 
7533   ~NativeArray() {
7534     if (clone_ != &NativeArray::InitRef)
7535       delete[] array_;
7536   }
7537 
7538   // STL-style container methods.
7539   size_t size() const { return size_; }
7540   const_iterator begin() const { return array_; }
7541   const_iterator end() const { return array_ + size_; }
7542   bool operator==(const NativeArray& rhs) const {
7543     return size() == rhs.size() &&
7544         ArrayEq(begin(), size(), rhs.begin());
7545   }
7546 
7547  private:
7548   enum {
7549     kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
7550         Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value
7551   };
7552 
7553   // Initializes this object with a copy of the input.
7554   void InitCopy(const Element* array, size_t a_size) {
7555     Element* const copy = new Element[a_size];
7556     CopyArray(array, a_size, copy);
7557     array_ = copy;
7558     size_ = a_size;
7559     clone_ = &NativeArray::InitCopy;
7560   }
7561 
7562   // Initializes this object with a reference of the input.
7563   void InitRef(const Element* array, size_t a_size) {
7564     array_ = array;
7565     size_ = a_size;
7566     clone_ = &NativeArray::InitRef;
7567   }
7568 
7569   const Element* array_;
7570   size_t size_;
7571   void (NativeArray::*clone_)(const Element*, size_t);
7572 
7573   GTEST_DISALLOW_ASSIGN_(NativeArray);
7574 };
7575 
7576 // Backport of std::index_sequence.
7577 template <size_t... Is>
7578 struct IndexSequence {
7579   using type = IndexSequence;
7580 };
7581 
7582 // Double the IndexSequence, and one if plus_one is true.
7583 template <bool plus_one, typename T, size_t sizeofT>
7584 struct DoubleSequence;
7585 template <size_t... I, size_t sizeofT>
7586 struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
7587   using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
7588 };
7589 template <size_t... I, size_t sizeofT>
7590 struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
7591   using type = IndexSequence<I..., (sizeofT + I)...>;
7592 };
7593 
7594 // Backport of std::make_index_sequence.
7595 // It uses O(ln(N)) instantiation depth.
7596 template <size_t N>
7597 struct MakeIndexSequence
7598     : DoubleSequence<N % 2 == 1, typename MakeIndexSequence<N / 2>::type,
7599                      N / 2>::type {};
7600 
7601 template <>
7602 struct MakeIndexSequence<0> : IndexSequence<> {};
7603 
7604 // FIXME: This implementation of ElemFromList is O(1) in instantiation depth,
7605 // but it is O(N^2) in total instantiations. Not sure if this is the best
7606 // tradeoff, as it will make it somewhat slow to compile.
7607 template <typename T, size_t, size_t>
7608 struct ElemFromListImpl {};
7609 
7610 template <typename T, size_t I>
7611 struct ElemFromListImpl<T, I, I> {
7612   using type = T;
7613 };
7614 
7615 // Get the Nth element from T...
7616 // It uses O(1) instantiation depth.
7617 template <size_t N, typename I, typename... T>
7618 struct ElemFromList;
7619 
7620 template <size_t N, size_t... I, typename... T>
7621 struct ElemFromList<N, IndexSequence<I...>, T...>
7622     : ElemFromListImpl<T, N, I>... {};
7623 
7624 template <typename... T>
7625 class FlatTuple;
7626 
7627 template <typename Derived, size_t I>
7628 struct FlatTupleElemBase;
7629 
7630 template <typename... T, size_t I>
7631 struct FlatTupleElemBase<FlatTuple<T...>, I> {
7632   using value_type =
7633       typename ElemFromList<I, typename MakeIndexSequence<sizeof...(T)>::type,
7634                             T...>::type;
7635   FlatTupleElemBase() = default;
7636   explicit FlatTupleElemBase(value_type t) : value(std::move(t)) {}
7637   value_type value;
7638 };
7639 
7640 template <typename Derived, typename Idx>
7641 struct FlatTupleBase;
7642 
7643 template <size_t... Idx, typename... T>
7644 struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
7645     : FlatTupleElemBase<FlatTuple<T...>, Idx>... {
7646   using Indices = IndexSequence<Idx...>;
7647   FlatTupleBase() = default;
7648   explicit FlatTupleBase(T... t)
7649       : FlatTupleElemBase<FlatTuple<T...>, Idx>(std::move(t))... {}
7650 };
7651 
7652 // Analog to std::tuple but with different tradeoffs.
7653 // This class minimizes the template instantiation depth, thus allowing more
7654 // elements that std::tuple would. std::tuple has been seen to require an
7655 // instantiation depth of more than 10x the number of elements in some
7656 // implementations.
7657 // FlatTuple and ElemFromList are not recursive and have a fixed depth
7658 // regardless of T...
7659 // MakeIndexSequence, on the other hand, it is recursive but with an
7660 // instantiation depth of O(ln(N)).
7661 template <typename... T>
7662 class FlatTuple
7663     : private FlatTupleBase<FlatTuple<T...>,
7664                             typename MakeIndexSequence<sizeof...(T)>::type> {
7665   using Indices = typename FlatTuple::FlatTupleBase::Indices;
7666 
7667  public:
7668   FlatTuple() = default;
7669   explicit FlatTuple(T... t) : FlatTuple::FlatTupleBase(std::move(t)...) {}
7670 
7671   template <size_t I>
7672   const typename ElemFromList<I, Indices, T...>::type& Get() const {
7673     return static_cast<const FlatTupleElemBase<FlatTuple, I>*>(this)->value;
7674   }
7675 
7676   template <size_t I>
7677   typename ElemFromList<I, Indices, T...>::type& Get() {
7678     return static_cast<FlatTupleElemBase<FlatTuple, I>*>(this)->value;
7679   }
7680 };
7681 
7682 // Utility functions to be called with static_assert to induce deprecation
7683 // warnings.
7684 GTEST_INTERNAL_DEPRECATED(
7685     "INSTANTIATE_TEST_CASE_P is deprecated, please use "
7686     "INSTANTIATE_TEST_SUITE_P")
7687 constexpr bool InstantiateTestCase_P_IsDeprecated() { return true; }
7688 
7689 GTEST_INTERNAL_DEPRECATED(
7690     "TYPED_TEST_CASE_P is deprecated, please use "
7691     "TYPED_TEST_SUITE_P")
7692 constexpr bool TypedTestCase_P_IsDeprecated() { return true; }
7693 
7694 GTEST_INTERNAL_DEPRECATED(
7695     "TYPED_TEST_CASE is deprecated, please use "
7696     "TYPED_TEST_SUITE")
7697 constexpr bool TypedTestCaseIsDeprecated() { return true; }
7698 
7699 GTEST_INTERNAL_DEPRECATED(
7700     "REGISTER_TYPED_TEST_CASE_P is deprecated, please use "
7701     "REGISTER_TYPED_TEST_SUITE_P")
7702 constexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; }
7703 
7704 GTEST_INTERNAL_DEPRECATED(
7705     "INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use "
7706     "INSTANTIATE_TYPED_TEST_SUITE_P")
7707 constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
7708 
7709 }  // namespace internal
7710 }  // namespace testing
7711 
7712 #define GTEST_MESSAGE_AT_(file, line, message, result_type) \
7713   ::testing::internal::AssertHelper(result_type, file, line, message) \
7714     = ::testing::Message()
7715 
7716 #define GTEST_MESSAGE_(message, result_type) \
7717   GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
7718 
7719 #define GTEST_FATAL_FAILURE_(message) \
7720   return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
7721 
7722 #define GTEST_NONFATAL_FAILURE_(message) \
7723   GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
7724 
7725 #define GTEST_SUCCESS_(message) \
7726   GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
7727 
7728 #define GTEST_SKIP_(message) \
7729   return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
7730 
7731 // Suppress MSVC warning 4072 (unreachable code) for the code following
7732 // statement if it returns or throws (or doesn't return or throw in some
7733 // situations).
7734 #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
7735   if (::testing::internal::AlwaysTrue()) { statement; }
7736 
7737 #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
7738   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7739   if (::testing::internal::ConstCharPtr gtest_msg = "") { \
7740     bool gtest_caught_expected = false; \
7741     try { \
7742       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7743     } \
7744     catch (expected_exception const&) { \
7745       gtest_caught_expected = true; \
7746     } \
7747     catch (...) { \
7748       gtest_msg.value = \
7749           "Expected: " #statement " throws an exception of type " \
7750           #expected_exception ".\n  Actual: it throws a different type."; \
7751       goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
7752     } \
7753     if (!gtest_caught_expected) { \
7754       gtest_msg.value = \
7755           "Expected: " #statement " throws an exception of type " \
7756           #expected_exception ".\n  Actual: it throws nothing."; \
7757       goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
7758     } \
7759   } else \
7760     GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
7761       fail(gtest_msg.value)
7762 
7763 #define GTEST_TEST_NO_THROW_(statement, fail) \
7764   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7765   if (::testing::internal::AlwaysTrue()) { \
7766     try { \
7767       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7768     } \
7769     catch (...) { \
7770       goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
7771     } \
7772   } else \
7773     GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
7774       fail("Expected: " #statement " doesn't throw an exception.\n" \
7775            "  Actual: it throws.")
7776 
7777 #define GTEST_TEST_ANY_THROW_(statement, fail) \
7778   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7779   if (::testing::internal::AlwaysTrue()) { \
7780     bool gtest_caught_any = false; \
7781     try { \
7782       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7783     } \
7784     catch (...) { \
7785       gtest_caught_any = true; \
7786     } \
7787     if (!gtest_caught_any) { \
7788       goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
7789     } \
7790   } else \
7791     GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
7792       fail("Expected: " #statement " throws an exception.\n" \
7793            "  Actual: it doesn't.")
7794 
7795 
7796 // Implements Boolean test assertions such as EXPECT_TRUE. expression can be
7797 // either a boolean expression or an AssertionResult. text is a textual
7798 // represenation of expression as it was passed into the EXPECT_TRUE.
7799 #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
7800   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7801   if (const ::testing::AssertionResult gtest_ar_ = \
7802       ::testing::AssertionResult(expression)) \
7803     ; \
7804   else \
7805     fail(::testing::internal::GetBoolAssertionFailureMessage(\
7806         gtest_ar_, text, #actual, #expected).c_str())
7807 
7808 #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
7809   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7810   if (::testing::internal::AlwaysTrue()) { \
7811     ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
7812     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7813     if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
7814       goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
7815     } \
7816   } else \
7817     GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
7818       fail("Expected: " #statement " doesn't generate new fatal " \
7819            "failures in the current thread.\n" \
7820            "  Actual: it does.")
7821 
7822 // Expands to the name of the class that implements the given test.
7823 #define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
7824   test_suite_name##_##test_name##_Test
7825 
7826 // Helper macro for defining tests.
7827 #define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id)      \
7828   class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)                    \
7829       : public parent_class {                                                 \
7830    public:                                                                    \
7831     GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {}                   \
7832                                                                               \
7833    private:                                                                   \
7834     virtual void TestBody();                                                  \
7835     static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;     \
7836     GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,   \
7837                                                            test_name));       \
7838   };                                                                          \
7839                                                                               \
7840   ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name,          \
7841                                                     test_name)::test_info_ =  \
7842       ::testing::internal::MakeAndRegisterTestInfo(                           \
7843           #test_suite_name, #test_name, nullptr, nullptr,                     \
7844           ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
7845           ::testing::internal::SuiteApiResolver<                              \
7846               parent_class>::GetSetUpCaseOrSuite(),                           \
7847           ::testing::internal::SuiteApiResolver<                              \
7848               parent_class>::GetTearDownCaseOrSuite(),                        \
7849           new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_(    \
7850               test_suite_name, test_name)>);                                  \
7851   void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
7852 
7853 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
7854 // Copyright 2005, Google Inc.
7855 // All rights reserved.
7856 //
7857 // Redistribution and use in source and binary forms, with or without
7858 // modification, are permitted provided that the following conditions are
7859 // met:
7860 //
7861 //     * Redistributions of source code must retain the above copyright
7862 // notice, this list of conditions and the following disclaimer.
7863 //     * Redistributions in binary form must reproduce the above
7864 // copyright notice, this list of conditions and the following disclaimer
7865 // in the documentation and/or other materials provided with the
7866 // distribution.
7867 //     * Neither the name of Google Inc. nor the names of its
7868 // contributors may be used to endorse or promote products derived from
7869 // this software without specific prior written permission.
7870 //
7871 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7872 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7873 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7874 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7875 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7876 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7877 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7878 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7879 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7880 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7881 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7882 
7883 //
7884 // The Google C++ Testing and Mocking Framework (Google Test)
7885 //
7886 // This header file defines the public API for death tests.  It is
7887 // #included by gtest.h so a user doesn't need to include this
7888 // directly.
7889 // GOOGLETEST_CM0001 DO NOT DELETE
7890 
7891 #ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
7892 #define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
7893 
7894 // Copyright 2005, Google Inc.
7895 // All rights reserved.
7896 //
7897 // Redistribution and use in source and binary forms, with or without
7898 // modification, are permitted provided that the following conditions are
7899 // met:
7900 //
7901 //     * Redistributions of source code must retain the above copyright
7902 // notice, this list of conditions and the following disclaimer.
7903 //     * Redistributions in binary form must reproduce the above
7904 // copyright notice, this list of conditions and the following disclaimer
7905 // in the documentation and/or other materials provided with the
7906 // distribution.
7907 //     * Neither the name of Google Inc. nor the names of its
7908 // contributors may be used to endorse or promote products derived from
7909 // this software without specific prior written permission.
7910 //
7911 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7912 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7913 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7914 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7915 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7916 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7917 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7918 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7919 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7920 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7921 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7922 //
7923 // The Google C++ Testing and Mocking Framework (Google Test)
7924 //
7925 // This header file defines internal utilities needed for implementing
7926 // death tests.  They are subject to change without notice.
7927 // GOOGLETEST_CM0001 DO NOT DELETE
7928 
7929 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
7930 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
7931 
7932 // Copyright 2007, Google Inc.
7933 // All rights reserved.
7934 //
7935 // Redistribution and use in source and binary forms, with or without
7936 // modification, are permitted provided that the following conditions are
7937 // met:
7938 //
7939 //     * Redistributions of source code must retain the above copyright
7940 // notice, this list of conditions and the following disclaimer.
7941 //     * Redistributions in binary form must reproduce the above
7942 // copyright notice, this list of conditions and the following disclaimer
7943 // in the documentation and/or other materials provided with the
7944 // distribution.
7945 //     * Neither the name of Google Inc. nor the names of its
7946 // contributors may be used to endorse or promote products derived from
7947 // this software without specific prior written permission.
7948 //
7949 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7950 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7951 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7952 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7953 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7954 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7955 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7956 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7957 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7958 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7959 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7960 
7961 // The Google C++ Testing and Mocking Framework (Google Test)
7962 //
7963 // This file implements just enough of the matcher interface to allow
7964 // EXPECT_DEATH and friends to accept a matcher argument.
7965 
7966 // IWYU pragma: private, include "testing/base/public/gunit.h"
7967 // IWYU pragma: friend third_party/googletest/googlemock/.*
7968 // IWYU pragma: friend third_party/googletest/googletest/.*
7969 
7970 #ifndef GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
7971 #define GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
7972 
7973 #include <memory>
7974 #include <ostream>
7975 #include <string>
7976 
7977 // Copyright 2007, Google Inc.
7978 // All rights reserved.
7979 //
7980 // Redistribution and use in source and binary forms, with or without
7981 // modification, are permitted provided that the following conditions are
7982 // met:
7983 //
7984 //     * Redistributions of source code must retain the above copyright
7985 // notice, this list of conditions and the following disclaimer.
7986 //     * Redistributions in binary form must reproduce the above
7987 // copyright notice, this list of conditions and the following disclaimer
7988 // in the documentation and/or other materials provided with the
7989 // distribution.
7990 //     * Neither the name of Google Inc. nor the names of its
7991 // contributors may be used to endorse or promote products derived from
7992 // this software without specific prior written permission.
7993 //
7994 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7995 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7996 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7997 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7998 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7999 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8000 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
8001 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
8002 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8003 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
8004 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8005 
8006 
8007 // Google Test - The Google C++ Testing and Mocking Framework
8008 //
8009 // This file implements a universal value printer that can print a
8010 // value of any type T:
8011 //
8012 //   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
8013 //
8014 // A user can teach this function how to print a class type T by
8015 // defining either operator<<() or PrintTo() in the namespace that
8016 // defines T.  More specifically, the FIRST defined function in the
8017 // following list will be used (assuming T is defined in namespace
8018 // foo):
8019 //
8020 //   1. foo::PrintTo(const T&, ostream*)
8021 //   2. operator<<(ostream&, const T&) defined in either foo or the
8022 //      global namespace.
8023 //
8024 // However if T is an STL-style container then it is printed element-wise
8025 // unless foo::PrintTo(const T&, ostream*) is defined. Note that
8026 // operator<<() is ignored for container types.
8027 //
8028 // If none of the above is defined, it will print the debug string of
8029 // the value if it is a protocol buffer, or print the raw bytes in the
8030 // value otherwise.
8031 //
8032 // To aid debugging: when T is a reference type, the address of the
8033 // value is also printed; when T is a (const) char pointer, both the
8034 // pointer value and the NUL-terminated string it points to are
8035 // printed.
8036 //
8037 // We also provide some convenient wrappers:
8038 //
8039 //   // Prints a value to a string.  For a (const or not) char
8040 //   // pointer, the NUL-terminated string (but not the pointer) is
8041 //   // printed.
8042 //   std::string ::testing::PrintToString(const T& value);
8043 //
8044 //   // Prints a value tersely: for a reference type, the referenced
8045 //   // value (but not the address) is printed; for a (const or not) char
8046 //   // pointer, the NUL-terminated string (but not the pointer) is
8047 //   // printed.
8048 //   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
8049 //
8050 //   // Prints value using the type inferred by the compiler.  The difference
8051 //   // from UniversalTersePrint() is that this function prints both the
8052 //   // pointer and the NUL-terminated string for a (const or not) char pointer.
8053 //   void ::testing::internal::UniversalPrint(const T& value, ostream*);
8054 //
8055 //   // Prints the fields of a tuple tersely to a string vector, one
8056 //   // element for each field. Tuple support must be enabled in
8057 //   // gtest-port.h.
8058 //   std::vector<string> UniversalTersePrintTupleFieldsToStrings(
8059 //       const Tuple& value);
8060 //
8061 // Known limitation:
8062 //
8063 // The print primitives print the elements of an STL-style container
8064 // using the compiler-inferred type of *iter where iter is a
8065 // const_iterator of the container.  When const_iterator is an input
8066 // iterator but not a forward iterator, this inferred type may not
8067 // match value_type, and the print output may be incorrect.  In
8068 // practice, this is rarely a problem as for most containers
8069 // const_iterator is a forward iterator.  We'll fix this if there's an
8070 // actual need for it.  Note that this fix cannot rely on value_type
8071 // being defined as many user-defined container types don't have
8072 // value_type.
8073 
8074 // GOOGLETEST_CM0001 DO NOT DELETE
8075 
8076 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8077 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8078 
8079 #include <functional>
8080 #include <ostream>  // NOLINT
8081 #include <sstream>
8082 #include <string>
8083 #include <tuple>
8084 #include <type_traits>
8085 #include <utility>
8086 #include <vector>
8087 
8088 #if GTEST_HAS_ABSL
8089 #include "absl/strings/string_view.h"
8090 #include "absl/types/optional.h"
8091 #include "absl/types/variant.h"
8092 #endif  // GTEST_HAS_ABSL
8093 
8094 namespace testing {
8095 
8096 // Definitions in the 'internal' and 'internal2' name spaces are
8097 // subject to change without notice.  DO NOT USE THEM IN USER CODE!
8098 namespace internal2 {
8099 
8100 // Prints the given number of bytes in the given object to the given
8101 // ostream.
8102 GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
8103                                      size_t count,
8104                                      ::std::ostream* os);
8105 
8106 // For selecting which printer to use when a given type has neither <<
8107 // nor PrintTo().
8108 enum TypeKind {
8109   kProtobuf,              // a protobuf type
8110   kConvertibleToInteger,  // a type implicitly convertible to BiggestInt
8111                           // (e.g. a named or unnamed enum type)
8112 #if GTEST_HAS_ABSL
8113   kConvertibleToStringView,  // a type implicitly convertible to
8114                              // absl::string_view
8115 #endif
8116   kOtherType  // anything else
8117 };
8118 
8119 // TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
8120 // by the universal printer to print a value of type T when neither
8121 // operator<< nor PrintTo() is defined for T, where kTypeKind is the
8122 // "kind" of T as defined by enum TypeKind.
8123 template <typename T, TypeKind kTypeKind>
8124 class TypeWithoutFormatter {
8125  public:
8126   // This default version is called when kTypeKind is kOtherType.
8127   static void PrintValue(const T& value, ::std::ostream* os) {
8128     PrintBytesInObjectTo(static_cast<const unsigned char*>(
8129                              reinterpret_cast<const void*>(&value)),
8130                          sizeof(value), os);
8131   }
8132 };
8133 
8134 // We print a protobuf using its ShortDebugString() when the string
8135 // doesn't exceed this many characters; otherwise we print it using
8136 // DebugString() for better readability.
8137 const size_t kProtobufOneLinerMaxLength = 50;
8138 
8139 template <typename T>
8140 class TypeWithoutFormatter<T, kProtobuf> {
8141  public:
8142   static void PrintValue(const T& value, ::std::ostream* os) {
8143     std::string pretty_str = value.ShortDebugString();
8144     if (pretty_str.length() > kProtobufOneLinerMaxLength) {
8145       pretty_str = "\n" + value.DebugString();
8146     }
8147     *os << ("<" + pretty_str + ">");
8148   }
8149 };
8150 
8151 template <typename T>
8152 class TypeWithoutFormatter<T, kConvertibleToInteger> {
8153  public:
8154   // Since T has no << operator or PrintTo() but can be implicitly
8155   // converted to BiggestInt, we print it as a BiggestInt.
8156   //
8157   // Most likely T is an enum type (either named or unnamed), in which
8158   // case printing it as an integer is the desired behavior.  In case
8159   // T is not an enum, printing it as an integer is the best we can do
8160   // given that it has no user-defined printer.
8161   static void PrintValue(const T& value, ::std::ostream* os) {
8162     const internal::BiggestInt kBigInt = value;
8163     *os << kBigInt;
8164   }
8165 };
8166 
8167 #if GTEST_HAS_ABSL
8168 template <typename T>
8169 class TypeWithoutFormatter<T, kConvertibleToStringView> {
8170  public:
8171   // Since T has neither operator<< nor PrintTo() but can be implicitly
8172   // converted to absl::string_view, we print it as a absl::string_view.
8173   //
8174   // Note: the implementation is further below, as it depends on
8175   // internal::PrintTo symbol which is defined later in the file.
8176   static void PrintValue(const T& value, ::std::ostream* os);
8177 };
8178 #endif
8179 
8180 // Prints the given value to the given ostream.  If the value is a
8181 // protocol message, its debug string is printed; if it's an enum or
8182 // of a type implicitly convertible to BiggestInt, it's printed as an
8183 // integer; otherwise the bytes in the value are printed.  This is
8184 // what UniversalPrinter<T>::Print() does when it knows nothing about
8185 // type T and T has neither << operator nor PrintTo().
8186 //
8187 // A user can override this behavior for a class type Foo by defining
8188 // a << operator in the namespace where Foo is defined.
8189 //
8190 // We put this operator in namespace 'internal2' instead of 'internal'
8191 // to simplify the implementation, as much code in 'internal' needs to
8192 // use << in STL, which would conflict with our own << were it defined
8193 // in 'internal'.
8194 //
8195 // Note that this operator<< takes a generic std::basic_ostream<Char,
8196 // CharTraits> type instead of the more restricted std::ostream.  If
8197 // we define it to take an std::ostream instead, we'll get an
8198 // "ambiguous overloads" compiler error when trying to print a type
8199 // Foo that supports streaming to std::basic_ostream<Char,
8200 // CharTraits>, as the compiler cannot tell whether
8201 // operator<<(std::ostream&, const T&) or
8202 // operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
8203 // specific.
8204 template <typename Char, typename CharTraits, typename T>
8205 ::std::basic_ostream<Char, CharTraits>& operator<<(
8206     ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
8207   TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
8208                                ? kProtobuf
8209                                : std::is_convertible<
8210                                      const T&, internal::BiggestInt>::value
8211                                      ? kConvertibleToInteger
8212                                      :
8213 #if GTEST_HAS_ABSL
8214                                      std::is_convertible<
8215                                          const T&, absl::string_view>::value
8216                                          ? kConvertibleToStringView
8217                                          :
8218 #endif
8219                                          kOtherType)>::PrintValue(x, &os);
8220   return os;
8221 }
8222 
8223 }  // namespace internal2
8224 }  // namespace testing
8225 
8226 // This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
8227 // magic needed for implementing UniversalPrinter won't work.
8228 namespace testing_internal {
8229 
8230 // Used to print a value that is not an STL-style container when the
8231 // user doesn't define PrintTo() for it.
8232 template <typename T>
8233 void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
8234   // With the following statement, during unqualified name lookup,
8235   // testing::internal2::operator<< appears as if it was declared in
8236   // the nearest enclosing namespace that contains both
8237   // ::testing_internal and ::testing::internal2, i.e. the global
8238   // namespace.  For more details, refer to the C++ Standard section
8239   // 7.3.4-1 [namespace.udir].  This allows us to fall back onto
8240   // testing::internal2::operator<< in case T doesn't come with a <<
8241   // operator.
8242   //
8243   // We cannot write 'using ::testing::internal2::operator<<;', which
8244   // gcc 3.3 fails to compile due to a compiler bug.
8245   using namespace ::testing::internal2;  // NOLINT
8246 
8247   // Assuming T is defined in namespace foo, in the next statement,
8248   // the compiler will consider all of:
8249   //
8250   //   1. foo::operator<< (thanks to Koenig look-up),
8251   //   2. ::operator<< (as the current namespace is enclosed in ::),
8252   //   3. testing::internal2::operator<< (thanks to the using statement above).
8253   //
8254   // The operator<< whose type matches T best will be picked.
8255   //
8256   // We deliberately allow #2 to be a candidate, as sometimes it's
8257   // impossible to define #1 (e.g. when foo is ::std, defining
8258   // anything in it is undefined behavior unless you are a compiler
8259   // vendor.).
8260   *os << value;
8261 }
8262 
8263 }  // namespace testing_internal
8264 
8265 namespace testing {
8266 namespace internal {
8267 
8268 // FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
8269 // value of type ToPrint that is an operand of a comparison assertion
8270 // (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in
8271 // the comparison, and is used to help determine the best way to
8272 // format the value.  In particular, when the value is a C string
8273 // (char pointer) and the other operand is an STL string object, we
8274 // want to format the C string as a string, since we know it is
8275 // compared by value with the string object.  If the value is a char
8276 // pointer but the other operand is not an STL string object, we don't
8277 // know whether the pointer is supposed to point to a NUL-terminated
8278 // string, and thus want to print it as a pointer to be safe.
8279 //
8280 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
8281 
8282 // The default case.
8283 template <typename ToPrint, typename OtherOperand>
8284 class FormatForComparison {
8285  public:
8286   static ::std::string Format(const ToPrint& value) {
8287     return ::testing::PrintToString(value);
8288   }
8289 };
8290 
8291 // Array.
8292 template <typename ToPrint, size_t N, typename OtherOperand>
8293 class FormatForComparison<ToPrint[N], OtherOperand> {
8294  public:
8295   static ::std::string Format(const ToPrint* value) {
8296     return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
8297   }
8298 };
8299 
8300 // By default, print C string as pointers to be safe, as we don't know
8301 // whether they actually point to a NUL-terminated string.
8302 
8303 #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \
8304   template <typename OtherOperand>                                      \
8305   class FormatForComparison<CharType*, OtherOperand> {                  \
8306    public:                                                              \
8307     static ::std::string Format(CharType* value) {                      \
8308       return ::testing::PrintToString(static_cast<const void*>(value)); \
8309     }                                                                   \
8310   }
8311 
8312 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
8313 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
8314 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
8315 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
8316 
8317 #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
8318 
8319 // If a C string is compared with an STL string object, we know it's meant
8320 // to point to a NUL-terminated string, and thus can print it as a string.
8321 
8322 #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
8323   template <>                                                           \
8324   class FormatForComparison<CharType*, OtherStringType> {               \
8325    public:                                                              \
8326     static ::std::string Format(CharType* value) {                      \
8327       return ::testing::PrintToString(value);                           \
8328     }                                                                   \
8329   }
8330 
8331 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
8332 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
8333 
8334 #if GTEST_HAS_STD_WSTRING
8335 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
8336 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
8337 #endif
8338 
8339 #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
8340 
8341 // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
8342 // operand to be used in a failure message.  The type (but not value)
8343 // of the other operand may affect the format.  This allows us to
8344 // print a char* as a raw pointer when it is compared against another
8345 // char* or void*, and print it as a C string when it is compared
8346 // against an std::string object, for example.
8347 //
8348 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
8349 template <typename T1, typename T2>
8350 std::string FormatForComparisonFailureMessage(
8351     const T1& value, const T2& /* other_operand */) {
8352   return FormatForComparison<T1, T2>::Format(value);
8353 }
8354 
8355 // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
8356 // value to the given ostream.  The caller must ensure that
8357 // 'ostream_ptr' is not NULL, or the behavior is undefined.
8358 //
8359 // We define UniversalPrinter as a class template (as opposed to a
8360 // function template), as we need to partially specialize it for
8361 // reference types, which cannot be done with function templates.
8362 template <typename T>
8363 class UniversalPrinter;
8364 
8365 template <typename T>
8366 void UniversalPrint(const T& value, ::std::ostream* os);
8367 
8368 enum DefaultPrinterType {
8369   kPrintContainer,
8370   kPrintPointer,
8371   kPrintFunctionPointer,
8372   kPrintOther,
8373 };
8374 template <DefaultPrinterType type> struct WrapPrinterType {};
8375 
8376 // Used to print an STL-style container when the user doesn't define
8377 // a PrintTo() for it.
8378 template <typename C>
8379 void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
8380                     const C& container, ::std::ostream* os) {
8381   const size_t kMaxCount = 32;  // The maximum number of elements to print.
8382   *os << '{';
8383   size_t count = 0;
8384   for (typename C::const_iterator it = container.begin();
8385        it != container.end(); ++it, ++count) {
8386     if (count > 0) {
8387       *os << ',';
8388       if (count == kMaxCount) {  // Enough has been printed.
8389         *os << " ...";
8390         break;
8391       }
8392     }
8393     *os << ' ';
8394     // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
8395     // handle *it being a native array.
8396     internal::UniversalPrint(*it, os);
8397   }
8398 
8399   if (count > 0) {
8400     *os << ' ';
8401   }
8402   *os << '}';
8403 }
8404 
8405 // Used to print a pointer that is neither a char pointer nor a member
8406 // pointer, when the user doesn't define PrintTo() for it.  (A member
8407 // variable pointer or member function pointer doesn't really point to
8408 // a location in the address space.  Their representation is
8409 // implementation-defined.  Therefore they will be printed as raw
8410 // bytes.)
8411 template <typename T>
8412 void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
8413                     T* p, ::std::ostream* os) {
8414   if (p == nullptr) {
8415     *os << "NULL";
8416   } else {
8417     // T is not a function type.  We just call << to print p,
8418     // relying on ADL to pick up user-defined << for their pointer
8419     // types, if any.
8420     *os << p;
8421   }
8422 }
8423 template <typename T>
8424 void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,
8425                     T* p, ::std::ostream* os) {
8426   if (p == nullptr) {
8427     *os << "NULL";
8428   } else {
8429     // T is a function type, so '*os << p' doesn't do what we want
8430     // (it just prints p as bool).  We want to print p as a const
8431     // void*.
8432     *os << reinterpret_cast<const void*>(p);
8433   }
8434 }
8435 
8436 // Used to print a non-container, non-pointer value when the user
8437 // doesn't define PrintTo() for it.
8438 template <typename T>
8439 void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
8440                     const T& value, ::std::ostream* os) {
8441   ::testing_internal::DefaultPrintNonContainerTo(value, os);
8442 }
8443 
8444 // Prints the given value using the << operator if it has one;
8445 // otherwise prints the bytes in it.  This is what
8446 // UniversalPrinter<T>::Print() does when PrintTo() is not specialized
8447 // or overloaded for type T.
8448 //
8449 // A user can override this behavior for a class type Foo by defining
8450 // an overload of PrintTo() in the namespace where Foo is defined.  We
8451 // give the user this option as sometimes defining a << operator for
8452 // Foo is not desirable (e.g. the coding style may prevent doing it,
8453 // or there is already a << operator but it doesn't do what the user
8454 // wants).
8455 template <typename T>
8456 void PrintTo(const T& value, ::std::ostream* os) {
8457   // DefaultPrintTo() is overloaded.  The type of its first argument
8458   // determines which version will be picked.
8459   //
8460   // Note that we check for container types here, prior to we check
8461   // for protocol message types in our operator<<.  The rationale is:
8462   //
8463   // For protocol messages, we want to give people a chance to
8464   // override Google Mock's format by defining a PrintTo() or
8465   // operator<<.  For STL containers, other formats can be
8466   // incompatible with Google Mock's format for the container
8467   // elements; therefore we check for container types here to ensure
8468   // that our format is used.
8469   //
8470   // Note that MSVC and clang-cl do allow an implicit conversion from
8471   // pointer-to-function to pointer-to-object, but clang-cl warns on it.
8472   // So don't use ImplicitlyConvertible if it can be helped since it will
8473   // cause this warning, and use a separate overload of DefaultPrintTo for
8474   // function pointers so that the `*os << p` in the object pointer overload
8475   // doesn't cause that warning either.
8476   DefaultPrintTo(
8477       WrapPrinterType <
8478                   (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
8479               !IsRecursiveContainer<T>::value
8480           ? kPrintContainer
8481           : !std::is_pointer<T>::value
8482                 ? kPrintOther
8483                 : std::is_function<typename std::remove_pointer<T>::type>::value
8484                       ? kPrintFunctionPointer
8485                       : kPrintPointer > (),
8486       value, os);
8487 }
8488 
8489 // The following list of PrintTo() overloads tells
8490 // UniversalPrinter<T>::Print() how to print standard types (built-in
8491 // types, strings, plain arrays, and pointers).
8492 
8493 // Overloads for various char types.
8494 GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
8495 GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
8496 inline void PrintTo(char c, ::std::ostream* os) {
8497   // When printing a plain char, we always treat it as unsigned.  This
8498   // way, the output won't be affected by whether the compiler thinks
8499   // char is signed or not.
8500   PrintTo(static_cast<unsigned char>(c), os);
8501 }
8502 
8503 // Overloads for other simple built-in types.
8504 inline void PrintTo(bool x, ::std::ostream* os) {
8505   *os << (x ? "true" : "false");
8506 }
8507 
8508 // Overload for wchar_t type.
8509 // Prints a wchar_t as a symbol if it is printable or as its internal
8510 // code otherwise and also as its decimal code (except for L'\0').
8511 // The L'\0' char is printed as "L'\\0'". The decimal code is printed
8512 // as signed integer when wchar_t is implemented by the compiler
8513 // as a signed type and is printed as an unsigned integer when wchar_t
8514 // is implemented as an unsigned type.
8515 GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
8516 
8517 // Overloads for C strings.
8518 GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
8519 inline void PrintTo(char* s, ::std::ostream* os) {
8520   PrintTo(ImplicitCast_<const char*>(s), os);
8521 }
8522 
8523 // signed/unsigned char is often used for representing binary data, so
8524 // we print pointers to it as void* to be safe.
8525 inline void PrintTo(const signed char* s, ::std::ostream* os) {
8526   PrintTo(ImplicitCast_<const void*>(s), os);
8527 }
8528 inline void PrintTo(signed char* s, ::std::ostream* os) {
8529   PrintTo(ImplicitCast_<const void*>(s), os);
8530 }
8531 inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
8532   PrintTo(ImplicitCast_<const void*>(s), os);
8533 }
8534 inline void PrintTo(unsigned char* s, ::std::ostream* os) {
8535   PrintTo(ImplicitCast_<const void*>(s), os);
8536 }
8537 
8538 // MSVC can be configured to define wchar_t as a typedef of unsigned
8539 // short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
8540 // type.  When wchar_t is a typedef, defining an overload for const
8541 // wchar_t* would cause unsigned short* be printed as a wide string,
8542 // possibly causing invalid memory accesses.
8543 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
8544 // Overloads for wide C strings
8545 GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
8546 inline void PrintTo(wchar_t* s, ::std::ostream* os) {
8547   PrintTo(ImplicitCast_<const wchar_t*>(s), os);
8548 }
8549 #endif
8550 
8551 // Overload for C arrays.  Multi-dimensional arrays are printed
8552 // properly.
8553 
8554 // Prints the given number of elements in an array, without printing
8555 // the curly braces.
8556 template <typename T>
8557 void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
8558   UniversalPrint(a[0], os);
8559   for (size_t i = 1; i != count; i++) {
8560     *os << ", ";
8561     UniversalPrint(a[i], os);
8562   }
8563 }
8564 
8565 // Overloads for ::std::string.
8566 GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
8567 inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
8568   PrintStringTo(s, os);
8569 }
8570 
8571 // Overloads for ::std::wstring.
8572 #if GTEST_HAS_STD_WSTRING
8573 GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
8574 inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
8575   PrintWideStringTo(s, os);
8576 }
8577 #endif  // GTEST_HAS_STD_WSTRING
8578 
8579 #if GTEST_HAS_ABSL
8580 // Overload for absl::string_view.
8581 inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
8582   PrintTo(::std::string(sp), os);
8583 }
8584 #endif  // GTEST_HAS_ABSL
8585 
8586 inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
8587 
8588 template <typename T>
8589 void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
8590   UniversalPrinter<T&>::Print(ref.get(), os);
8591 }
8592 
8593 // Helper function for printing a tuple.  T must be instantiated with
8594 // a tuple type.
8595 template <typename T>
8596 void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
8597                   ::std::ostream*) {}
8598 
8599 template <typename T, size_t I>
8600 void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
8601                   ::std::ostream* os) {
8602   PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
8603   GTEST_INTENTIONAL_CONST_COND_PUSH_()
8604   if (I > 1) {
8605     GTEST_INTENTIONAL_CONST_COND_POP_()
8606     *os << ", ";
8607   }
8608   UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
8609       std::get<I - 1>(t), os);
8610 }
8611 
8612 template <typename... Types>
8613 void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
8614   *os << "(";
8615   PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
8616   *os << ")";
8617 }
8618 
8619 // Overload for std::pair.
8620 template <typename T1, typename T2>
8621 void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
8622   *os << '(';
8623   // We cannot use UniversalPrint(value.first, os) here, as T1 may be
8624   // a reference type.  The same for printing value.second.
8625   UniversalPrinter<T1>::Print(value.first, os);
8626   *os << ", ";
8627   UniversalPrinter<T2>::Print(value.second, os);
8628   *os << ')';
8629 }
8630 
8631 // Implements printing a non-reference type T by letting the compiler
8632 // pick the right overload of PrintTo() for T.
8633 template <typename T>
8634 class UniversalPrinter {
8635  public:
8636   // MSVC warns about adding const to a function type, so we want to
8637   // disable the warning.
8638   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
8639 
8640   // Note: we deliberately don't call this PrintTo(), as that name
8641   // conflicts with ::testing::internal::PrintTo in the body of the
8642   // function.
8643   static void Print(const T& value, ::std::ostream* os) {
8644     // By default, ::testing::internal::PrintTo() is used for printing
8645     // the value.
8646     //
8647     // Thanks to Koenig look-up, if T is a class and has its own
8648     // PrintTo() function defined in its namespace, that function will
8649     // be visible here.  Since it is more specific than the generic ones
8650     // in ::testing::internal, it will be picked by the compiler in the
8651     // following statement - exactly what we want.
8652     PrintTo(value, os);
8653   }
8654 
8655   GTEST_DISABLE_MSC_WARNINGS_POP_()
8656 };
8657 
8658 #if GTEST_HAS_ABSL
8659 
8660 // Printer for absl::optional
8661 
8662 template <typename T>
8663 class UniversalPrinter<::absl::optional<T>> {
8664  public:
8665   static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
8666     *os << '(';
8667     if (!value) {
8668       *os << "nullopt";
8669     } else {
8670       UniversalPrint(*value, os);
8671     }
8672     *os << ')';
8673   }
8674 };
8675 
8676 // Printer for absl::variant
8677 
8678 template <typename... T>
8679 class UniversalPrinter<::absl::variant<T...>> {
8680  public:
8681   static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {
8682     *os << '(';
8683     absl::visit(Visitor{os}, value);
8684     *os << ')';
8685   }
8686 
8687  private:
8688   struct Visitor {
8689     template <typename U>
8690     void operator()(const U& u) const {
8691       *os << "'" << GetTypeName<U>() << "' with value ";
8692       UniversalPrint(u, os);
8693     }
8694     ::std::ostream* os;
8695   };
8696 };
8697 
8698 #endif  // GTEST_HAS_ABSL
8699 
8700 // UniversalPrintArray(begin, len, os) prints an array of 'len'
8701 // elements, starting at address 'begin'.
8702 template <typename T>
8703 void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
8704   if (len == 0) {
8705     *os << "{}";
8706   } else {
8707     *os << "{ ";
8708     const size_t kThreshold = 18;
8709     const size_t kChunkSize = 8;
8710     // If the array has more than kThreshold elements, we'll have to
8711     // omit some details by printing only the first and the last
8712     // kChunkSize elements.
8713     if (len <= kThreshold) {
8714       PrintRawArrayTo(begin, len, os);
8715     } else {
8716       PrintRawArrayTo(begin, kChunkSize, os);
8717       *os << ", ..., ";
8718       PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
8719     }
8720     *os << " }";
8721   }
8722 }
8723 // This overload prints a (const) char array compactly.
8724 GTEST_API_ void UniversalPrintArray(
8725     const char* begin, size_t len, ::std::ostream* os);
8726 
8727 // This overload prints a (const) wchar_t array compactly.
8728 GTEST_API_ void UniversalPrintArray(
8729     const wchar_t* begin, size_t len, ::std::ostream* os);
8730 
8731 // Implements printing an array type T[N].
8732 template <typename T, size_t N>
8733 class UniversalPrinter<T[N]> {
8734  public:
8735   // Prints the given array, omitting some elements when there are too
8736   // many.
8737   static void Print(const T (&a)[N], ::std::ostream* os) {
8738     UniversalPrintArray(a, N, os);
8739   }
8740 };
8741 
8742 // Implements printing a reference type T&.
8743 template <typename T>
8744 class UniversalPrinter<T&> {
8745  public:
8746   // MSVC warns about adding const to a function type, so we want to
8747   // disable the warning.
8748   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
8749 
8750   static void Print(const T& value, ::std::ostream* os) {
8751     // Prints the address of the value.  We use reinterpret_cast here
8752     // as static_cast doesn't compile when T is a function type.
8753     *os << "@" << reinterpret_cast<const void*>(&value) << " ";
8754 
8755     // Then prints the value itself.
8756     UniversalPrint(value, os);
8757   }
8758 
8759   GTEST_DISABLE_MSC_WARNINGS_POP_()
8760 };
8761 
8762 // Prints a value tersely: for a reference type, the referenced value
8763 // (but not the address) is printed; for a (const) char pointer, the
8764 // NUL-terminated string (but not the pointer) is printed.
8765 
8766 template <typename T>
8767 class UniversalTersePrinter {
8768  public:
8769   static void Print(const T& value, ::std::ostream* os) {
8770     UniversalPrint(value, os);
8771   }
8772 };
8773 template <typename T>
8774 class UniversalTersePrinter<T&> {
8775  public:
8776   static void Print(const T& value, ::std::ostream* os) {
8777     UniversalPrint(value, os);
8778   }
8779 };
8780 template <typename T, size_t N>
8781 class UniversalTersePrinter<T[N]> {
8782  public:
8783   static void Print(const T (&value)[N], ::std::ostream* os) {
8784     UniversalPrinter<T[N]>::Print(value, os);
8785   }
8786 };
8787 template <>
8788 class UniversalTersePrinter<const char*> {
8789  public:
8790   static void Print(const char* str, ::std::ostream* os) {
8791     if (str == nullptr) {
8792       *os << "NULL";
8793     } else {
8794       UniversalPrint(std::string(str), os);
8795     }
8796   }
8797 };
8798 template <>
8799 class UniversalTersePrinter<char*> {
8800  public:
8801   static void Print(char* str, ::std::ostream* os) {
8802     UniversalTersePrinter<const char*>::Print(str, os);
8803   }
8804 };
8805 
8806 #if GTEST_HAS_STD_WSTRING
8807 template <>
8808 class UniversalTersePrinter<const wchar_t*> {
8809  public:
8810   static void Print(const wchar_t* str, ::std::ostream* os) {
8811     if (str == nullptr) {
8812       *os << "NULL";
8813     } else {
8814       UniversalPrint(::std::wstring(str), os);
8815     }
8816   }
8817 };
8818 #endif
8819 
8820 template <>
8821 class UniversalTersePrinter<wchar_t*> {
8822  public:
8823   static void Print(wchar_t* str, ::std::ostream* os) {
8824     UniversalTersePrinter<const wchar_t*>::Print(str, os);
8825   }
8826 };
8827 
8828 template <typename T>
8829 void UniversalTersePrint(const T& value, ::std::ostream* os) {
8830   UniversalTersePrinter<T>::Print(value, os);
8831 }
8832 
8833 // Prints a value using the type inferred by the compiler.  The
8834 // difference between this and UniversalTersePrint() is that for a
8835 // (const) char pointer, this prints both the pointer and the
8836 // NUL-terminated string.
8837 template <typename T>
8838 void UniversalPrint(const T& value, ::std::ostream* os) {
8839   // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
8840   // UniversalPrinter with T directly.
8841   typedef T T1;
8842   UniversalPrinter<T1>::Print(value, os);
8843 }
8844 
8845 typedef ::std::vector< ::std::string> Strings;
8846 
8847   // Tersely prints the first N fields of a tuple to a string vector,
8848   // one element for each field.
8849 template <typename Tuple>
8850 void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
8851                                Strings*) {}
8852 template <typename Tuple, size_t I>
8853 void TersePrintPrefixToStrings(const Tuple& t,
8854                                std::integral_constant<size_t, I>,
8855                                Strings* strings) {
8856   TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
8857                             strings);
8858   ::std::stringstream ss;
8859   UniversalTersePrint(std::get<I - 1>(t), &ss);
8860   strings->push_back(ss.str());
8861 }
8862 
8863 // Prints the fields of a tuple tersely to a string vector, one
8864 // element for each field.  See the comment before
8865 // UniversalTersePrint() for how we define "tersely".
8866 template <typename Tuple>
8867 Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
8868   Strings result;
8869   TersePrintPrefixToStrings(
8870       value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
8871       &result);
8872   return result;
8873 }
8874 
8875 }  // namespace internal
8876 
8877 #if GTEST_HAS_ABSL
8878 namespace internal2 {
8879 template <typename T>
8880 void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(
8881     const T& value, ::std::ostream* os) {
8882   internal::PrintTo(absl::string_view(value), os);
8883 }
8884 }  // namespace internal2
8885 #endif
8886 
8887 template <typename T>
8888 ::std::string PrintToString(const T& value) {
8889   ::std::stringstream ss;
8890   internal::UniversalTersePrinter<T>::Print(value, &ss);
8891   return ss.str();
8892 }
8893 
8894 }  // namespace testing
8895 
8896 // Include any custom printer added by the local installation.
8897 // We must include this header at the end to make sure it can use the
8898 // declarations from this file.
8899 // Copyright 2015, Google Inc.
8900 // All rights reserved.
8901 //
8902 // Redistribution and use in source and binary forms, with or without
8903 // modification, are permitted provided that the following conditions are
8904 // met:
8905 //
8906 //     * Redistributions of source code must retain the above copyright
8907 // notice, this list of conditions and the following disclaimer.
8908 //     * Redistributions in binary form must reproduce the above
8909 // copyright notice, this list of conditions and the following disclaimer
8910 // in the documentation and/or other materials provided with the
8911 // distribution.
8912 //     * Neither the name of Google Inc. nor the names of its
8913 // contributors may be used to endorse or promote products derived from
8914 // this software without specific prior written permission.
8915 //
8916 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
8917 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8918 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8919 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8920 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8921 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8922 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
8923 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
8924 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8925 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
8926 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8927 //
8928 // This file provides an injection point for custom printers in a local
8929 // installation of gTest.
8930 // It will be included from gtest-printers.h and the overrides in this file
8931 // will be visible to everyone.
8932 //
8933 // Injection point for custom user configurations. See README for details
8934 //
8935 // ** Custom implementation starts here **
8936 
8937 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8938 #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8939 
8940 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
8941 
8942 #endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8943 
8944 // MSVC warning C5046 is new as of VS2017 version 15.8.
8945 #if defined(_MSC_VER) && _MSC_VER >= 1915
8946 #define GTEST_MAYBE_5046_ 5046
8947 #else
8948 #define GTEST_MAYBE_5046_
8949 #endif
8950 
8951 GTEST_DISABLE_MSC_WARNINGS_PUSH_(
8952     4251 GTEST_MAYBE_5046_ /* class A needs to have dll-interface to be used by
8953                               clients of class B */
8954     /* Symbol involving type with internal linkage not defined */)
8955 
8956 namespace testing {
8957 
8958 // To implement a matcher Foo for type T, define:
8959 //   1. a class FooMatcherImpl that implements the
8960 //      MatcherInterface<T> interface, and
8961 //   2. a factory function that creates a Matcher<T> object from a
8962 //      FooMatcherImpl*.
8963 //
8964 // The two-level delegation design makes it possible to allow a user
8965 // to write "v" instead of "Eq(v)" where a Matcher is expected, which
8966 // is impossible if we pass matchers by pointers.  It also eases
8967 // ownership management as Matcher objects can now be copied like
8968 // plain values.
8969 
8970 // MatchResultListener is an abstract class.  Its << operator can be
8971 // used by a matcher to explain why a value matches or doesn't match.
8972 //
8973 class MatchResultListener {
8974  public:
8975   // Creates a listener object with the given underlying ostream.  The
8976   // listener does not own the ostream, and does not dereference it
8977   // in the constructor or destructor.
8978   explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
8979   virtual ~MatchResultListener() = 0;  // Makes this class abstract.
8980 
8981   // Streams x to the underlying ostream; does nothing if the ostream
8982   // is NULL.
8983   template <typename T>
8984   MatchResultListener& operator<<(const T& x) {
8985     if (stream_ != nullptr) *stream_ << x;
8986     return *this;
8987   }
8988 
8989   // Returns the underlying ostream.
8990   ::std::ostream* stream() { return stream_; }
8991 
8992   // Returns true iff the listener is interested in an explanation of
8993   // the match result.  A matcher's MatchAndExplain() method can use
8994   // this information to avoid generating the explanation when no one
8995   // intends to hear it.
8996   bool IsInterested() const { return stream_ != nullptr; }
8997 
8998  private:
8999   ::std::ostream* const stream_;
9000 
9001   GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
9002 };
9003 
9004 inline MatchResultListener::~MatchResultListener() {
9005 }
9006 
9007 // An instance of a subclass of this knows how to describe itself as a
9008 // matcher.
9009 class MatcherDescriberInterface {
9010  public:
9011   virtual ~MatcherDescriberInterface() {}
9012 
9013   // Describes this matcher to an ostream.  The function should print
9014   // a verb phrase that describes the property a value matching this
9015   // matcher should have.  The subject of the verb phrase is the value
9016   // being matched.  For example, the DescribeTo() method of the Gt(7)
9017   // matcher prints "is greater than 7".
9018   virtual void DescribeTo(::std::ostream* os) const = 0;
9019 
9020   // Describes the negation of this matcher to an ostream.  For
9021   // example, if the description of this matcher is "is greater than
9022   // 7", the negated description could be "is not greater than 7".
9023   // You are not required to override this when implementing
9024   // MatcherInterface, but it is highly advised so that your matcher
9025   // can produce good error messages.
9026   virtual void DescribeNegationTo(::std::ostream* os) const {
9027     *os << "not (";
9028     DescribeTo(os);
9029     *os << ")";
9030   }
9031 };
9032 
9033 // The implementation of a matcher.
9034 template <typename T>
9035 class MatcherInterface : public MatcherDescriberInterface {
9036  public:
9037   // Returns true iff the matcher matches x; also explains the match
9038   // result to 'listener' if necessary (see the next paragraph), in
9039   // the form of a non-restrictive relative clause ("which ...",
9040   // "whose ...", etc) that describes x.  For example, the
9041   // MatchAndExplain() method of the Pointee(...) matcher should
9042   // generate an explanation like "which points to ...".
9043   //
9044   // Implementations of MatchAndExplain() should add an explanation of
9045   // the match result *if and only if* they can provide additional
9046   // information that's not already present (or not obvious) in the
9047   // print-out of x and the matcher's description.  Whether the match
9048   // succeeds is not a factor in deciding whether an explanation is
9049   // needed, as sometimes the caller needs to print a failure message
9050   // when the match succeeds (e.g. when the matcher is used inside
9051   // Not()).
9052   //
9053   // For example, a "has at least 10 elements" matcher should explain
9054   // what the actual element count is, regardless of the match result,
9055   // as it is useful information to the reader; on the other hand, an
9056   // "is empty" matcher probably only needs to explain what the actual
9057   // size is when the match fails, as it's redundant to say that the
9058   // size is 0 when the value is already known to be empty.
9059   //
9060   // You should override this method when defining a new matcher.
9061   //
9062   // It's the responsibility of the caller (Google Test) to guarantee
9063   // that 'listener' is not NULL.  This helps to simplify a matcher's
9064   // implementation when it doesn't care about the performance, as it
9065   // can talk to 'listener' without checking its validity first.
9066   // However, in order to implement dummy listeners efficiently,
9067   // listener->stream() may be NULL.
9068   virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
9069 
9070   // Inherits these methods from MatcherDescriberInterface:
9071   //   virtual void DescribeTo(::std::ostream* os) const = 0;
9072   //   virtual void DescribeNegationTo(::std::ostream* os) const;
9073 };
9074 
9075 namespace internal {
9076 
9077 // Converts a MatcherInterface<T> to a MatcherInterface<const T&>.
9078 template <typename T>
9079 class MatcherInterfaceAdapter : public MatcherInterface<const T&> {
9080  public:
9081   explicit MatcherInterfaceAdapter(const MatcherInterface<T>* impl)
9082       : impl_(impl) {}
9083   ~MatcherInterfaceAdapter() override { delete impl_; }
9084 
9085   void DescribeTo(::std::ostream* os) const override { impl_->DescribeTo(os); }
9086 
9087   void DescribeNegationTo(::std::ostream* os) const override {
9088     impl_->DescribeNegationTo(os);
9089   }
9090 
9091   bool MatchAndExplain(const T& x,
9092                        MatchResultListener* listener) const override {
9093     return impl_->MatchAndExplain(x, listener);
9094   }
9095 
9096  private:
9097   const MatcherInterface<T>* const impl_;
9098 
9099   GTEST_DISALLOW_COPY_AND_ASSIGN_(MatcherInterfaceAdapter);
9100 };
9101 
9102 struct AnyEq {
9103   template <typename A, typename B>
9104   bool operator()(const A& a, const B& b) const { return a == b; }
9105 };
9106 struct AnyNe {
9107   template <typename A, typename B>
9108   bool operator()(const A& a, const B& b) const { return a != b; }
9109 };
9110 struct AnyLt {
9111   template <typename A, typename B>
9112   bool operator()(const A& a, const B& b) const { return a < b; }
9113 };
9114 struct AnyGt {
9115   template <typename A, typename B>
9116   bool operator()(const A& a, const B& b) const { return a > b; }
9117 };
9118 struct AnyLe {
9119   template <typename A, typename B>
9120   bool operator()(const A& a, const B& b) const { return a <= b; }
9121 };
9122 struct AnyGe {
9123   template <typename A, typename B>
9124   bool operator()(const A& a, const B& b) const { return a >= b; }
9125 };
9126 
9127 // A match result listener that ignores the explanation.
9128 class DummyMatchResultListener : public MatchResultListener {
9129  public:
9130   DummyMatchResultListener() : MatchResultListener(nullptr) {}
9131 
9132  private:
9133   GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
9134 };
9135 
9136 // A match result listener that forwards the explanation to a given
9137 // ostream.  The difference between this and MatchResultListener is
9138 // that the former is concrete.
9139 class StreamMatchResultListener : public MatchResultListener {
9140  public:
9141   explicit StreamMatchResultListener(::std::ostream* os)
9142       : MatchResultListener(os) {}
9143 
9144  private:
9145   GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
9146 };
9147 
9148 // An internal class for implementing Matcher<T>, which will derive
9149 // from it.  We put functionalities common to all Matcher<T>
9150 // specializations here to avoid code duplication.
9151 template <typename T>
9152 class MatcherBase {
9153  public:
9154   // Returns true iff the matcher matches x; also explains the match
9155   // result to 'listener'.
9156   bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
9157     return impl_->MatchAndExplain(x, listener);
9158   }
9159 
9160   // Returns true iff this matcher matches x.
9161   bool Matches(const T& x) const {
9162     DummyMatchResultListener dummy;
9163     return MatchAndExplain(x, &dummy);
9164   }
9165 
9166   // Describes this matcher to an ostream.
9167   void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
9168 
9169   // Describes the negation of this matcher to an ostream.
9170   void DescribeNegationTo(::std::ostream* os) const {
9171     impl_->DescribeNegationTo(os);
9172   }
9173 
9174   // Explains why x matches, or doesn't match, the matcher.
9175   void ExplainMatchResultTo(const T& x, ::std::ostream* os) const {
9176     StreamMatchResultListener listener(os);
9177     MatchAndExplain(x, &listener);
9178   }
9179 
9180   // Returns the describer for this matcher object; retains ownership
9181   // of the describer, which is only guaranteed to be alive when
9182   // this matcher object is alive.
9183   const MatcherDescriberInterface* GetDescriber() const {
9184     return impl_.get();
9185   }
9186 
9187  protected:
9188   MatcherBase() {}
9189 
9190   // Constructs a matcher from its implementation.
9191   explicit MatcherBase(const MatcherInterface<const T&>* impl) : impl_(impl) {}
9192 
9193   template <typename U>
9194   explicit MatcherBase(
9195       const MatcherInterface<U>* impl,
9196       typename internal::EnableIf<
9197           !internal::IsSame<U, const U&>::value>::type* = nullptr)
9198       : impl_(new internal::MatcherInterfaceAdapter<U>(impl)) {}
9199 
9200   MatcherBase(const MatcherBase&) = default;
9201   MatcherBase& operator=(const MatcherBase&) = default;
9202   MatcherBase(MatcherBase&&) = default;
9203   MatcherBase& operator=(MatcherBase&&) = default;
9204 
9205   virtual ~MatcherBase() {}
9206 
9207  private:
9208   std::shared_ptr<const MatcherInterface<const T&>> impl_;
9209 };
9210 
9211 }  // namespace internal
9212 
9213 // A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
9214 // object that can check whether a value of type T matches.  The
9215 // implementation of Matcher<T> is just a std::shared_ptr to const
9216 // MatcherInterface<T>.  Don't inherit from Matcher!
9217 template <typename T>
9218 class Matcher : public internal::MatcherBase<T> {
9219  public:
9220   // Constructs a null matcher.  Needed for storing Matcher objects in STL
9221   // containers.  A default-constructed matcher is not yet initialized.  You
9222   // cannot use it until a valid value has been assigned to it.
9223   explicit Matcher() {}  // NOLINT
9224 
9225   // Constructs a matcher from its implementation.
9226   explicit Matcher(const MatcherInterface<const T&>* impl)
9227       : internal::MatcherBase<T>(impl) {}
9228 
9229   template <typename U>
9230   explicit Matcher(const MatcherInterface<U>* impl,
9231                    typename internal::EnableIf<
9232                        !internal::IsSame<U, const U&>::value>::type* = nullptr)
9233       : internal::MatcherBase<T>(impl) {}
9234 
9235   // Implicit constructor here allows people to write
9236   // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
9237   Matcher(T value);  // NOLINT
9238 };
9239 
9240 // The following two specializations allow the user to write str
9241 // instead of Eq(str) and "foo" instead of Eq("foo") when a std::string
9242 // matcher is expected.
9243 template <>
9244 class GTEST_API_ Matcher<const std::string&>
9245     : public internal::MatcherBase<const std::string&> {
9246  public:
9247   Matcher() {}
9248 
9249   explicit Matcher(const MatcherInterface<const std::string&>* impl)
9250       : internal::MatcherBase<const std::string&>(impl) {}
9251 
9252   // Allows the user to write str instead of Eq(str) sometimes, where
9253   // str is a std::string object.
9254   Matcher(const std::string& s);  // NOLINT
9255 
9256   // Allows the user to write "foo" instead of Eq("foo") sometimes.
9257   Matcher(const char* s);  // NOLINT
9258 };
9259 
9260 template <>
9261 class GTEST_API_ Matcher<std::string>
9262     : public internal::MatcherBase<std::string> {
9263  public:
9264   Matcher() {}
9265 
9266   explicit Matcher(const MatcherInterface<const std::string&>* impl)
9267       : internal::MatcherBase<std::string>(impl) {}
9268   explicit Matcher(const MatcherInterface<std::string>* impl)
9269       : internal::MatcherBase<std::string>(impl) {}
9270 
9271   // Allows the user to write str instead of Eq(str) sometimes, where
9272   // str is a string object.
9273   Matcher(const std::string& s);  // NOLINT
9274 
9275   // Allows the user to write "foo" instead of Eq("foo") sometimes.
9276   Matcher(const char* s);  // NOLINT
9277 };
9278 
9279 #if GTEST_HAS_ABSL
9280 // The following two specializations allow the user to write str
9281 // instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
9282 // matcher is expected.
9283 template <>
9284 class GTEST_API_ Matcher<const absl::string_view&>
9285     : public internal::MatcherBase<const absl::string_view&> {
9286  public:
9287   Matcher() {}
9288 
9289   explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
9290       : internal::MatcherBase<const absl::string_view&>(impl) {}
9291 
9292   // Allows the user to write str instead of Eq(str) sometimes, where
9293   // str is a std::string object.
9294   Matcher(const std::string& s);  // NOLINT
9295 
9296   // Allows the user to write "foo" instead of Eq("foo") sometimes.
9297   Matcher(const char* s);  // NOLINT
9298 
9299   // Allows the user to pass absl::string_views directly.
9300   Matcher(absl::string_view s);  // NOLINT
9301 };
9302 
9303 template <>
9304 class GTEST_API_ Matcher<absl::string_view>
9305     : public internal::MatcherBase<absl::string_view> {
9306  public:
9307   Matcher() {}
9308 
9309   explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
9310       : internal::MatcherBase<absl::string_view>(impl) {}
9311   explicit Matcher(const MatcherInterface<absl::string_view>* impl)
9312       : internal::MatcherBase<absl::string_view>(impl) {}
9313 
9314   // Allows the user to write str instead of Eq(str) sometimes, where
9315   // str is a std::string object.
9316   Matcher(const std::string& s);  // NOLINT
9317 
9318   // Allows the user to write "foo" instead of Eq("foo") sometimes.
9319   Matcher(const char* s);  // NOLINT
9320 
9321   // Allows the user to pass absl::string_views directly.
9322   Matcher(absl::string_view s);  // NOLINT
9323 };
9324 #endif  // GTEST_HAS_ABSL
9325 
9326 // Prints a matcher in a human-readable format.
9327 template <typename T>
9328 std::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) {
9329   matcher.DescribeTo(&os);
9330   return os;
9331 }
9332 
9333 // The PolymorphicMatcher class template makes it easy to implement a
9334 // polymorphic matcher (i.e. a matcher that can match values of more
9335 // than one type, e.g. Eq(n) and NotNull()).
9336 //
9337 // To define a polymorphic matcher, a user should provide an Impl
9338 // class that has a DescribeTo() method and a DescribeNegationTo()
9339 // method, and define a member function (or member function template)
9340 //
9341 //   bool MatchAndExplain(const Value& value,
9342 //                        MatchResultListener* listener) const;
9343 //
9344 // See the definition of NotNull() for a complete example.
9345 template <class Impl>
9346 class PolymorphicMatcher {
9347  public:
9348   explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
9349 
9350   // Returns a mutable reference to the underlying matcher
9351   // implementation object.
9352   Impl& mutable_impl() { return impl_; }
9353 
9354   // Returns an immutable reference to the underlying matcher
9355   // implementation object.
9356   const Impl& impl() const { return impl_; }
9357 
9358   template <typename T>
9359   operator Matcher<T>() const {
9360     return Matcher<T>(new MonomorphicImpl<const T&>(impl_));
9361   }
9362 
9363  private:
9364   template <typename T>
9365   class MonomorphicImpl : public MatcherInterface<T> {
9366    public:
9367     explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
9368 
9369     virtual void DescribeTo(::std::ostream* os) const { impl_.DescribeTo(os); }
9370 
9371     virtual void DescribeNegationTo(::std::ostream* os) const {
9372       impl_.DescribeNegationTo(os);
9373     }
9374 
9375     virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
9376       return impl_.MatchAndExplain(x, listener);
9377     }
9378 
9379    private:
9380     const Impl impl_;
9381   };
9382 
9383   Impl impl_;
9384 };
9385 
9386 // Creates a matcher from its implementation.
9387 // DEPRECATED: Especially in the generic code, prefer:
9388 //   Matcher<T>(new MyMatcherImpl<const T&>(...));
9389 //
9390 // MakeMatcher may create a Matcher that accepts its argument by value, which
9391 // leads to unnecessary copies & lack of support for non-copyable types.
9392 template <typename T>
9393 inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
9394   return Matcher<T>(impl);
9395 }
9396 
9397 // Creates a polymorphic matcher from its implementation.  This is
9398 // easier to use than the PolymorphicMatcher<Impl> constructor as it
9399 // doesn't require you to explicitly write the template argument, e.g.
9400 //
9401 //   MakePolymorphicMatcher(foo);
9402 // vs
9403 //   PolymorphicMatcher<TypeOfFoo>(foo);
9404 template <class Impl>
9405 inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
9406   return PolymorphicMatcher<Impl>(impl);
9407 }
9408 
9409 namespace internal {
9410 // Implements a matcher that compares a given value with a
9411 // pre-supplied value using one of the ==, <=, <, etc, operators.  The
9412 // two values being compared don't have to have the same type.
9413 //
9414 // The matcher defined here is polymorphic (for example, Eq(5) can be
9415 // used to match an int, a short, a double, etc).  Therefore we use
9416 // a template type conversion operator in the implementation.
9417 //
9418 // The following template definition assumes that the Rhs parameter is
9419 // a "bare" type (i.e. neither 'const T' nor 'T&').
9420 template <typename D, typename Rhs, typename Op>
9421 class ComparisonBase {
9422  public:
9423   explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {}
9424   template <typename Lhs>
9425   operator Matcher<Lhs>() const {
9426     return Matcher<Lhs>(new Impl<const Lhs&>(rhs_));
9427   }
9428 
9429  private:
9430   template <typename T>
9431   static const T& Unwrap(const T& v) { return v; }
9432   template <typename T>
9433   static const T& Unwrap(std::reference_wrapper<T> v) { return v; }
9434 
9435   template <typename Lhs, typename = Rhs>
9436   class Impl : public MatcherInterface<Lhs> {
9437    public:
9438     explicit Impl(const Rhs& rhs) : rhs_(rhs) {}
9439     bool MatchAndExplain(Lhs lhs,
9440                          MatchResultListener* /* listener */) const override {
9441       return Op()(lhs, Unwrap(rhs_));
9442     }
9443     void DescribeTo(::std::ostream* os) const override {
9444       *os << D::Desc() << " ";
9445       UniversalPrint(Unwrap(rhs_), os);
9446     }
9447     void DescribeNegationTo(::std::ostream* os) const override {
9448       *os << D::NegatedDesc() <<  " ";
9449       UniversalPrint(Unwrap(rhs_), os);
9450     }
9451 
9452    private:
9453     Rhs rhs_;
9454   };
9455   Rhs rhs_;
9456 };
9457 
9458 template <typename Rhs>
9459 class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
9460  public:
9461   explicit EqMatcher(const Rhs& rhs)
9462       : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }
9463   static const char* Desc() { return "is equal to"; }
9464   static const char* NegatedDesc() { return "isn't equal to"; }
9465 };
9466 template <typename Rhs>
9467 class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
9468  public:
9469   explicit NeMatcher(const Rhs& rhs)
9470       : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }
9471   static const char* Desc() { return "isn't equal to"; }
9472   static const char* NegatedDesc() { return "is equal to"; }
9473 };
9474 template <typename Rhs>
9475 class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
9476  public:
9477   explicit LtMatcher(const Rhs& rhs)
9478       : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }
9479   static const char* Desc() { return "is <"; }
9480   static const char* NegatedDesc() { return "isn't <"; }
9481 };
9482 template <typename Rhs>
9483 class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
9484  public:
9485   explicit GtMatcher(const Rhs& rhs)
9486       : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }
9487   static const char* Desc() { return "is >"; }
9488   static const char* NegatedDesc() { return "isn't >"; }
9489 };
9490 template <typename Rhs>
9491 class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
9492  public:
9493   explicit LeMatcher(const Rhs& rhs)
9494       : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }
9495   static const char* Desc() { return "is <="; }
9496   static const char* NegatedDesc() { return "isn't <="; }
9497 };
9498 template <typename Rhs>
9499 class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
9500  public:
9501   explicit GeMatcher(const Rhs& rhs)
9502       : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }
9503   static const char* Desc() { return "is >="; }
9504   static const char* NegatedDesc() { return "isn't >="; }
9505 };
9506 
9507 // Implements polymorphic matchers MatchesRegex(regex) and
9508 // ContainsRegex(regex), which can be used as a Matcher<T> as long as
9509 // T can be converted to a string.
9510 class MatchesRegexMatcher {
9511  public:
9512   MatchesRegexMatcher(const RE* regex, bool full_match)
9513       : regex_(regex), full_match_(full_match) {}
9514 
9515 #if GTEST_HAS_ABSL
9516   bool MatchAndExplain(const absl::string_view& s,
9517                        MatchResultListener* listener) const {
9518     return MatchAndExplain(std::string(s), listener);
9519   }
9520 #endif  // GTEST_HAS_ABSL
9521 
9522   // Accepts pointer types, particularly:
9523   //   const char*
9524   //   char*
9525   //   const wchar_t*
9526   //   wchar_t*
9527   template <typename CharType>
9528   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
9529     return s != nullptr && MatchAndExplain(std::string(s), listener);
9530   }
9531 
9532   // Matches anything that can convert to std::string.
9533   //
9534   // This is a template, not just a plain function with const std::string&,
9535   // because absl::string_view has some interfering non-explicit constructors.
9536   template <class MatcheeStringType>
9537   bool MatchAndExplain(const MatcheeStringType& s,
9538                        MatchResultListener* /* listener */) const {
9539     const std::string& s2(s);
9540     return full_match_ ? RE::FullMatch(s2, *regex_)
9541                        : RE::PartialMatch(s2, *regex_);
9542   }
9543 
9544   void DescribeTo(::std::ostream* os) const {
9545     *os << (full_match_ ? "matches" : "contains") << " regular expression ";
9546     UniversalPrinter<std::string>::Print(regex_->pattern(), os);
9547   }
9548 
9549   void DescribeNegationTo(::std::ostream* os) const {
9550     *os << "doesn't " << (full_match_ ? "match" : "contain")
9551         << " regular expression ";
9552     UniversalPrinter<std::string>::Print(regex_->pattern(), os);
9553   }
9554 
9555  private:
9556   const std::shared_ptr<const RE> regex_;
9557   const bool full_match_;
9558 };
9559 }  // namespace internal
9560 
9561 // Matches a string that fully matches regular expression 'regex'.
9562 // The matcher takes ownership of 'regex'.
9563 inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
9564     const internal::RE* regex) {
9565   return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
9566 }
9567 inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
9568     const std::string& regex) {
9569   return MatchesRegex(new internal::RE(regex));
9570 }
9571 
9572 // Matches a string that contains regular expression 'regex'.
9573 // The matcher takes ownership of 'regex'.
9574 inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
9575     const internal::RE* regex) {
9576   return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
9577 }
9578 inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
9579     const std::string& regex) {
9580   return ContainsRegex(new internal::RE(regex));
9581 }
9582 
9583 // Creates a polymorphic matcher that matches anything equal to x.
9584 // Note: if the parameter of Eq() were declared as const T&, Eq("foo")
9585 // wouldn't compile.
9586 template <typename T>
9587 inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
9588 
9589 // Constructs a Matcher<T> from a 'value' of type T.  The constructed
9590 // matcher matches any value that's equal to 'value'.
9591 template <typename T>
9592 Matcher<T>::Matcher(T value) { *this = Eq(value); }
9593 
9594 // Creates a monomorphic matcher that matches anything with type Lhs
9595 // and equal to rhs.  A user may need to use this instead of Eq(...)
9596 // in order to resolve an overloading ambiguity.
9597 //
9598 // TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
9599 // or Matcher<T>(x), but more readable than the latter.
9600 //
9601 // We could define similar monomorphic matchers for other comparison
9602 // operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
9603 // it yet as those are used much less than Eq() in practice.  A user
9604 // can always write Matcher<T>(Lt(5)) to be explicit about the type,
9605 // for example.
9606 template <typename Lhs, typename Rhs>
9607 inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
9608 
9609 // Creates a polymorphic matcher that matches anything >= x.
9610 template <typename Rhs>
9611 inline internal::GeMatcher<Rhs> Ge(Rhs x) {
9612   return internal::GeMatcher<Rhs>(x);
9613 }
9614 
9615 // Creates a polymorphic matcher that matches anything > x.
9616 template <typename Rhs>
9617 inline internal::GtMatcher<Rhs> Gt(Rhs x) {
9618   return internal::GtMatcher<Rhs>(x);
9619 }
9620 
9621 // Creates a polymorphic matcher that matches anything <= x.
9622 template <typename Rhs>
9623 inline internal::LeMatcher<Rhs> Le(Rhs x) {
9624   return internal::LeMatcher<Rhs>(x);
9625 }
9626 
9627 // Creates a polymorphic matcher that matches anything < x.
9628 template <typename Rhs>
9629 inline internal::LtMatcher<Rhs> Lt(Rhs x) {
9630   return internal::LtMatcher<Rhs>(x);
9631 }
9632 
9633 // Creates a polymorphic matcher that matches anything != x.
9634 template <typename Rhs>
9635 inline internal::NeMatcher<Rhs> Ne(Rhs x) {
9636   return internal::NeMatcher<Rhs>(x);
9637 }
9638 }  // namespace testing
9639 
9640 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251 5046
9641 
9642 #endif  // GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
9643 
9644 #include <stdio.h>
9645 #include <memory>
9646 
9647 namespace testing {
9648 namespace internal {
9649 
9650 GTEST_DECLARE_string_(internal_run_death_test);
9651 
9652 // Names of the flags (needed for parsing Google Test flags).
9653 const char kDeathTestStyleFlag[] = "death_test_style";
9654 const char kDeathTestUseFork[] = "death_test_use_fork";
9655 const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
9656 
9657 #if GTEST_HAS_DEATH_TEST
9658 
9659 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
9660 /* class A needs to have dll-interface to be used by clients of class B */)
9661 
9662 // DeathTest is a class that hides much of the complexity of the
9663 // GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method
9664 // returns a concrete class that depends on the prevailing death test
9665 // style, as defined by the --gtest_death_test_style and/or
9666 // --gtest_internal_run_death_test flags.
9667 
9668 // In describing the results of death tests, these terms are used with
9669 // the corresponding definitions:
9670 //
9671 // exit status:  The integer exit information in the format specified
9672 //               by wait(2)
9673 // exit code:    The integer code passed to exit(3), _exit(2), or
9674 //               returned from main()
9675 class GTEST_API_ DeathTest {
9676  public:
9677   // Create returns false if there was an error determining the
9678   // appropriate action to take for the current death test; for example,
9679   // if the gtest_death_test_style flag is set to an invalid value.
9680   // The LastMessage method will return a more detailed message in that
9681   // case.  Otherwise, the DeathTest pointer pointed to by the "test"
9682   // argument is set.  If the death test should be skipped, the pointer
9683   // is set to NULL; otherwise, it is set to the address of a new concrete
9684   // DeathTest object that controls the execution of the current test.
9685   static bool Create(const char* statement, Matcher<const std::string&> matcher,
9686                      const char* file, int line, DeathTest** test);
9687   DeathTest();
9688   virtual ~DeathTest() { }
9689 
9690   // A helper class that aborts a death test when it's deleted.
9691   class ReturnSentinel {
9692    public:
9693     explicit ReturnSentinel(DeathTest* test) : test_(test) { }
9694     ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
9695    private:
9696     DeathTest* const test_;
9697     GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
9698   } GTEST_ATTRIBUTE_UNUSED_;
9699 
9700   // An enumeration of possible roles that may be taken when a death
9701   // test is encountered.  EXECUTE means that the death test logic should
9702   // be executed immediately.  OVERSEE means that the program should prepare
9703   // the appropriate environment for a child process to execute the death
9704   // test, then wait for it to complete.
9705   enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
9706 
9707   // An enumeration of the three reasons that a test might be aborted.
9708   enum AbortReason {
9709     TEST_ENCOUNTERED_RETURN_STATEMENT,
9710     TEST_THREW_EXCEPTION,
9711     TEST_DID_NOT_DIE
9712   };
9713 
9714   // Assumes one of the above roles.
9715   virtual TestRole AssumeRole() = 0;
9716 
9717   // Waits for the death test to finish and returns its status.
9718   virtual int Wait() = 0;
9719 
9720   // Returns true if the death test passed; that is, the test process
9721   // exited during the test, its exit status matches a user-supplied
9722   // predicate, and its stderr output matches a user-supplied regular
9723   // expression.
9724   // The user-supplied predicate may be a macro expression rather
9725   // than a function pointer or functor, or else Wait and Passed could
9726   // be combined.
9727   virtual bool Passed(bool exit_status_ok) = 0;
9728 
9729   // Signals that the death test did not die as expected.
9730   virtual void Abort(AbortReason reason) = 0;
9731 
9732   // Returns a human-readable outcome message regarding the outcome of
9733   // the last death test.
9734   static const char* LastMessage();
9735 
9736   static void set_last_death_test_message(const std::string& message);
9737 
9738  private:
9739   // A string containing a description of the outcome of the last death test.
9740   static std::string last_death_test_message_;
9741 
9742   GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
9743 };
9744 
9745 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
9746 
9747 // Factory interface for death tests.  May be mocked out for testing.
9748 class DeathTestFactory {
9749  public:
9750   virtual ~DeathTestFactory() { }
9751   virtual bool Create(const char* statement,
9752                       Matcher<const std::string&> matcher, const char* file,
9753                       int line, DeathTest** test) = 0;
9754 };
9755 
9756 // A concrete DeathTestFactory implementation for normal use.
9757 class DefaultDeathTestFactory : public DeathTestFactory {
9758  public:
9759   bool Create(const char* statement, Matcher<const std::string&> matcher,
9760               const char* file, int line, DeathTest** test) override;
9761 };
9762 
9763 // Returns true if exit_status describes a process that was terminated
9764 // by a signal, or exited normally with a nonzero exit code.
9765 GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
9766 
9767 // A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
9768 // and interpreted as a regex (rather than an Eq matcher) for legacy
9769 // compatibility.
9770 inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9771     ::testing::internal::RE regex) {
9772   return ContainsRegex(regex.pattern());
9773 }
9774 inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
9775   return ContainsRegex(regex);
9776 }
9777 inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9778     const ::std::string& regex) {
9779   return ContainsRegex(regex);
9780 }
9781 
9782 // If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
9783 // used directly.
9784 inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9785     Matcher<const ::std::string&> matcher) {
9786   return matcher;
9787 }
9788 
9789 // Traps C++ exceptions escaping statement and reports them as test
9790 // failures. Note that trapping SEH exceptions is not implemented here.
9791 # if GTEST_HAS_EXCEPTIONS
9792 #  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
9793   try { \
9794     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
9795   } catch (const ::std::exception& gtest_exception) { \
9796     fprintf(\
9797         stderr, \
9798         "\n%s: Caught std::exception-derived exception escaping the " \
9799         "death test statement. Exception message: %s\n", \
9800         ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
9801         gtest_exception.what()); \
9802     fflush(stderr); \
9803     death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
9804   } catch (...) { \
9805     death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
9806   }
9807 
9808 # else
9809 #  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
9810   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
9811 
9812 # endif
9813 
9814 // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
9815 // ASSERT_EXIT*, and EXPECT_EXIT*.
9816 #define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail)        \
9817   GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \
9818   if (::testing::internal::AlwaysTrue()) {                                     \
9819     ::testing::internal::DeathTest* gtest_dt;                                  \
9820     if (!::testing::internal::DeathTest::Create(                               \
9821             #statement,                                                        \
9822             ::testing::internal::MakeDeathTestMatcher(regex_or_matcher),       \
9823             __FILE__, __LINE__, &gtest_dt)) {                                  \
9824       goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                        \
9825     }                                                                          \
9826     if (gtest_dt != nullptr) {                                                 \
9827       std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
9828       switch (gtest_dt->AssumeRole()) {                                        \
9829         case ::testing::internal::DeathTest::OVERSEE_TEST:                     \
9830           if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) {                \
9831             goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                  \
9832           }                                                                    \
9833           break;                                                               \
9834         case ::testing::internal::DeathTest::EXECUTE_TEST: {                   \
9835           ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel(       \
9836               gtest_dt);                                                       \
9837           GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt);            \
9838           gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE);   \
9839           break;                                                               \
9840         }                                                                      \
9841         default:                                                               \
9842           break;                                                               \
9843       }                                                                        \
9844     }                                                                          \
9845   } else                                                                       \
9846     GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__)                                \
9847         : fail(::testing::internal::DeathTest::LastMessage())
9848 // The symbol "fail" here expands to something into which a message
9849 // can be streamed.
9850 
9851 // This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
9852 // NDEBUG mode. In this case we need the statements to be executed and the macro
9853 // must accept a streamed message even though the message is never printed.
9854 // The regex object is not evaluated, but it is used to prevent "unused"
9855 // warnings and to avoid an expression that doesn't compile in debug mode.
9856 #define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher)    \
9857   GTEST_AMBIGUOUS_ELSE_BLOCKER_                                  \
9858   if (::testing::internal::AlwaysTrue()) {                       \
9859     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);   \
9860   } else if (!::testing::internal::AlwaysTrue()) {               \
9861     ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
9862   } else                                                         \
9863     ::testing::Message()
9864 
9865 // A class representing the parsed contents of the
9866 // --gtest_internal_run_death_test flag, as it existed when
9867 // RUN_ALL_TESTS was called.
9868 class InternalRunDeathTestFlag {
9869  public:
9870   InternalRunDeathTestFlag(const std::string& a_file,
9871                            int a_line,
9872                            int an_index,
9873                            int a_write_fd)
9874       : file_(a_file), line_(a_line), index_(an_index),
9875         write_fd_(a_write_fd) {}
9876 
9877   ~InternalRunDeathTestFlag() {
9878     if (write_fd_ >= 0)
9879       posix::Close(write_fd_);
9880   }
9881 
9882   const std::string& file() const { return file_; }
9883   int line() const { return line_; }
9884   int index() const { return index_; }
9885   int write_fd() const { return write_fd_; }
9886 
9887  private:
9888   std::string file_;
9889   int line_;
9890   int index_;
9891   int write_fd_;
9892 
9893   GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
9894 };
9895 
9896 // Returns a newly created InternalRunDeathTestFlag object with fields
9897 // initialized from the GTEST_FLAG(internal_run_death_test) flag if
9898 // the flag is specified; otherwise returns NULL.
9899 InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
9900 
9901 #endif  // GTEST_HAS_DEATH_TEST
9902 
9903 }  // namespace internal
9904 }  // namespace testing
9905 
9906 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
9907 
9908 namespace testing {
9909 
9910 // This flag controls the style of death tests.  Valid values are "threadsafe",
9911 // meaning that the death test child process will re-execute the test binary
9912 // from the start, running only a single death test, or "fast",
9913 // meaning that the child process will execute the test logic immediately
9914 // after forking.
9915 GTEST_DECLARE_string_(death_test_style);
9916 
9917 #if GTEST_HAS_DEATH_TEST
9918 
9919 namespace internal {
9920 
9921 // Returns a Boolean value indicating whether the caller is currently
9922 // executing in the context of the death test child process.  Tools such as
9923 // Valgrind heap checkers may need this to modify their behavior in death
9924 // tests.  IMPORTANT: This is an internal utility.  Using it may break the
9925 // implementation of death tests.  User code MUST NOT use it.
9926 GTEST_API_ bool InDeathTestChild();
9927 
9928 }  // namespace internal
9929 
9930 // The following macros are useful for writing death tests.
9931 
9932 // Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
9933 // executed:
9934 //
9935 //   1. It generates a warning if there is more than one active
9936 //   thread.  This is because it's safe to fork() or clone() only
9937 //   when there is a single thread.
9938 //
9939 //   2. The parent process clone()s a sub-process and runs the death
9940 //   test in it; the sub-process exits with code 0 at the end of the
9941 //   death test, if it hasn't exited already.
9942 //
9943 //   3. The parent process waits for the sub-process to terminate.
9944 //
9945 //   4. The parent process checks the exit code and error message of
9946 //   the sub-process.
9947 //
9948 // Examples:
9949 //
9950 //   ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
9951 //   for (int i = 0; i < 5; i++) {
9952 //     EXPECT_DEATH(server.ProcessRequest(i),
9953 //                  "Invalid request .* in ProcessRequest()")
9954 //                  << "Failed to die on request " << i;
9955 //   }
9956 //
9957 //   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
9958 //
9959 //   bool KilledBySIGHUP(int exit_code) {
9960 //     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
9961 //   }
9962 //
9963 //   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
9964 //
9965 // On the regular expressions used in death tests:
9966 //
9967 //   GOOGLETEST_CM0005 DO NOT DELETE
9968 //   On POSIX-compliant systems (*nix), we use the <regex.h> library,
9969 //   which uses the POSIX extended regex syntax.
9970 //
9971 //   On other platforms (e.g. Windows or Mac), we only support a simple regex
9972 //   syntax implemented as part of Google Test.  This limited
9973 //   implementation should be enough most of the time when writing
9974 //   death tests; though it lacks many features you can find in PCRE
9975 //   or POSIX extended regex syntax.  For example, we don't support
9976 //   union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
9977 //   repetition count ("x{5,7}"), among others.
9978 //
9979 //   Below is the syntax that we do support.  We chose it to be a
9980 //   subset of both PCRE and POSIX extended regex, so it's easy to
9981 //   learn wherever you come from.  In the following: 'A' denotes a
9982 //   literal character, period (.), or a single \\ escape sequence;
9983 //   'x' and 'y' denote regular expressions; 'm' and 'n' are for
9984 //   natural numbers.
9985 //
9986 //     c     matches any literal character c
9987 //     \\d   matches any decimal digit
9988 //     \\D   matches any character that's not a decimal digit
9989 //     \\f   matches \f
9990 //     \\n   matches \n
9991 //     \\r   matches \r
9992 //     \\s   matches any ASCII whitespace, including \n
9993 //     \\S   matches any character that's not a whitespace
9994 //     \\t   matches \t
9995 //     \\v   matches \v
9996 //     \\w   matches any letter, _, or decimal digit
9997 //     \\W   matches any character that \\w doesn't match
9998 //     \\c   matches any literal character c, which must be a punctuation
9999 //     .     matches any single character except \n
10000 //     A?    matches 0 or 1 occurrences of A
10001 //     A*    matches 0 or many occurrences of A
10002 //     A+    matches 1 or many occurrences of A
10003 //     ^     matches the beginning of a string (not that of each line)
10004 //     $     matches the end of a string (not that of each line)
10005 //     xy    matches x followed by y
10006 //
10007 //   If you accidentally use PCRE or POSIX extended regex features
10008 //   not implemented by us, you will get a run-time failure.  In that
10009 //   case, please try to rewrite your regular expression within the
10010 //   above syntax.
10011 //
10012 //   This implementation is *not* meant to be as highly tuned or robust
10013 //   as a compiled regex library, but should perform well enough for a
10014 //   death test, which already incurs significant overhead by launching
10015 //   a child process.
10016 //
10017 // Known caveats:
10018 //
10019 //   A "threadsafe" style death test obtains the path to the test
10020 //   program from argv[0] and re-executes it in the sub-process.  For
10021 //   simplicity, the current implementation doesn't search the PATH
10022 //   when launching the sub-process.  This means that the user must
10023 //   invoke the test program via a path that contains at least one
10024 //   path separator (e.g. path/to/foo_test and
10025 //   /absolute/path/to/bar_test are fine, but foo_test is not).  This
10026 //   is rarely a problem as people usually don't put the test binary
10027 //   directory in PATH.
10028 //
10029 
10030 // Asserts that a given statement causes the program to exit, with an
10031 // integer exit status that satisfies predicate, and emitting error output
10032 // that matches regex.
10033 # define ASSERT_EXIT(statement, predicate, regex) \
10034     GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
10035 
10036 // Like ASSERT_EXIT, but continues on to successive tests in the
10037 // test suite, if any:
10038 # define EXPECT_EXIT(statement, predicate, regex) \
10039     GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
10040 
10041 // Asserts that a given statement causes the program to exit, either by
10042 // explicitly exiting with a nonzero exit code or being killed by a
10043 // signal, and emitting error output that matches regex.
10044 # define ASSERT_DEATH(statement, regex) \
10045     ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
10046 
10047 // Like ASSERT_DEATH, but continues on to successive tests in the
10048 // test suite, if any:
10049 # define EXPECT_DEATH(statement, regex) \
10050     EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
10051 
10052 // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
10053 
10054 // Tests that an exit code describes a normal exit with a given exit code.
10055 class GTEST_API_ ExitedWithCode {
10056  public:
10057   explicit ExitedWithCode(int exit_code);
10058   bool operator()(int exit_status) const;
10059  private:
10060   // No implementation - assignment is unsupported.
10061   void operator=(const ExitedWithCode& other);
10062 
10063   const int exit_code_;
10064 };
10065 
10066 # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
10067 // Tests that an exit code describes an exit due to termination by a
10068 // given signal.
10069 // GOOGLETEST_CM0006 DO NOT DELETE
10070 class GTEST_API_ KilledBySignal {
10071  public:
10072   explicit KilledBySignal(int signum);
10073   bool operator()(int exit_status) const;
10074  private:
10075   const int signum_;
10076 };
10077 # endif  // !GTEST_OS_WINDOWS
10078 
10079 // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
10080 // The death testing framework causes this to have interesting semantics,
10081 // since the sideeffects of the call are only visible in opt mode, and not
10082 // in debug mode.
10083 //
10084 // In practice, this can be used to test functions that utilize the
10085 // LOG(DFATAL) macro using the following style:
10086 //
10087 // int DieInDebugOr12(int* sideeffect) {
10088 //   if (sideeffect) {
10089 //     *sideeffect = 12;
10090 //   }
10091 //   LOG(DFATAL) << "death";
10092 //   return 12;
10093 // }
10094 //
10095 // TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) {
10096 //   int sideeffect = 0;
10097 //   // Only asserts in dbg.
10098 //   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
10099 //
10100 // #ifdef NDEBUG
10101 //   // opt-mode has sideeffect visible.
10102 //   EXPECT_EQ(12, sideeffect);
10103 // #else
10104 //   // dbg-mode no visible sideeffect.
10105 //   EXPECT_EQ(0, sideeffect);
10106 // #endif
10107 // }
10108 //
10109 // This will assert that DieInDebugReturn12InOpt() crashes in debug
10110 // mode, usually due to a DCHECK or LOG(DFATAL), but returns the
10111 // appropriate fallback value (12 in this case) in opt mode. If you
10112 // need to test that a function has appropriate side-effects in opt
10113 // mode, include assertions against the side-effects.  A general
10114 // pattern for this is:
10115 //
10116 // EXPECT_DEBUG_DEATH({
10117 //   // Side-effects here will have an effect after this statement in
10118 //   // opt mode, but none in debug mode.
10119 //   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
10120 // }, "death");
10121 //
10122 # ifdef NDEBUG
10123 
10124 #  define EXPECT_DEBUG_DEATH(statement, regex) \
10125   GTEST_EXECUTE_STATEMENT_(statement, regex)
10126 
10127 #  define ASSERT_DEBUG_DEATH(statement, regex) \
10128   GTEST_EXECUTE_STATEMENT_(statement, regex)
10129 
10130 # else
10131 
10132 #  define EXPECT_DEBUG_DEATH(statement, regex) \
10133   EXPECT_DEATH(statement, regex)
10134 
10135 #  define ASSERT_DEBUG_DEATH(statement, regex) \
10136   ASSERT_DEATH(statement, regex)
10137 
10138 # endif  // NDEBUG for EXPECT_DEBUG_DEATH
10139 #endif  // GTEST_HAS_DEATH_TEST
10140 
10141 // This macro is used for implementing macros such as
10142 // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
10143 // death tests are not supported. Those macros must compile on such systems
10144 // iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
10145 // systems that support death tests. This allows one to write such a macro
10146 // on a system that does not support death tests and be sure that it will
10147 // compile on a death-test supporting system. It is exposed publicly so that
10148 // systems that have death-tests with stricter requirements than
10149 // GTEST_HAS_DEATH_TEST can write their own equivalent of
10150 // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
10151 //
10152 // Parameters:
10153 //   statement -  A statement that a macro such as EXPECT_DEATH would test
10154 //                for program termination. This macro has to make sure this
10155 //                statement is compiled but not executed, to ensure that
10156 //                EXPECT_DEATH_IF_SUPPORTED compiles with a certain
10157 //                parameter iff EXPECT_DEATH compiles with it.
10158 //   regex     -  A regex that a macro such as EXPECT_DEATH would use to test
10159 //                the output of statement.  This parameter has to be
10160 //                compiled but not evaluated by this macro, to ensure that
10161 //                this macro only accepts expressions that a macro such as
10162 //                EXPECT_DEATH would accept.
10163 //   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
10164 //                and a return statement for ASSERT_DEATH_IF_SUPPORTED.
10165 //                This ensures that ASSERT_DEATH_IF_SUPPORTED will not
10166 //                compile inside functions where ASSERT_DEATH doesn't
10167 //                compile.
10168 //
10169 //  The branch that has an always false condition is used to ensure that
10170 //  statement and regex are compiled (and thus syntactically correct) but
10171 //  never executed. The unreachable code macro protects the terminator
10172 //  statement from generating an 'unreachable code' warning in case
10173 //  statement unconditionally returns or throws. The Message constructor at
10174 //  the end allows the syntax of streaming additional messages into the
10175 //  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
10176 # define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
10177     GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
10178     if (::testing::internal::AlwaysTrue()) { \
10179       GTEST_LOG_(WARNING) \
10180           << "Death tests are not supported on this platform.\n" \
10181           << "Statement '" #statement "' cannot be verified."; \
10182     } else if (::testing::internal::AlwaysFalse()) { \
10183       ::testing::internal::RE::PartialMatch(".*", (regex)); \
10184       GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
10185       terminator; \
10186     } else \
10187       ::testing::Message()
10188 
10189 // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
10190 // ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
10191 // death tests are supported; otherwise they just issue a warning.  This is
10192 // useful when you are combining death test assertions with normal test
10193 // assertions in one test.
10194 #if GTEST_HAS_DEATH_TEST
10195 # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
10196     EXPECT_DEATH(statement, regex)
10197 # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
10198     ASSERT_DEATH(statement, regex)
10199 #else
10200 # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
10201     GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
10202 # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
10203     GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
10204 #endif
10205 
10206 }  // namespace testing
10207 
10208 #endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
10209 // Copyright 2008, Google Inc.
10210 // All rights reserved.
10211 //
10212 // Redistribution and use in source and binary forms, with or without
10213 // modification, are permitted provided that the following conditions are
10214 // met:
10215 //
10216 //     * Redistributions of source code must retain the above copyright
10217 // notice, this list of conditions and the following disclaimer.
10218 //     * Redistributions in binary form must reproduce the above
10219 // copyright notice, this list of conditions and the following disclaimer
10220 // in the documentation and/or other materials provided with the
10221 // distribution.
10222 //     * Neither the name of Google Inc. nor the names of its
10223 // contributors may be used to endorse or promote products derived from
10224 // this software without specific prior written permission.
10225 //
10226 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10227 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10228 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
10229 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10230 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10231 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10232 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10233 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
10234 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10235 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
10236 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10237 //
10238 // Macros and functions for implementing parameterized tests
10239 // in Google C++ Testing and Mocking Framework (Google Test)
10240 //
10241 // This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
10242 //
10243 // GOOGLETEST_CM0001 DO NOT DELETE
10244 #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
10245 #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
10246 
10247 
10248 // Value-parameterized tests allow you to test your code with different
10249 // parameters without writing multiple copies of the same test.
10250 //
10251 // Here is how you use value-parameterized tests:
10252 
10253 #if 0
10254 
10255 // To write value-parameterized tests, first you should define a fixture
10256 // class. It is usually derived from testing::TestWithParam<T> (see below for
10257 // another inheritance scheme that's sometimes useful in more complicated
10258 // class hierarchies), where the type of your parameter values.
10259 // TestWithParam<T> is itself derived from testing::Test. T can be any
10260 // copyable type. If it's a raw pointer, you are responsible for managing the
10261 // lifespan of the pointed values.
10262 
10263 class FooTest : public ::testing::TestWithParam<const char*> {
10264   // You can implement all the usual class fixture members here.
10265 };
10266 
10267 // Then, use the TEST_P macro to define as many parameterized tests
10268 // for this fixture as you want. The _P suffix is for "parameterized"
10269 // or "pattern", whichever you prefer to think.
10270 
10271 TEST_P(FooTest, DoesBlah) {
10272   // Inside a test, access the test parameter with the GetParam() method
10273   // of the TestWithParam<T> class:
10274   EXPECT_TRUE(foo.Blah(GetParam()));
10275   ...
10276 }
10277 
10278 TEST_P(FooTest, HasBlahBlah) {
10279   ...
10280 }
10281 
10282 // Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test
10283 // case with any set of parameters you want. Google Test defines a number
10284 // of functions for generating test parameters. They return what we call
10285 // (surprise!) parameter generators. Here is a summary of them, which
10286 // are all in the testing namespace:
10287 //
10288 //
10289 //  Range(begin, end [, step]) - Yields values {begin, begin+step,
10290 //                               begin+step+step, ...}. The values do not
10291 //                               include end. step defaults to 1.
10292 //  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.
10293 //  ValuesIn(container)        - Yields values from a C-style array, an STL
10294 //  ValuesIn(begin,end)          container, or an iterator range [begin, end).
10295 //  Bool()                     - Yields sequence {false, true}.
10296 //  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product
10297 //                               for the math savvy) of the values generated
10298 //                               by the N generators.
10299 //
10300 // For more details, see comments at the definitions of these functions below
10301 // in this file.
10302 //
10303 // The following statement will instantiate tests from the FooTest test suite
10304 // each with parameter values "meeny", "miny", and "moe".
10305 
10306 INSTANTIATE_TEST_SUITE_P(InstantiationName,
10307                          FooTest,
10308                          Values("meeny", "miny", "moe"));
10309 
10310 // To distinguish different instances of the pattern, (yes, you
10311 // can instantiate it more than once) the first argument to the
10312 // INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the
10313 // actual test suite name. Remember to pick unique prefixes for different
10314 // instantiations. The tests from the instantiation above will have
10315 // these names:
10316 //
10317 //    * InstantiationName/FooTest.DoesBlah/0 for "meeny"
10318 //    * InstantiationName/FooTest.DoesBlah/1 for "miny"
10319 //    * InstantiationName/FooTest.DoesBlah/2 for "moe"
10320 //    * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
10321 //    * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
10322 //    * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
10323 //
10324 // You can use these names in --gtest_filter.
10325 //
10326 // This statement will instantiate all tests from FooTest again, each
10327 // with parameter values "cat" and "dog":
10328 
10329 const char* pets[] = {"cat", "dog"};
10330 INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
10331 
10332 // The tests from the instantiation above will have these names:
10333 //
10334 //    * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
10335 //    * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
10336 //    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
10337 //    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
10338 //
10339 // Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests
10340 // in the given test suite, whether their definitions come before or
10341 // AFTER the INSTANTIATE_TEST_SUITE_P statement.
10342 //
10343 // Please also note that generator expressions (including parameters to the
10344 // generators) are evaluated in InitGoogleTest(), after main() has started.
10345 // This allows the user on one hand, to adjust generator parameters in order
10346 // to dynamically determine a set of tests to run and on the other hand,
10347 // give the user a chance to inspect the generated tests with Google Test
10348 // reflection API before RUN_ALL_TESTS() is executed.
10349 //
10350 // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
10351 // for more examples.
10352 //
10353 // In the future, we plan to publish the API for defining new parameter
10354 // generators. But for now this interface remains part of the internal
10355 // implementation and is subject to change.
10356 //
10357 //
10358 // A parameterized test fixture must be derived from testing::Test and from
10359 // testing::WithParamInterface<T>, where T is the type of the parameter
10360 // values. Inheriting from TestWithParam<T> satisfies that requirement because
10361 // TestWithParam<T> inherits from both Test and WithParamInterface. In more
10362 // complicated hierarchies, however, it is occasionally useful to inherit
10363 // separately from Test and WithParamInterface. For example:
10364 
10365 class BaseTest : public ::testing::Test {
10366   // You can inherit all the usual members for a non-parameterized test
10367   // fixture here.
10368 };
10369 
10370 class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
10371   // The usual test fixture members go here too.
10372 };
10373 
10374 TEST_F(BaseTest, HasFoo) {
10375   // This is an ordinary non-parameterized test.
10376 }
10377 
10378 TEST_P(DerivedTest, DoesBlah) {
10379   // GetParam works just the same here as if you inherit from TestWithParam.
10380   EXPECT_TRUE(foo.Blah(GetParam()));
10381 }
10382 
10383 #endif  // 0
10384 
10385 #include <utility>
10386 
10387 // Copyright 2008 Google Inc.
10388 // All Rights Reserved.
10389 //
10390 // Redistribution and use in source and binary forms, with or without
10391 // modification, are permitted provided that the following conditions are
10392 // met:
10393 //
10394 //     * Redistributions of source code must retain the above copyright
10395 // notice, this list of conditions and the following disclaimer.
10396 //     * Redistributions in binary form must reproduce the above
10397 // copyright notice, this list of conditions and the following disclaimer
10398 // in the documentation and/or other materials provided with the
10399 // distribution.
10400 //     * Neither the name of Google Inc. nor the names of its
10401 // contributors may be used to endorse or promote products derived from
10402 // this software without specific prior written permission.
10403 //
10404 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10405 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10406 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
10407 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10408 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10409 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10410 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10411 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
10412 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10413 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
10414 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10415 
10416 
10417 // Type and function utilities for implementing parameterized tests.
10418 
10419 // GOOGLETEST_CM0001 DO NOT DELETE
10420 
10421 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
10422 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
10423 
10424 #include <ctype.h>
10425 
10426 #include <cassert>
10427 #include <iterator>
10428 #include <memory>
10429 #include <set>
10430 #include <tuple>
10431 #include <utility>
10432 #include <vector>
10433 
10434 
10435 namespace testing {
10436 // Input to a parameterized test name generator, describing a test parameter.
10437 // Consists of the parameter value and the integer parameter index.
10438 template <class ParamType>
10439 struct TestParamInfo {
10440   TestParamInfo(const ParamType& a_param, size_t an_index) :
10441     param(a_param),
10442     index(an_index) {}
10443   ParamType param;
10444   size_t index;
10445 };
10446 
10447 // A builtin parameterized test name generator which returns the result of
10448 // testing::PrintToString.
10449 struct PrintToStringParamName {
10450   template <class ParamType>
10451   std::string operator()(const TestParamInfo<ParamType>& info) const {
10452     return PrintToString(info.param);
10453   }
10454 };
10455 
10456 namespace internal {
10457 
10458 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10459 // Utility Functions
10460 
10461 // Outputs a message explaining invalid registration of different
10462 // fixture class for the same test suite. This may happen when
10463 // TEST_P macro is used to define two tests with the same name
10464 // but in different namespaces.
10465 GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
10466                                            CodeLocation code_location);
10467 
10468 template <typename> class ParamGeneratorInterface;
10469 template <typename> class ParamGenerator;
10470 
10471 // Interface for iterating over elements provided by an implementation
10472 // of ParamGeneratorInterface<T>.
10473 template <typename T>
10474 class ParamIteratorInterface {
10475  public:
10476   virtual ~ParamIteratorInterface() {}
10477   // A pointer to the base generator instance.
10478   // Used only for the purposes of iterator comparison
10479   // to make sure that two iterators belong to the same generator.
10480   virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
10481   // Advances iterator to point to the next element
10482   // provided by the generator. The caller is responsible
10483   // for not calling Advance() on an iterator equal to
10484   // BaseGenerator()->End().
10485   virtual void Advance() = 0;
10486   // Clones the iterator object. Used for implementing copy semantics
10487   // of ParamIterator<T>.
10488   virtual ParamIteratorInterface* Clone() const = 0;
10489   // Dereferences the current iterator and provides (read-only) access
10490   // to the pointed value. It is the caller's responsibility not to call
10491   // Current() on an iterator equal to BaseGenerator()->End().
10492   // Used for implementing ParamGenerator<T>::operator*().
10493   virtual const T* Current() const = 0;
10494   // Determines whether the given iterator and other point to the same
10495   // element in the sequence generated by the generator.
10496   // Used for implementing ParamGenerator<T>::operator==().
10497   virtual bool Equals(const ParamIteratorInterface& other) const = 0;
10498 };
10499 
10500 // Class iterating over elements provided by an implementation of
10501 // ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
10502 // and implements the const forward iterator concept.
10503 template <typename T>
10504 class ParamIterator {
10505  public:
10506   typedef T value_type;
10507   typedef const T& reference;
10508   typedef ptrdiff_t difference_type;
10509 
10510   // ParamIterator assumes ownership of the impl_ pointer.
10511   ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
10512   ParamIterator& operator=(const ParamIterator& other) {
10513     if (this != &other)
10514       impl_.reset(other.impl_->Clone());
10515     return *this;
10516   }
10517 
10518   const T& operator*() const { return *impl_->Current(); }
10519   const T* operator->() const { return impl_->Current(); }
10520   // Prefix version of operator++.
10521   ParamIterator& operator++() {
10522     impl_->Advance();
10523     return *this;
10524   }
10525   // Postfix version of operator++.
10526   ParamIterator operator++(int /*unused*/) {
10527     ParamIteratorInterface<T>* clone = impl_->Clone();
10528     impl_->Advance();
10529     return ParamIterator(clone);
10530   }
10531   bool operator==(const ParamIterator& other) const {
10532     return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
10533   }
10534   bool operator!=(const ParamIterator& other) const {
10535     return !(*this == other);
10536   }
10537 
10538  private:
10539   friend class ParamGenerator<T>;
10540   explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
10541   std::unique_ptr<ParamIteratorInterface<T> > impl_;
10542 };
10543 
10544 // ParamGeneratorInterface<T> is the binary interface to access generators
10545 // defined in other translation units.
10546 template <typename T>
10547 class ParamGeneratorInterface {
10548  public:
10549   typedef T ParamType;
10550 
10551   virtual ~ParamGeneratorInterface() {}
10552 
10553   // Generator interface definition
10554   virtual ParamIteratorInterface<T>* Begin() const = 0;
10555   virtual ParamIteratorInterface<T>* End() const = 0;
10556 };
10557 
10558 // Wraps ParamGeneratorInterface<T> and provides general generator syntax
10559 // compatible with the STL Container concept.
10560 // This class implements copy initialization semantics and the contained
10561 // ParamGeneratorInterface<T> instance is shared among all copies
10562 // of the original object. This is possible because that instance is immutable.
10563 template<typename T>
10564 class ParamGenerator {
10565  public:
10566   typedef ParamIterator<T> iterator;
10567 
10568   explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
10569   ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
10570 
10571   ParamGenerator& operator=(const ParamGenerator& other) {
10572     impl_ = other.impl_;
10573     return *this;
10574   }
10575 
10576   iterator begin() const { return iterator(impl_->Begin()); }
10577   iterator end() const { return iterator(impl_->End()); }
10578 
10579  private:
10580   std::shared_ptr<const ParamGeneratorInterface<T> > impl_;
10581 };
10582 
10583 // Generates values from a range of two comparable values. Can be used to
10584 // generate sequences of user-defined types that implement operator+() and
10585 // operator<().
10586 // This class is used in the Range() function.
10587 template <typename T, typename IncrementT>
10588 class RangeGenerator : public ParamGeneratorInterface<T> {
10589  public:
10590   RangeGenerator(T begin, T end, IncrementT step)
10591       : begin_(begin), end_(end),
10592         step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
10593   ~RangeGenerator() override {}
10594 
10595   ParamIteratorInterface<T>* Begin() const override {
10596     return new Iterator(this, begin_, 0, step_);
10597   }
10598   ParamIteratorInterface<T>* End() const override {
10599     return new Iterator(this, end_, end_index_, step_);
10600   }
10601 
10602  private:
10603   class Iterator : public ParamIteratorInterface<T> {
10604    public:
10605     Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
10606              IncrementT step)
10607         : base_(base), value_(value), index_(index), step_(step) {}
10608     ~Iterator() override {}
10609 
10610     const ParamGeneratorInterface<T>* BaseGenerator() const override {
10611       return base_;
10612     }
10613     void Advance() override {
10614       value_ = static_cast<T>(value_ + step_);
10615       index_++;
10616     }
10617     ParamIteratorInterface<T>* Clone() const override {
10618       return new Iterator(*this);
10619     }
10620     const T* Current() const override { return &value_; }
10621     bool Equals(const ParamIteratorInterface<T>& other) const override {
10622       // Having the same base generator guarantees that the other
10623       // iterator is of the same type and we can downcast.
10624       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
10625           << "The program attempted to compare iterators "
10626           << "from different generators." << std::endl;
10627       const int other_index =
10628           CheckedDowncastToActualType<const Iterator>(&other)->index_;
10629       return index_ == other_index;
10630     }
10631 
10632    private:
10633     Iterator(const Iterator& other)
10634         : ParamIteratorInterface<T>(),
10635           base_(other.base_), value_(other.value_), index_(other.index_),
10636           step_(other.step_) {}
10637 
10638     // No implementation - assignment is unsupported.
10639     void operator=(const Iterator& other);
10640 
10641     const ParamGeneratorInterface<T>* const base_;
10642     T value_;
10643     int index_;
10644     const IncrementT step_;
10645   };  // class RangeGenerator::Iterator
10646 
10647   static int CalculateEndIndex(const T& begin,
10648                                const T& end,
10649                                const IncrementT& step) {
10650     int end_index = 0;
10651     for (T i = begin; i < end; i = static_cast<T>(i + step))
10652       end_index++;
10653     return end_index;
10654   }
10655 
10656   // No implementation - assignment is unsupported.
10657   void operator=(const RangeGenerator& other);
10658 
10659   const T begin_;
10660   const T end_;
10661   const IncrementT step_;
10662   // The index for the end() iterator. All the elements in the generated
10663   // sequence are indexed (0-based) to aid iterator comparison.
10664   const int end_index_;
10665 };  // class RangeGenerator
10666 
10667 
10668 // Generates values from a pair of STL-style iterators. Used in the
10669 // ValuesIn() function. The elements are copied from the source range
10670 // since the source can be located on the stack, and the generator
10671 // is likely to persist beyond that stack frame.
10672 template <typename T>
10673 class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
10674  public:
10675   template <typename ForwardIterator>
10676   ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
10677       : container_(begin, end) {}
10678   ~ValuesInIteratorRangeGenerator() override {}
10679 
10680   ParamIteratorInterface<T>* Begin() const override {
10681     return new Iterator(this, container_.begin());
10682   }
10683   ParamIteratorInterface<T>* End() const override {
10684     return new Iterator(this, container_.end());
10685   }
10686 
10687  private:
10688   typedef typename ::std::vector<T> ContainerType;
10689 
10690   class Iterator : public ParamIteratorInterface<T> {
10691    public:
10692     Iterator(const ParamGeneratorInterface<T>* base,
10693              typename ContainerType::const_iterator iterator)
10694         : base_(base), iterator_(iterator) {}
10695     ~Iterator() override {}
10696 
10697     const ParamGeneratorInterface<T>* BaseGenerator() const override {
10698       return base_;
10699     }
10700     void Advance() override {
10701       ++iterator_;
10702       value_.reset();
10703     }
10704     ParamIteratorInterface<T>* Clone() const override {
10705       return new Iterator(*this);
10706     }
10707     // We need to use cached value referenced by iterator_ because *iterator_
10708     // can return a temporary object (and of type other then T), so just
10709     // having "return &*iterator_;" doesn't work.
10710     // value_ is updated here and not in Advance() because Advance()
10711     // can advance iterator_ beyond the end of the range, and we cannot
10712     // detect that fact. The client code, on the other hand, is
10713     // responsible for not calling Current() on an out-of-range iterator.
10714     const T* Current() const override {
10715       if (value_.get() == nullptr) value_.reset(new T(*iterator_));
10716       return value_.get();
10717     }
10718     bool Equals(const ParamIteratorInterface<T>& other) const override {
10719       // Having the same base generator guarantees that the other
10720       // iterator is of the same type and we can downcast.
10721       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
10722           << "The program attempted to compare iterators "
10723           << "from different generators." << std::endl;
10724       return iterator_ ==
10725           CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
10726     }
10727 
10728    private:
10729     Iterator(const Iterator& other)
10730           // The explicit constructor call suppresses a false warning
10731           // emitted by gcc when supplied with the -Wextra option.
10732         : ParamIteratorInterface<T>(),
10733           base_(other.base_),
10734           iterator_(other.iterator_) {}
10735 
10736     const ParamGeneratorInterface<T>* const base_;
10737     typename ContainerType::const_iterator iterator_;
10738     // A cached value of *iterator_. We keep it here to allow access by
10739     // pointer in the wrapping iterator's operator->().
10740     // value_ needs to be mutable to be accessed in Current().
10741     // Use of std::unique_ptr helps manage cached value's lifetime,
10742     // which is bound by the lifespan of the iterator itself.
10743     mutable std::unique_ptr<const T> value_;
10744   };  // class ValuesInIteratorRangeGenerator::Iterator
10745 
10746   // No implementation - assignment is unsupported.
10747   void operator=(const ValuesInIteratorRangeGenerator& other);
10748 
10749   const ContainerType container_;
10750 };  // class ValuesInIteratorRangeGenerator
10751 
10752 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10753 //
10754 // Default parameterized test name generator, returns a string containing the
10755 // integer test parameter index.
10756 template <class ParamType>
10757 std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
10758   Message name_stream;
10759   name_stream << info.index;
10760   return name_stream.GetString();
10761 }
10762 
10763 template <typename T = int>
10764 void TestNotEmpty() {
10765   static_assert(sizeof(T) == 0, "Empty arguments are not allowed.");
10766 }
10767 template <typename T = int>
10768 void TestNotEmpty(const T&) {}
10769 
10770 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10771 //
10772 // Stores a parameter value and later creates tests parameterized with that
10773 // value.
10774 template <class TestClass>
10775 class ParameterizedTestFactory : public TestFactoryBase {
10776  public:
10777   typedef typename TestClass::ParamType ParamType;
10778   explicit ParameterizedTestFactory(ParamType parameter) :
10779       parameter_(parameter) {}
10780   Test* CreateTest() override {
10781     TestClass::SetParam(&parameter_);
10782     return new TestClass();
10783   }
10784 
10785  private:
10786   const ParamType parameter_;
10787 
10788   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
10789 };
10790 
10791 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10792 //
10793 // TestMetaFactoryBase is a base class for meta-factories that create
10794 // test factories for passing into MakeAndRegisterTestInfo function.
10795 template <class ParamType>
10796 class TestMetaFactoryBase {
10797  public:
10798   virtual ~TestMetaFactoryBase() {}
10799 
10800   virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
10801 };
10802 
10803 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10804 //
10805 // TestMetaFactory creates test factories for passing into
10806 // MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
10807 // ownership of test factory pointer, same factory object cannot be passed
10808 // into that method twice. But ParameterizedTestSuiteInfo is going to call
10809 // it for each Test/Parameter value combination. Thus it needs meta factory
10810 // creator class.
10811 template <class TestSuite>
10812 class TestMetaFactory
10813     : public TestMetaFactoryBase<typename TestSuite::ParamType> {
10814  public:
10815   using ParamType = typename TestSuite::ParamType;
10816 
10817   TestMetaFactory() {}
10818 
10819   TestFactoryBase* CreateTestFactory(ParamType parameter) override {
10820     return new ParameterizedTestFactory<TestSuite>(parameter);
10821   }
10822 
10823  private:
10824   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
10825 };
10826 
10827 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10828 //
10829 // ParameterizedTestSuiteInfoBase is a generic interface
10830 // to ParameterizedTestSuiteInfo classes. ParameterizedTestSuiteInfoBase
10831 // accumulates test information provided by TEST_P macro invocations
10832 // and generators provided by INSTANTIATE_TEST_SUITE_P macro invocations
10833 // and uses that information to register all resulting test instances
10834 // in RegisterTests method. The ParameterizeTestSuiteRegistry class holds
10835 // a collection of pointers to the ParameterizedTestSuiteInfo objects
10836 // and calls RegisterTests() on each of them when asked.
10837 class ParameterizedTestSuiteInfoBase {
10838  public:
10839   virtual ~ParameterizedTestSuiteInfoBase() {}
10840 
10841   // Base part of test suite name for display purposes.
10842   virtual const std::string& GetTestSuiteName() const = 0;
10843   // Test case id to verify identity.
10844   virtual TypeId GetTestSuiteTypeId() const = 0;
10845   // UnitTest class invokes this method to register tests in this
10846   // test suite right before running them in RUN_ALL_TESTS macro.
10847   // This method should not be called more than once on any single
10848   // instance of a ParameterizedTestSuiteInfoBase derived class.
10849   virtual void RegisterTests() = 0;
10850 
10851  protected:
10852   ParameterizedTestSuiteInfoBase() {}
10853 
10854  private:
10855   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);
10856 };
10857 
10858 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10859 //
10860 // ParameterizedTestSuiteInfo accumulates tests obtained from TEST_P
10861 // macro invocations for a particular test suite and generators
10862 // obtained from INSTANTIATE_TEST_SUITE_P macro invocations for that
10863 // test suite. It registers tests with all values generated by all
10864 // generators when asked.
10865 template <class TestSuite>
10866 class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
10867  public:
10868   // ParamType and GeneratorCreationFunc are private types but are required
10869   // for declarations of public methods AddTestPattern() and
10870   // AddTestSuiteInstantiation().
10871   using ParamType = typename TestSuite::ParamType;
10872   // A function that returns an instance of appropriate generator type.
10873   typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
10874   using ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&);
10875 
10876   explicit ParameterizedTestSuiteInfo(const char* name,
10877                                       CodeLocation code_location)
10878       : test_suite_name_(name), code_location_(code_location) {}
10879 
10880   // Test case base name for display purposes.
10881   const std::string& GetTestSuiteName() const override {
10882     return test_suite_name_;
10883   }
10884   // Test case id to verify identity.
10885   TypeId GetTestSuiteTypeId() const override { return GetTypeId<TestSuite>(); }
10886   // TEST_P macro uses AddTestPattern() to record information
10887   // about a single test in a LocalTestInfo structure.
10888   // test_suite_name is the base name of the test suite (without invocation
10889   // prefix). test_base_name is the name of an individual test without
10890   // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
10891   // test suite base name and DoBar is test base name.
10892   void AddTestPattern(const char* test_suite_name, const char* test_base_name,
10893                       TestMetaFactoryBase<ParamType>* meta_factory) {
10894     tests_.push_back(std::shared_ptr<TestInfo>(
10895         new TestInfo(test_suite_name, test_base_name, meta_factory)));
10896   }
10897   // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
10898   // about a generator.
10899   int AddTestSuiteInstantiation(const std::string& instantiation_name,
10900                                 GeneratorCreationFunc* func,
10901                                 ParamNameGeneratorFunc* name_func,
10902                                 const char* file, int line) {
10903     instantiations_.push_back(
10904         InstantiationInfo(instantiation_name, func, name_func, file, line));
10905     return 0;  // Return value used only to run this method in namespace scope.
10906   }
10907   // UnitTest class invokes this method to register tests in this test suite
10908   // test suites right before running tests in RUN_ALL_TESTS macro.
10909   // This method should not be called more than once on any single
10910   // instance of a ParameterizedTestSuiteInfoBase derived class.
10911   // UnitTest has a guard to prevent from calling this method more than once.
10912   void RegisterTests() override {
10913     for (typename TestInfoContainer::iterator test_it = tests_.begin();
10914          test_it != tests_.end(); ++test_it) {
10915       std::shared_ptr<TestInfo> test_info = *test_it;
10916       for (typename InstantiationContainer::iterator gen_it =
10917                instantiations_.begin(); gen_it != instantiations_.end();
10918                ++gen_it) {
10919         const std::string& instantiation_name = gen_it->name;
10920         ParamGenerator<ParamType> generator((*gen_it->generator)());
10921         ParamNameGeneratorFunc* name_func = gen_it->name_func;
10922         const char* file = gen_it->file;
10923         int line = gen_it->line;
10924 
10925         std::string test_suite_name;
10926         if ( !instantiation_name.empty() )
10927           test_suite_name = instantiation_name + "/";
10928         test_suite_name += test_info->test_suite_base_name;
10929 
10930         size_t i = 0;
10931         std::set<std::string> test_param_names;
10932         for (typename ParamGenerator<ParamType>::iterator param_it =
10933                  generator.begin();
10934              param_it != generator.end(); ++param_it, ++i) {
10935           Message test_name_stream;
10936 
10937           std::string param_name = name_func(
10938               TestParamInfo<ParamType>(*param_it, i));
10939 
10940           GTEST_CHECK_(IsValidParamName(param_name))
10941               << "Parameterized test name '" << param_name
10942               << "' is invalid, in " << file
10943               << " line " << line << std::endl;
10944 
10945           GTEST_CHECK_(test_param_names.count(param_name) == 0)
10946               << "Duplicate parameterized test name '" << param_name
10947               << "', in " << file << " line " << line << std::endl;
10948 
10949           test_param_names.insert(param_name);
10950 
10951           test_name_stream << test_info->test_base_name << "/" << param_name;
10952           MakeAndRegisterTestInfo(
10953               test_suite_name.c_str(), test_name_stream.GetString().c_str(),
10954               nullptr,  // No type parameter.
10955               PrintToString(*param_it).c_str(), code_location_,
10956               GetTestSuiteTypeId(),
10957               SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(),
10958               SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(),
10959               test_info->test_meta_factory->CreateTestFactory(*param_it));
10960         }  // for param_it
10961       }  // for gen_it
10962     }  // for test_it
10963   }    // RegisterTests
10964 
10965  private:
10966   // LocalTestInfo structure keeps information about a single test registered
10967   // with TEST_P macro.
10968   struct TestInfo {
10969     TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
10970              TestMetaFactoryBase<ParamType>* a_test_meta_factory)
10971         : test_suite_base_name(a_test_suite_base_name),
10972           test_base_name(a_test_base_name),
10973           test_meta_factory(a_test_meta_factory) {}
10974 
10975     const std::string test_suite_base_name;
10976     const std::string test_base_name;
10977     const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
10978   };
10979   using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;
10980   // Records data received from INSTANTIATE_TEST_SUITE_P macros:
10981   //  <Instantiation name, Sequence generator creation function,
10982   //     Name generator function, Source file, Source line>
10983   struct InstantiationInfo {
10984       InstantiationInfo(const std::string &name_in,
10985                         GeneratorCreationFunc* generator_in,
10986                         ParamNameGeneratorFunc* name_func_in,
10987                         const char* file_in,
10988                         int line_in)
10989           : name(name_in),
10990             generator(generator_in),
10991             name_func(name_func_in),
10992             file(file_in),
10993             line(line_in) {}
10994 
10995       std::string name;
10996       GeneratorCreationFunc* generator;
10997       ParamNameGeneratorFunc* name_func;
10998       const char* file;
10999       int line;
11000   };
11001   typedef ::std::vector<InstantiationInfo> InstantiationContainer;
11002 
11003   static bool IsValidParamName(const std::string& name) {
11004     // Check for empty string
11005     if (name.empty())
11006       return false;
11007 
11008     // Check for invalid characters
11009     for (std::string::size_type index = 0; index < name.size(); ++index) {
11010       if (!isalnum(name[index]) && name[index] != '_')
11011         return false;
11012     }
11013 
11014     return true;
11015   }
11016 
11017   const std::string test_suite_name_;
11018   CodeLocation code_location_;
11019   TestInfoContainer tests_;
11020   InstantiationContainer instantiations_;
11021 
11022   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);
11023 };  // class ParameterizedTestSuiteInfo
11024 
11025 //  Legacy API is deprecated but still available
11026 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11027 template <class TestCase>
11028 using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
11029 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11030 
11031 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
11032 //
11033 // ParameterizedTestSuiteRegistry contains a map of
11034 // ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P
11035 // and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding
11036 // ParameterizedTestSuiteInfo descriptors.
11037 class ParameterizedTestSuiteRegistry {
11038  public:
11039   ParameterizedTestSuiteRegistry() {}
11040   ~ParameterizedTestSuiteRegistry() {
11041     for (auto& test_suite_info : test_suite_infos_) {
11042       delete test_suite_info;
11043     }
11044   }
11045 
11046   // Looks up or creates and returns a structure containing information about
11047   // tests and instantiations of a particular test suite.
11048   template <class TestSuite>
11049   ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(
11050       const char* test_suite_name, CodeLocation code_location) {
11051     ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;
11052     for (auto& test_suite_info : test_suite_infos_) {
11053       if (test_suite_info->GetTestSuiteName() == test_suite_name) {
11054         if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
11055           // Complain about incorrect usage of Google Test facilities
11056           // and terminate the program since we cannot guaranty correct
11057           // test suite setup and tear-down in this case.
11058           ReportInvalidTestSuiteType(test_suite_name, code_location);
11059           posix::Abort();
11060         } else {
11061           // At this point we are sure that the object we found is of the same
11062           // type we are looking for, so we downcast it to that type
11063           // without further checks.
11064           typed_test_info = CheckedDowncastToActualType<
11065               ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);
11066         }
11067         break;
11068       }
11069     }
11070     if (typed_test_info == nullptr) {
11071       typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(
11072           test_suite_name, code_location);
11073       test_suite_infos_.push_back(typed_test_info);
11074     }
11075     return typed_test_info;
11076   }
11077   void RegisterTests() {
11078     for (auto& test_suite_info : test_suite_infos_) {
11079       test_suite_info->RegisterTests();
11080     }
11081   }
11082 //  Legacy API is deprecated but still available
11083 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11084   template <class TestCase>
11085   ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
11086       const char* test_case_name, CodeLocation code_location) {
11087     return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);
11088   }
11089 
11090 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11091 
11092  private:
11093   using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;
11094 
11095   TestSuiteInfoContainer test_suite_infos_;
11096 
11097   GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);
11098 };
11099 
11100 }  // namespace internal
11101 
11102 // Forward declarations of ValuesIn(), which is implemented in
11103 // include/gtest/gtest-param-test.h.
11104 template <class Container>
11105 internal::ParamGenerator<typename Container::value_type> ValuesIn(
11106     const Container& container);
11107 
11108 namespace internal {
11109 // Used in the Values() function to provide polymorphic capabilities.
11110 
11111 template <typename... Ts>
11112 class ValueArray {
11113  public:
11114   ValueArray(Ts... v) : v_{std::move(v)...} {}
11115 
11116   template <typename T>
11117   operator ParamGenerator<T>() const {  // NOLINT
11118     return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
11119   }
11120 
11121  private:
11122   template <typename T, size_t... I>
11123   std::vector<T> MakeVector(IndexSequence<I...>) const {
11124     return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
11125   }
11126 
11127   FlatTuple<Ts...> v_;
11128 };
11129 
11130 template <typename... T>
11131 class CartesianProductGenerator
11132     : public ParamGeneratorInterface<::std::tuple<T...>> {
11133  public:
11134   typedef ::std::tuple<T...> ParamType;
11135 
11136   CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
11137       : generators_(g) {}
11138   ~CartesianProductGenerator() override {}
11139 
11140   ParamIteratorInterface<ParamType>* Begin() const override {
11141     return new Iterator(this, generators_, false);
11142   }
11143   ParamIteratorInterface<ParamType>* End() const override {
11144     return new Iterator(this, generators_, true);
11145   }
11146 
11147  private:
11148   template <class I>
11149   class IteratorImpl;
11150   template <size_t... I>
11151   class IteratorImpl<IndexSequence<I...>>
11152       : public ParamIteratorInterface<ParamType> {
11153    public:
11154     IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
11155              const std::tuple<ParamGenerator<T>...>& generators, bool is_end)
11156         : base_(base),
11157           begin_(std::get<I>(generators).begin()...),
11158           end_(std::get<I>(generators).end()...),
11159           current_(is_end ? end_ : begin_) {
11160       ComputeCurrentValue();
11161     }
11162     ~IteratorImpl() override {}
11163 
11164     const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
11165       return base_;
11166     }
11167     // Advance should not be called on beyond-of-range iterators
11168     // so no component iterators must be beyond end of range, either.
11169     void Advance() override {
11170       assert(!AtEnd());
11171       // Advance the last iterator.
11172       ++std::get<sizeof...(T) - 1>(current_);
11173       // if that reaches end, propagate that up.
11174       AdvanceIfEnd<sizeof...(T) - 1>();
11175       ComputeCurrentValue();
11176     }
11177     ParamIteratorInterface<ParamType>* Clone() const override {
11178       return new IteratorImpl(*this);
11179     }
11180 
11181     const ParamType* Current() const override { return current_value_.get(); }
11182 
11183     bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
11184       // Having the same base generator guarantees that the other
11185       // iterator is of the same type and we can downcast.
11186       GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
11187           << "The program attempted to compare iterators "
11188           << "from different generators." << std::endl;
11189       const IteratorImpl* typed_other =
11190           CheckedDowncastToActualType<const IteratorImpl>(&other);
11191 
11192       // We must report iterators equal if they both point beyond their
11193       // respective ranges. That can happen in a variety of fashions,
11194       // so we have to consult AtEnd().
11195       if (AtEnd() && typed_other->AtEnd()) return true;
11196 
11197       bool same = true;
11198       bool dummy[] = {
11199           (same = same && std::get<I>(current_) ==
11200                               std::get<I>(typed_other->current_))...};
11201       (void)dummy;
11202       return same;
11203     }
11204 
11205    private:
11206     template <size_t ThisI>
11207     void AdvanceIfEnd() {
11208       if (std::get<ThisI>(current_) != std::get<ThisI>(end_)) return;
11209 
11210       bool last = ThisI == 0;
11211       if (last) {
11212         // We are done. Nothing else to propagate.
11213         return;
11214       }
11215 
11216       constexpr size_t NextI = ThisI - (ThisI != 0);
11217       std::get<ThisI>(current_) = std::get<ThisI>(begin_);
11218       ++std::get<NextI>(current_);
11219       AdvanceIfEnd<NextI>();
11220     }
11221 
11222     void ComputeCurrentValue() {
11223       if (!AtEnd())
11224         current_value_ = std::make_shared<ParamType>(*std::get<I>(current_)...);
11225     }
11226     bool AtEnd() const {
11227       bool at_end = false;
11228       bool dummy[] = {
11229           (at_end = at_end || std::get<I>(current_) == std::get<I>(end_))...};
11230       (void)dummy;
11231       return at_end;
11232     }
11233 
11234     const ParamGeneratorInterface<ParamType>* const base_;
11235     std::tuple<typename ParamGenerator<T>::iterator...> begin_;
11236     std::tuple<typename ParamGenerator<T>::iterator...> end_;
11237     std::tuple<typename ParamGenerator<T>::iterator...> current_;
11238     std::shared_ptr<ParamType> current_value_;
11239   };
11240 
11241   using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;
11242 
11243   std::tuple<ParamGenerator<T>...> generators_;
11244 };
11245 
11246 template <class... Gen>
11247 class CartesianProductHolder {
11248  public:
11249   CartesianProductHolder(const Gen&... g) : generators_(g...) {}
11250   template <typename... T>
11251   operator ParamGenerator<::std::tuple<T...>>() const {
11252     return ParamGenerator<::std::tuple<T...>>(
11253         new CartesianProductGenerator<T...>(generators_));
11254   }
11255 
11256  private:
11257   std::tuple<Gen...> generators_;
11258 };
11259 
11260 }  // namespace internal
11261 }  // namespace testing
11262 
11263 #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
11264 
11265 namespace testing {
11266 
11267 // Functions producing parameter generators.
11268 //
11269 // Google Test uses these generators to produce parameters for value-
11270 // parameterized tests. When a parameterized test suite is instantiated
11271 // with a particular generator, Google Test creates and runs tests
11272 // for each element in the sequence produced by the generator.
11273 //
11274 // In the following sample, tests from test suite FooTest are instantiated
11275 // each three times with parameter values 3, 5, and 8:
11276 //
11277 // class FooTest : public TestWithParam<int> { ... };
11278 //
11279 // TEST_P(FooTest, TestThis) {
11280 // }
11281 // TEST_P(FooTest, TestThat) {
11282 // }
11283 // INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8));
11284 //
11285 
11286 // Range() returns generators providing sequences of values in a range.
11287 //
11288 // Synopsis:
11289 // Range(start, end)
11290 //   - returns a generator producing a sequence of values {start, start+1,
11291 //     start+2, ..., }.
11292 // Range(start, end, step)
11293 //   - returns a generator producing a sequence of values {start, start+step,
11294 //     start+step+step, ..., }.
11295 // Notes:
11296 //   * The generated sequences never include end. For example, Range(1, 5)
11297 //     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
11298 //     returns a generator producing {1, 3, 5, 7}.
11299 //   * start and end must have the same type. That type may be any integral or
11300 //     floating-point type or a user defined type satisfying these conditions:
11301 //     * It must be assignable (have operator=() defined).
11302 //     * It must have operator+() (operator+(int-compatible type) for
11303 //       two-operand version).
11304 //     * It must have operator<() defined.
11305 //     Elements in the resulting sequences will also have that type.
11306 //   * Condition start < end must be satisfied in order for resulting sequences
11307 //     to contain any elements.
11308 //
11309 template <typename T, typename IncrementT>
11310 internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
11311   return internal::ParamGenerator<T>(
11312       new internal::RangeGenerator<T, IncrementT>(start, end, step));
11313 }
11314 
11315 template <typename T>
11316 internal::ParamGenerator<T> Range(T start, T end) {
11317   return Range(start, end, 1);
11318 }
11319 
11320 // ValuesIn() function allows generation of tests with parameters coming from
11321 // a container.
11322 //
11323 // Synopsis:
11324 // ValuesIn(const T (&array)[N])
11325 //   - returns a generator producing sequences with elements from
11326 //     a C-style array.
11327 // ValuesIn(const Container& container)
11328 //   - returns a generator producing sequences with elements from
11329 //     an STL-style container.
11330 // ValuesIn(Iterator begin, Iterator end)
11331 //   - returns a generator producing sequences with elements from
11332 //     a range [begin, end) defined by a pair of STL-style iterators. These
11333 //     iterators can also be plain C pointers.
11334 //
11335 // Please note that ValuesIn copies the values from the containers
11336 // passed in and keeps them to generate tests in RUN_ALL_TESTS().
11337 //
11338 // Examples:
11339 //
11340 // This instantiates tests from test suite StringTest
11341 // each with C-string values of "foo", "bar", and "baz":
11342 //
11343 // const char* strings[] = {"foo", "bar", "baz"};
11344 // INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));
11345 //
11346 // This instantiates tests from test suite StlStringTest
11347 // each with STL strings with values "a" and "b":
11348 //
11349 // ::std::vector< ::std::string> GetParameterStrings() {
11350 //   ::std::vector< ::std::string> v;
11351 //   v.push_back("a");
11352 //   v.push_back("b");
11353 //   return v;
11354 // }
11355 //
11356 // INSTANTIATE_TEST_SUITE_P(CharSequence,
11357 //                          StlStringTest,
11358 //                          ValuesIn(GetParameterStrings()));
11359 //
11360 //
11361 // This will also instantiate tests from CharTest
11362 // each with parameter values 'a' and 'b':
11363 //
11364 // ::std::list<char> GetParameterChars() {
11365 //   ::std::list<char> list;
11366 //   list.push_back('a');
11367 //   list.push_back('b');
11368 //   return list;
11369 // }
11370 // ::std::list<char> l = GetParameterChars();
11371 // INSTANTIATE_TEST_SUITE_P(CharSequence2,
11372 //                          CharTest,
11373 //                          ValuesIn(l.begin(), l.end()));
11374 //
11375 template <typename ForwardIterator>
11376 internal::ParamGenerator<
11377   typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
11378 ValuesIn(ForwardIterator begin, ForwardIterator end) {
11379   typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
11380       ::value_type ParamType;
11381   return internal::ParamGenerator<ParamType>(
11382       new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
11383 }
11384 
11385 template <typename T, size_t N>
11386 internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
11387   return ValuesIn(array, array + N);
11388 }
11389 
11390 template <class Container>
11391 internal::ParamGenerator<typename Container::value_type> ValuesIn(
11392     const Container& container) {
11393   return ValuesIn(container.begin(), container.end());
11394 }
11395 
11396 // Values() allows generating tests from explicitly specified list of
11397 // parameters.
11398 //
11399 // Synopsis:
11400 // Values(T v1, T v2, ..., T vN)
11401 //   - returns a generator producing sequences with elements v1, v2, ..., vN.
11402 //
11403 // For example, this instantiates tests from test suite BarTest each
11404 // with values "one", "two", and "three":
11405 //
11406 // INSTANTIATE_TEST_SUITE_P(NumSequence,
11407 //                          BarTest,
11408 //                          Values("one", "two", "three"));
11409 //
11410 // This instantiates tests from test suite BazTest each with values 1, 2, 3.5.
11411 // The exact type of values will depend on the type of parameter in BazTest.
11412 //
11413 // INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
11414 //
11415 //
11416 template <typename... T>
11417 internal::ValueArray<T...> Values(T... v) {
11418   return internal::ValueArray<T...>(std::move(v)...);
11419 }
11420 
11421 // Bool() allows generating tests with parameters in a set of (false, true).
11422 //
11423 // Synopsis:
11424 // Bool()
11425 //   - returns a generator producing sequences with elements {false, true}.
11426 //
11427 // It is useful when testing code that depends on Boolean flags. Combinations
11428 // of multiple flags can be tested when several Bool()'s are combined using
11429 // Combine() function.
11430 //
11431 // In the following example all tests in the test suite FlagDependentTest
11432 // will be instantiated twice with parameters false and true.
11433 //
11434 // class FlagDependentTest : public testing::TestWithParam<bool> {
11435 //   virtual void SetUp() {
11436 //     external_flag = GetParam();
11437 //   }
11438 // }
11439 // INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
11440 //
11441 inline internal::ParamGenerator<bool> Bool() {
11442   return Values(false, true);
11443 }
11444 
11445 // Combine() allows the user to combine two or more sequences to produce
11446 // values of a Cartesian product of those sequences' elements.
11447 //
11448 // Synopsis:
11449 // Combine(gen1, gen2, ..., genN)
11450 //   - returns a generator producing sequences with elements coming from
11451 //     the Cartesian product of elements from the sequences generated by
11452 //     gen1, gen2, ..., genN. The sequence elements will have a type of
11453 //     std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
11454 //     of elements from sequences produces by gen1, gen2, ..., genN.
11455 //
11456 // Combine can have up to 10 arguments.
11457 //
11458 // Example:
11459 //
11460 // This will instantiate tests in test suite AnimalTest each one with
11461 // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
11462 // tuple("dog", BLACK), and tuple("dog", WHITE):
11463 //
11464 // enum Color { BLACK, GRAY, WHITE };
11465 // class AnimalTest
11466 //     : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
11467 //
11468 // TEST_P(AnimalTest, AnimalLooksNice) {...}
11469 //
11470 // INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
11471 //                          Combine(Values("cat", "dog"),
11472 //                                  Values(BLACK, WHITE)));
11473 //
11474 // This will instantiate tests in FlagDependentTest with all variations of two
11475 // Boolean flags:
11476 //
11477 // class FlagDependentTest
11478 //     : public testing::TestWithParam<std::tuple<bool, bool> > {
11479 //   virtual void SetUp() {
11480 //     // Assigns external_flag_1 and external_flag_2 values from the tuple.
11481 //     std::tie(external_flag_1, external_flag_2) = GetParam();
11482 //   }
11483 // };
11484 //
11485 // TEST_P(FlagDependentTest, TestFeature1) {
11486 //   // Test your code using external_flag_1 and external_flag_2 here.
11487 // }
11488 // INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,
11489 //                          Combine(Bool(), Bool()));
11490 //
11491 template <typename... Generator>
11492 internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
11493   return internal::CartesianProductHolder<Generator...>(g...);
11494 }
11495 
11496 #define TEST_P(test_suite_name, test_name)                                     \
11497   class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)                     \
11498       : public test_suite_name {                                               \
11499    public:                                                                     \
11500     GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {}                    \
11501     virtual void TestBody();                                                   \
11502                                                                                \
11503    private:                                                                    \
11504     static int AddToRegistry() {                                               \
11505       ::testing::UnitTest::GetInstance()                                       \
11506           ->parameterized_test_registry()                                      \
11507           .GetTestSuitePatternHolder<test_suite_name>(                         \
11508               #test_suite_name,                                                \
11509               ::testing::internal::CodeLocation(__FILE__, __LINE__))           \
11510           ->AddTestPattern(                                                    \
11511               GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name),  \
11512               new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
11513                   test_suite_name, test_name)>());                             \
11514       return 0;                                                                \
11515     }                                                                          \
11516     static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_;               \
11517     GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,    \
11518                                                            test_name));        \
11519   };                                                                           \
11520   int GTEST_TEST_CLASS_NAME_(test_suite_name,                                  \
11521                              test_name)::gtest_registering_dummy_ =            \
11522       GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry();     \
11523   void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
11524 
11525 // The last argument to INSTANTIATE_TEST_SUITE_P allows the user to specify
11526 // generator and an optional function or functor that generates custom test name
11527 // suffixes based on the test parameters. Such a function or functor should
11528 // accept one argument of type testing::TestParamInfo<class ParamType>, and
11529 // return std::string.
11530 //
11531 // testing::PrintToStringParamName is a builtin test suffix generator that
11532 // returns the value of testing::PrintToString(GetParam()).
11533 //
11534 // Note: test names must be non-empty, unique, and may only contain ASCII
11535 // alphanumeric characters or underscore. Because PrintToString adds quotes
11536 // to std::string and C strings, it won't work for these types.
11537 
11538 #define GTEST_EXPAND_(arg) arg
11539 #define GTEST_GET_FIRST_(first, ...) first
11540 #define GTEST_GET_SECOND_(first, second, ...) second
11541 
11542 #define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...)                \
11543   static ::testing::internal::ParamGenerator<test_suite_name::ParamType>      \
11544       gtest_##prefix##test_suite_name##_EvalGenerator_() {                    \
11545     return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_));        \
11546   }                                                                           \
11547   static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_(   \
11548       const ::testing::TestParamInfo<test_suite_name::ParamType>& info) {     \
11549     if (::testing::internal::AlwaysFalse()) {                                 \
11550       ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_(      \
11551           __VA_ARGS__,                                                        \
11552           ::testing::internal::DefaultParamName<test_suite_name::ParamType>,  \
11553           DUMMY_PARAM_)));                                                    \
11554       auto t = std::make_tuple(__VA_ARGS__);                                  \
11555       static_assert(std::tuple_size<decltype(t)>::value <= 2,                 \
11556                     "Too Many Args!");                                        \
11557     }                                                                         \
11558     return ((GTEST_EXPAND_(GTEST_GET_SECOND_(                                 \
11559         __VA_ARGS__,                                                          \
11560         ::testing::internal::DefaultParamName<test_suite_name::ParamType>,    \
11561         DUMMY_PARAM_))))(info);                                               \
11562   }                                                                           \
11563   static int gtest_##prefix##test_suite_name##_dummy_                         \
11564       GTEST_ATTRIBUTE_UNUSED_ =                                               \
11565           ::testing::UnitTest::GetInstance()                                  \
11566               ->parameterized_test_registry()                                 \
11567               .GetTestSuitePatternHolder<test_suite_name>(                    \
11568                   #test_suite_name,                                           \
11569                   ::testing::internal::CodeLocation(__FILE__, __LINE__))      \
11570               ->AddTestSuiteInstantiation(                                    \
11571                   #prefix, &gtest_##prefix##test_suite_name##_EvalGenerator_, \
11572                   &gtest_##prefix##test_suite_name##_EvalGenerateName_,       \
11573                   __FILE__, __LINE__)
11574 
11575 // Legacy API is deprecated but still available
11576 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11577 #define INSTANTIATE_TEST_CASE_P                                            \
11578   static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
11579                 "");                                                       \
11580   INSTANTIATE_TEST_SUITE_P
11581 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11582 
11583 }  // namespace testing
11584 
11585 #endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
11586 // Copyright 2006, Google Inc.
11587 // All rights reserved.
11588 //
11589 // Redistribution and use in source and binary forms, with or without
11590 // modification, are permitted provided that the following conditions are
11591 // met:
11592 //
11593 //     * Redistributions of source code must retain the above copyright
11594 // notice, this list of conditions and the following disclaimer.
11595 //     * Redistributions in binary form must reproduce the above
11596 // copyright notice, this list of conditions and the following disclaimer
11597 // in the documentation and/or other materials provided with the
11598 // distribution.
11599 //     * Neither the name of Google Inc. nor the names of its
11600 // contributors may be used to endorse or promote products derived from
11601 // this software without specific prior written permission.
11602 //
11603 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11604 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11605 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11606 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
11607 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11608 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11609 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11610 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11611 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11612 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11613 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11614 
11615 //
11616 // Google C++ Testing and Mocking Framework definitions useful in production code.
11617 // GOOGLETEST_CM0003 DO NOT DELETE
11618 
11619 #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11620 #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11621 
11622 // When you need to test the private or protected members of a class,
11623 // use the FRIEND_TEST macro to declare your tests as friends of the
11624 // class.  For example:
11625 //
11626 // class MyClass {
11627 //  private:
11628 //   void PrivateMethod();
11629 //   FRIEND_TEST(MyClassTest, PrivateMethodWorks);
11630 // };
11631 //
11632 // class MyClassTest : public testing::Test {
11633 //   // ...
11634 // };
11635 //
11636 // TEST_F(MyClassTest, PrivateMethodWorks) {
11637 //   // Can call MyClass::PrivateMethod() here.
11638 // }
11639 //
11640 // Note: The test class must be in the same namespace as the class being tested.
11641 // For example, putting MyClassTest in an anonymous namespace will not work.
11642 
11643 #define FRIEND_TEST(test_case_name, test_name)\
11644 friend class test_case_name##_##test_name##_Test
11645 
11646 #endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11647 // Copyright 2008, Google Inc.
11648 // All rights reserved.
11649 //
11650 // Redistribution and use in source and binary forms, with or without
11651 // modification, are permitted provided that the following conditions are
11652 // met:
11653 //
11654 //     * Redistributions of source code must retain the above copyright
11655 // notice, this list of conditions and the following disclaimer.
11656 //     * Redistributions in binary form must reproduce the above
11657 // copyright notice, this list of conditions and the following disclaimer
11658 // in the documentation and/or other materials provided with the
11659 // distribution.
11660 //     * Neither the name of Google Inc. nor the names of its
11661 // contributors may be used to endorse or promote products derived from
11662 // this software without specific prior written permission.
11663 //
11664 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11665 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11666 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11667 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
11668 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11669 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11670 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11671 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11672 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11673 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11674 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11675 //
11676 // GOOGLETEST_CM0001 DO NOT DELETE
11677 
11678 #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11679 #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11680 
11681 #include <iosfwd>
11682 #include <vector>
11683 
11684 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
11685 /* class A needs to have dll-interface to be used by clients of class B */)
11686 
11687 namespace testing {
11688 
11689 // A copyable object representing the result of a test part (i.e. an
11690 // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
11691 //
11692 // Don't inherit from TestPartResult as its destructor is not virtual.
11693 class GTEST_API_ TestPartResult {
11694  public:
11695   // The possible outcomes of a test part (i.e. an assertion or an
11696   // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
11697   enum Type {
11698     kSuccess,          // Succeeded.
11699     kNonFatalFailure,  // Failed but the test can continue.
11700     kFatalFailure,     // Failed and the test should be terminated.
11701     kSkip              // Skipped.
11702   };
11703 
11704   // C'tor.  TestPartResult does NOT have a default constructor.
11705   // Always use this constructor (with parameters) to create a
11706   // TestPartResult object.
11707   TestPartResult(Type a_type, const char* a_file_name, int a_line_number,
11708                  const char* a_message)
11709       : type_(a_type),
11710         file_name_(a_file_name == nullptr ? "" : a_file_name),
11711         line_number_(a_line_number),
11712         summary_(ExtractSummary(a_message)),
11713         message_(a_message) {}
11714 
11715   // Gets the outcome of the test part.
11716   Type type() const { return type_; }
11717 
11718   // Gets the name of the source file where the test part took place, or
11719   // NULL if it's unknown.
11720   const char* file_name() const {
11721     return file_name_.empty() ? nullptr : file_name_.c_str();
11722   }
11723 
11724   // Gets the line in the source file where the test part took place,
11725   // or -1 if it's unknown.
11726   int line_number() const { return line_number_; }
11727 
11728   // Gets the summary of the failure message.
11729   const char* summary() const { return summary_.c_str(); }
11730 
11731   // Gets the message associated with the test part.
11732   const char* message() const { return message_.c_str(); }
11733 
11734   // Returns true iff the test part was skipped.
11735   bool skipped() const { return type_ == kSkip; }
11736 
11737   // Returns true iff the test part passed.
11738   bool passed() const { return type_ == kSuccess; }
11739 
11740   // Returns true iff the test part non-fatally failed.
11741   bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
11742 
11743   // Returns true iff the test part fatally failed.
11744   bool fatally_failed() const { return type_ == kFatalFailure; }
11745 
11746   // Returns true iff the test part failed.
11747   bool failed() const { return fatally_failed() || nonfatally_failed(); }
11748 
11749  private:
11750   Type type_;
11751 
11752   // Gets the summary of the failure message by omitting the stack
11753   // trace in it.
11754   static std::string ExtractSummary(const char* message);
11755 
11756   // The name of the source file where the test part took place, or
11757   // "" if the source file is unknown.
11758   std::string file_name_;
11759   // The line in the source file where the test part took place, or -1
11760   // if the line number is unknown.
11761   int line_number_;
11762   std::string summary_;  // The test failure summary.
11763   std::string message_;  // The test failure message.
11764 };
11765 
11766 // Prints a TestPartResult object.
11767 std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
11768 
11769 // An array of TestPartResult objects.
11770 //
11771 // Don't inherit from TestPartResultArray as its destructor is not
11772 // virtual.
11773 class GTEST_API_ TestPartResultArray {
11774  public:
11775   TestPartResultArray() {}
11776 
11777   // Appends the given TestPartResult to the array.
11778   void Append(const TestPartResult& result);
11779 
11780   // Returns the TestPartResult at the given index (0-based).
11781   const TestPartResult& GetTestPartResult(int index) const;
11782 
11783   // Returns the number of TestPartResult objects in the array.
11784   int size() const;
11785 
11786  private:
11787   std::vector<TestPartResult> array_;
11788 
11789   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
11790 };
11791 
11792 // This interface knows how to report a test part result.
11793 class GTEST_API_ TestPartResultReporterInterface {
11794  public:
11795   virtual ~TestPartResultReporterInterface() {}
11796 
11797   virtual void ReportTestPartResult(const TestPartResult& result) = 0;
11798 };
11799 
11800 namespace internal {
11801 
11802 // This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
11803 // statement generates new fatal failures. To do so it registers itself as the
11804 // current test part result reporter. Besides checking if fatal failures were
11805 // reported, it only delegates the reporting to the former result reporter.
11806 // The original result reporter is restored in the destructor.
11807 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
11808 class GTEST_API_ HasNewFatalFailureHelper
11809     : public TestPartResultReporterInterface {
11810  public:
11811   HasNewFatalFailureHelper();
11812   ~HasNewFatalFailureHelper() override;
11813   void ReportTestPartResult(const TestPartResult& result) override;
11814   bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
11815  private:
11816   bool has_new_fatal_failure_;
11817   TestPartResultReporterInterface* original_reporter_;
11818 
11819   GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
11820 };
11821 
11822 }  // namespace internal
11823 
11824 }  // namespace testing
11825 
11826 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
11827 
11828 #endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11829 // Copyright 2008 Google Inc.
11830 // All Rights Reserved.
11831 //
11832 // Redistribution and use in source and binary forms, with or without
11833 // modification, are permitted provided that the following conditions are
11834 // met:
11835 //
11836 //     * Redistributions of source code must retain the above copyright
11837 // notice, this list of conditions and the following disclaimer.
11838 //     * Redistributions in binary form must reproduce the above
11839 // copyright notice, this list of conditions and the following disclaimer
11840 // in the documentation and/or other materials provided with the
11841 // distribution.
11842 //     * Neither the name of Google Inc. nor the names of its
11843 // contributors may be used to endorse or promote products derived from
11844 // this software without specific prior written permission.
11845 //
11846 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11847 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11848 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11849 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
11850 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11851 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11852 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11853 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11854 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11855 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11856 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11857 
11858 
11859 // GOOGLETEST_CM0001 DO NOT DELETE
11860 
11861 #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
11862 #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
11863 
11864 // This header implements typed tests and type-parameterized tests.
11865 
11866 // Typed (aka type-driven) tests repeat the same test for types in a
11867 // list.  You must know which types you want to test with when writing
11868 // typed tests. Here's how you do it:
11869 
11870 #if 0
11871 
11872 // First, define a fixture class template.  It should be parameterized
11873 // by a type.  Remember to derive it from testing::Test.
11874 template <typename T>
11875 class FooTest : public testing::Test {
11876  public:
11877   ...
11878   typedef std::list<T> List;
11879   static T shared_;
11880   T value_;
11881 };
11882 
11883 // Next, associate a list of types with the test suite, which will be
11884 // repeated for each type in the list.  The typedef is necessary for
11885 // the macro to parse correctly.
11886 typedef testing::Types<char, int, unsigned int> MyTypes;
11887 TYPED_TEST_SUITE(FooTest, MyTypes);
11888 
11889 // If the type list contains only one type, you can write that type
11890 // directly without Types<...>:
11891 //   TYPED_TEST_SUITE(FooTest, int);
11892 
11893 // Then, use TYPED_TEST() instead of TEST_F() to define as many typed
11894 // tests for this test suite as you want.
11895 TYPED_TEST(FooTest, DoesBlah) {
11896   // Inside a test, refer to TypeParam to get the type parameter.
11897   // Since we are inside a derived class template, C++ requires use to
11898   // visit the members of FooTest via 'this'.
11899   TypeParam n = this->value_;
11900 
11901   // To visit static members of the fixture, add the TestFixture::
11902   // prefix.
11903   n += TestFixture::shared_;
11904 
11905   // To refer to typedefs in the fixture, add the "typename
11906   // TestFixture::" prefix.
11907   typename TestFixture::List values;
11908   values.push_back(n);
11909   ...
11910 }
11911 
11912 TYPED_TEST(FooTest, HasPropertyA) { ... }
11913 
11914 // TYPED_TEST_SUITE takes an optional third argument which allows to specify a
11915 // class that generates custom test name suffixes based on the type. This should
11916 // be a class which has a static template function GetName(int index) returning
11917 // a string for each type. The provided integer index equals the index of the
11918 // type in the provided type list. In many cases the index can be ignored.
11919 //
11920 // For example:
11921 //   class MyTypeNames {
11922 //    public:
11923 //     template <typename T>
11924 //     static std::string GetName(int) {
11925 //       if (std::is_same<T, char>()) return "char";
11926 //       if (std::is_same<T, int>()) return "int";
11927 //       if (std::is_same<T, unsigned int>()) return "unsignedInt";
11928 //     }
11929 //   };
11930 //   TYPED_TEST_SUITE(FooTest, MyTypes, MyTypeNames);
11931 
11932 #endif  // 0
11933 
11934 // Type-parameterized tests are abstract test patterns parameterized
11935 // by a type.  Compared with typed tests, type-parameterized tests
11936 // allow you to define the test pattern without knowing what the type
11937 // parameters are.  The defined pattern can be instantiated with
11938 // different types any number of times, in any number of translation
11939 // units.
11940 //
11941 // If you are designing an interface or concept, you can define a
11942 // suite of type-parameterized tests to verify properties that any
11943 // valid implementation of the interface/concept should have.  Then,
11944 // each implementation can easily instantiate the test suite to verify
11945 // that it conforms to the requirements, without having to write
11946 // similar tests repeatedly.  Here's an example:
11947 
11948 #if 0
11949 
11950 // First, define a fixture class template.  It should be parameterized
11951 // by a type.  Remember to derive it from testing::Test.
11952 template <typename T>
11953 class FooTest : public testing::Test {
11954   ...
11955 };
11956 
11957 // Next, declare that you will define a type-parameterized test suite
11958 // (the _P suffix is for "parameterized" or "pattern", whichever you
11959 // prefer):
11960 TYPED_TEST_SUITE_P(FooTest);
11961 
11962 // Then, use TYPED_TEST_P() to define as many type-parameterized tests
11963 // for this type-parameterized test suite as you want.
11964 TYPED_TEST_P(FooTest, DoesBlah) {
11965   // Inside a test, refer to TypeParam to get the type parameter.
11966   TypeParam n = 0;
11967   ...
11968 }
11969 
11970 TYPED_TEST_P(FooTest, HasPropertyA) { ... }
11971 
11972 // Now the tricky part: you need to register all test patterns before
11973 // you can instantiate them.  The first argument of the macro is the
11974 // test suite name; the rest are the names of the tests in this test
11975 // case.
11976 REGISTER_TYPED_TEST_SUITE_P(FooTest,
11977                             DoesBlah, HasPropertyA);
11978 
11979 // Finally, you are free to instantiate the pattern with the types you
11980 // want.  If you put the above code in a header file, you can #include
11981 // it in multiple C++ source files and instantiate it multiple times.
11982 //
11983 // To distinguish different instances of the pattern, the first
11984 // argument to the INSTANTIATE_* macro is a prefix that will be added
11985 // to the actual test suite name.  Remember to pick unique prefixes for
11986 // different instances.
11987 typedef testing::Types<char, int, unsigned int> MyTypes;
11988 INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
11989 
11990 // If the type list contains only one type, you can write that type
11991 // directly without Types<...>:
11992 //   INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int);
11993 //
11994 // Similar to the optional argument of TYPED_TEST_SUITE above,
11995 // INSTANTIATE_TEST_SUITE_P takes an optional fourth argument which allows to
11996 // generate custom names.
11997 //   INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes, MyTypeNames);
11998 
11999 #endif  // 0
12000 
12001 
12002 // Implements typed tests.
12003 
12004 #if GTEST_HAS_TYPED_TEST
12005 
12006 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12007 //
12008 // Expands to the name of the typedef for the type parameters of the
12009 // given test suite.
12010 #define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_
12011 
12012 // Expands to the name of the typedef for the NameGenerator, responsible for
12013 // creating the suffixes of the name.
12014 #define GTEST_NAME_GENERATOR_(TestSuiteName) \
12015   gtest_type_params_##TestSuiteName##_NameGenerator
12016 
12017 // The 'Types' template argument below must have spaces around it
12018 // since some compilers may choke on '>>' when passing a template
12019 // instance (e.g. Types<int>)
12020 #define TYPED_TEST_SUITE(CaseName, Types, ...)                           \
12021   typedef ::testing::internal::TypeList<Types>::type GTEST_TYPE_PARAMS_( \
12022       CaseName);                                                         \
12023   typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type  \
12024       GTEST_NAME_GENERATOR_(CaseName)
12025 
12026 # define TYPED_TEST(CaseName, TestName)                                       \
12027   template <typename gtest_TypeParam_>                                        \
12028   class GTEST_TEST_CLASS_NAME_(CaseName, TestName)                            \
12029       : public CaseName<gtest_TypeParam_> {                                   \
12030    private:                                                                   \
12031     typedef CaseName<gtest_TypeParam_> TestFixture;                           \
12032     typedef gtest_TypeParam_ TypeParam;                                       \
12033     virtual void TestBody();                                                  \
12034   };                                                                          \
12035   static bool gtest_##CaseName##_##TestName##_registered_                     \
12036         GTEST_ATTRIBUTE_UNUSED_ =                                             \
12037       ::testing::internal::TypeParameterizedTest<                             \
12038           CaseName,                                                           \
12039           ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName,   \
12040                                                                   TestName)>, \
12041           GTEST_TYPE_PARAMS_(                                                 \
12042               CaseName)>::Register("",                                        \
12043                                    ::testing::internal::CodeLocation(         \
12044                                        __FILE__, __LINE__),                   \
12045                                    #CaseName, #TestName, 0,                   \
12046                                    ::testing::internal::GenerateNames<        \
12047                                        GTEST_NAME_GENERATOR_(CaseName),       \
12048                                        GTEST_TYPE_PARAMS_(CaseName)>());      \
12049   template <typename gtest_TypeParam_>                                        \
12050   void GTEST_TEST_CLASS_NAME_(CaseName,                                       \
12051                               TestName)<gtest_TypeParam_>::TestBody()
12052 
12053 // Legacy API is deprecated but still available
12054 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12055 #define TYPED_TEST_CASE                                                \
12056   static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \
12057   TYPED_TEST_SUITE
12058 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12059 
12060 #endif  // GTEST_HAS_TYPED_TEST
12061 
12062 // Implements type-parameterized tests.
12063 
12064 #if GTEST_HAS_TYPED_TEST_P
12065 
12066 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12067 //
12068 // Expands to the namespace name that the type-parameterized tests for
12069 // the given type-parameterized test suite are defined in.  The exact
12070 // name of the namespace is subject to change without notice.
12071 #define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_
12072 
12073 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12074 //
12075 // Expands to the name of the variable used to remember the names of
12076 // the defined tests in the given test suite.
12077 #define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \
12078   gtest_typed_test_suite_p_state_##TestSuiteName##_
12079 
12080 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
12081 //
12082 // Expands to the name of the variable used to remember the names of
12083 // the registered tests in the given test suite.
12084 #define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \
12085   gtest_registered_test_names_##TestSuiteName##_
12086 
12087 // The variables defined in the type-parameterized test macros are
12088 // static as typically these macros are used in a .h file that can be
12089 // #included in multiple translation units linked together.
12090 #define TYPED_TEST_SUITE_P(SuiteName)              \
12091   static ::testing::internal::TypedTestSuitePState \
12092       GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
12093 
12094 // Legacy API is deprecated but still available
12095 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12096 #define TYPED_TEST_CASE_P                                                 \
12097   static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), ""); \
12098   TYPED_TEST_SUITE_P
12099 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12100 
12101 #define TYPED_TEST_P(SuiteName, TestName)                             \
12102   namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                       \
12103     template <typename gtest_TypeParam_>                              \
12104     class TestName : public SuiteName<gtest_TypeParam_> {             \
12105      private:                                                         \
12106       typedef SuiteName<gtest_TypeParam_> TestFixture;                \
12107       typedef gtest_TypeParam_ TypeParam;                             \
12108       virtual void TestBody();                                        \
12109     };                                                                \
12110     static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
12111         GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName(       \
12112             __FILE__, __LINE__, #SuiteName, #TestName);               \
12113   }                                                                   \
12114   template <typename gtest_TypeParam_>                                \
12115   void GTEST_SUITE_NAMESPACE_(                                        \
12116       SuiteName)::TestName<gtest_TypeParam_>::TestBody()
12117 
12118 #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...)                            \
12119   namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                                \
12120     typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
12121   }                                                                            \
12122   static const char* const GTEST_REGISTERED_TEST_NAMES_(                       \
12123       SuiteName) GTEST_ATTRIBUTE_UNUSED_ =                                     \
12124       GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames(    \
12125           __FILE__, __LINE__, #__VA_ARGS__)
12126 
12127 // Legacy API is deprecated but still available
12128 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12129 #define REGISTER_TYPED_TEST_CASE_P                                           \
12130   static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \
12131                 "");                                                         \
12132   REGISTER_TYPED_TEST_SUITE_P
12133 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12134 
12135 // The 'Types' template argument below must have spaces around it
12136 // since some compilers may choke on '>>' when passing a template
12137 // instance (e.g. Types<int>)
12138 #define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...)       \
12139   static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ =        \
12140       ::testing::internal::TypeParameterizedTestSuite<                      \
12141           SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_,    \
12142           ::testing::internal::TypeList<Types>::type>::                     \
12143           Register(#Prefix,                                                 \
12144                    ::testing::internal::CodeLocation(__FILE__, __LINE__),   \
12145                    &GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \
12146                    GTEST_REGISTERED_TEST_NAMES_(SuiteName),                 \
12147                    ::testing::internal::GenerateNames<                      \
12148                        ::testing::internal::NameGeneratorSelector<          \
12149                            __VA_ARGS__>::type,                              \
12150                        ::testing::internal::TypeList<Types>::type>())
12151 
12152 // Legacy API is deprecated but still available
12153 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12154 #define INSTANTIATE_TYPED_TEST_CASE_P                                      \
12155   static_assert(                                                           \
12156       ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), ""); \
12157   INSTANTIATE_TYPED_TEST_SUITE_P
12158 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12159 
12160 #endif  // GTEST_HAS_TYPED_TEST_P
12161 
12162 #endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
12163 
12164 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
12165 /* class A needs to have dll-interface to be used by clients of class B */)
12166 
12167 namespace testing {
12168 
12169 // Silence C4100 (unreferenced formal parameter) and 4805
12170 // unsafe mix of type 'const int' and type 'const bool'
12171 #ifdef _MSC_VER
12172 # pragma warning(push)
12173 # pragma warning(disable:4805)
12174 # pragma warning(disable:4100)
12175 #endif
12176 
12177 
12178 // Declares the flags.
12179 
12180 // This flag temporary enables the disabled tests.
12181 GTEST_DECLARE_bool_(also_run_disabled_tests);
12182 
12183 // This flag brings the debugger on an assertion failure.
12184 GTEST_DECLARE_bool_(break_on_failure);
12185 
12186 // This flag controls whether Google Test catches all test-thrown exceptions
12187 // and logs them as failures.
12188 GTEST_DECLARE_bool_(catch_exceptions);
12189 
12190 // This flag enables using colors in terminal output. Available values are
12191 // "yes" to enable colors, "no" (disable colors), or "auto" (the default)
12192 // to let Google Test decide.
12193 GTEST_DECLARE_string_(color);
12194 
12195 // This flag sets up the filter to select by name using a glob pattern
12196 // the tests to run. If the filter is not given all tests are executed.
12197 GTEST_DECLARE_string_(filter);
12198 
12199 // This flag controls whether Google Test installs a signal handler that dumps
12200 // debugging information when fatal signals are raised.
12201 GTEST_DECLARE_bool_(install_failure_signal_handler);
12202 
12203 // This flag causes the Google Test to list tests. None of the tests listed
12204 // are actually run if the flag is provided.
12205 GTEST_DECLARE_bool_(list_tests);
12206 
12207 // This flag controls whether Google Test emits a detailed XML report to a file
12208 // in addition to its normal textual output.
12209 GTEST_DECLARE_string_(output);
12210 
12211 // This flags control whether Google Test prints the elapsed time for each
12212 // test.
12213 GTEST_DECLARE_bool_(print_time);
12214 
12215 // This flags control whether Google Test prints UTF8 characters as text.
12216 GTEST_DECLARE_bool_(print_utf8);
12217 
12218 // This flag specifies the random number seed.
12219 GTEST_DECLARE_int32_(random_seed);
12220 
12221 // This flag sets how many times the tests are repeated. The default value
12222 // is 1. If the value is -1 the tests are repeating forever.
12223 GTEST_DECLARE_int32_(repeat);
12224 
12225 // This flag controls whether Google Test includes Google Test internal
12226 // stack frames in failure stack traces.
12227 GTEST_DECLARE_bool_(show_internal_stack_frames);
12228 
12229 // When this flag is specified, tests' order is randomized on every iteration.
12230 GTEST_DECLARE_bool_(shuffle);
12231 
12232 // This flag specifies the maximum number of stack frames to be
12233 // printed in a failure message.
12234 GTEST_DECLARE_int32_(stack_trace_depth);
12235 
12236 // When this flag is specified, a failed assertion will throw an
12237 // exception if exceptions are enabled, or exit the program with a
12238 // non-zero code otherwise. For use with an external test framework.
12239 GTEST_DECLARE_bool_(throw_on_failure);
12240 
12241 // When this flag is set with a "host:port" string, on supported
12242 // platforms test results are streamed to the specified port on
12243 // the specified host machine.
12244 GTEST_DECLARE_string_(stream_result_to);
12245 
12246 #if GTEST_USE_OWN_FLAGFILE_FLAG_
12247 GTEST_DECLARE_string_(flagfile);
12248 #endif  // GTEST_USE_OWN_FLAGFILE_FLAG_
12249 
12250 // The upper limit for valid stack trace depths.
12251 const int kMaxStackTraceDepth = 100;
12252 
12253 namespace internal {
12254 
12255 class AssertHelper;
12256 class DefaultGlobalTestPartResultReporter;
12257 class ExecDeathTest;
12258 class NoExecDeathTest;
12259 class FinalSuccessChecker;
12260 class GTestFlagSaver;
12261 class StreamingListenerTest;
12262 class TestResultAccessor;
12263 class TestEventListenersAccessor;
12264 class TestEventRepeater;
12265 class UnitTestRecordPropertyTestHelper;
12266 class WindowsDeathTest;
12267 class FuchsiaDeathTest;
12268 class UnitTestImpl* GetUnitTestImpl();
12269 void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
12270                                     const std::string& message);
12271 
12272 }  // namespace internal
12273 
12274 // The friend relationship of some of these classes is cyclic.
12275 // If we don't forward declare them the compiler might confuse the classes
12276 // in friendship clauses with same named classes on the scope.
12277 class Test;
12278 class TestSuite;
12279 
12280 // Old API is still available but deprecated
12281 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12282 using TestCase = TestSuite;
12283 #endif
12284 class TestInfo;
12285 class UnitTest;
12286 
12287 // A class for indicating whether an assertion was successful.  When
12288 // the assertion wasn't successful, the AssertionResult object
12289 // remembers a non-empty message that describes how it failed.
12290 //
12291 // To create an instance of this class, use one of the factory functions
12292 // (AssertionSuccess() and AssertionFailure()).
12293 //
12294 // This class is useful for two purposes:
12295 //   1. Defining predicate functions to be used with Boolean test assertions
12296 //      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
12297 //   2. Defining predicate-format functions to be
12298 //      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
12299 //
12300 // For example, if you define IsEven predicate:
12301 //
12302 //   testing::AssertionResult IsEven(int n) {
12303 //     if ((n % 2) == 0)
12304 //       return testing::AssertionSuccess();
12305 //     else
12306 //       return testing::AssertionFailure() << n << " is odd";
12307 //   }
12308 //
12309 // Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
12310 // will print the message
12311 //
12312 //   Value of: IsEven(Fib(5))
12313 //     Actual: false (5 is odd)
12314 //   Expected: true
12315 //
12316 // instead of a more opaque
12317 //
12318 //   Value of: IsEven(Fib(5))
12319 //     Actual: false
12320 //   Expected: true
12321 //
12322 // in case IsEven is a simple Boolean predicate.
12323 //
12324 // If you expect your predicate to be reused and want to support informative
12325 // messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
12326 // about half as often as positive ones in our tests), supply messages for
12327 // both success and failure cases:
12328 //
12329 //   testing::AssertionResult IsEven(int n) {
12330 //     if ((n % 2) == 0)
12331 //       return testing::AssertionSuccess() << n << " is even";
12332 //     else
12333 //       return testing::AssertionFailure() << n << " is odd";
12334 //   }
12335 //
12336 // Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
12337 //
12338 //   Value of: IsEven(Fib(6))
12339 //     Actual: true (8 is even)
12340 //   Expected: false
12341 //
12342 // NB: Predicates that support negative Boolean assertions have reduced
12343 // performance in positive ones so be careful not to use them in tests
12344 // that have lots (tens of thousands) of positive Boolean assertions.
12345 //
12346 // To use this class with EXPECT_PRED_FORMAT assertions such as:
12347 //
12348 //   // Verifies that Foo() returns an even number.
12349 //   EXPECT_PRED_FORMAT1(IsEven, Foo());
12350 //
12351 // you need to define:
12352 //
12353 //   testing::AssertionResult IsEven(const char* expr, int n) {
12354 //     if ((n % 2) == 0)
12355 //       return testing::AssertionSuccess();
12356 //     else
12357 //       return testing::AssertionFailure()
12358 //         << "Expected: " << expr << " is even\n  Actual: it's " << n;
12359 //   }
12360 //
12361 // If Foo() returns 5, you will see the following message:
12362 //
12363 //   Expected: Foo() is even
12364 //     Actual: it's 5
12365 //
12366 class GTEST_API_ AssertionResult {
12367  public:
12368   // Copy constructor.
12369   // Used in EXPECT_TRUE/FALSE(assertion_result).
12370   AssertionResult(const AssertionResult& other);
12371 
12372 #if defined(_MSC_VER) && _MSC_VER < 1910
12373   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
12374 #endif
12375 
12376   // Used in the EXPECT_TRUE/FALSE(bool_expression).
12377   //
12378   // T must be contextually convertible to bool.
12379   //
12380   // The second parameter prevents this overload from being considered if
12381   // the argument is implicitly convertible to AssertionResult. In that case
12382   // we want AssertionResult's copy constructor to be used.
12383   template <typename T>
12384   explicit AssertionResult(
12385       const T& success,
12386       typename internal::EnableIf<
12387           !std::is_convertible<T, AssertionResult>::value>::type*
12388       /*enabler*/
12389       = nullptr)
12390       : success_(success) {}
12391 
12392 #if defined(_MSC_VER) && _MSC_VER < 1910
12393   GTEST_DISABLE_MSC_WARNINGS_POP_()
12394 #endif
12395 
12396   // Assignment operator.
12397   AssertionResult& operator=(AssertionResult other) {
12398     swap(other);
12399     return *this;
12400   }
12401 
12402   // Returns true iff the assertion succeeded.
12403   operator bool() const { return success_; }  // NOLINT
12404 
12405   // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
12406   AssertionResult operator!() const;
12407 
12408   // Returns the text streamed into this AssertionResult. Test assertions
12409   // use it when they fail (i.e., the predicate's outcome doesn't match the
12410   // assertion's expectation). When nothing has been streamed into the
12411   // object, returns an empty string.
12412   const char* message() const {
12413     return message_.get() != nullptr ? message_->c_str() : "";
12414   }
12415   // Deprecated; please use message() instead.
12416   const char* failure_message() const { return message(); }
12417 
12418   // Streams a custom failure message into this object.
12419   template <typename T> AssertionResult& operator<<(const T& value) {
12420     AppendMessage(Message() << value);
12421     return *this;
12422   }
12423 
12424   // Allows streaming basic output manipulators such as endl or flush into
12425   // this object.
12426   AssertionResult& operator<<(
12427       ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
12428     AppendMessage(Message() << basic_manipulator);
12429     return *this;
12430   }
12431 
12432  private:
12433   // Appends the contents of message to message_.
12434   void AppendMessage(const Message& a_message) {
12435     if (message_.get() == nullptr) message_.reset(new ::std::string);
12436     message_->append(a_message.GetString().c_str());
12437   }
12438 
12439   // Swap the contents of this AssertionResult with other.
12440   void swap(AssertionResult& other);
12441 
12442   // Stores result of the assertion predicate.
12443   bool success_;
12444   // Stores the message describing the condition in case the expectation
12445   // construct is not satisfied with the predicate's outcome.
12446   // Referenced via a pointer to avoid taking too much stack frame space
12447   // with test assertions.
12448   std::unique_ptr< ::std::string> message_;
12449 };
12450 
12451 // Makes a successful assertion result.
12452 GTEST_API_ AssertionResult AssertionSuccess();
12453 
12454 // Makes a failed assertion result.
12455 GTEST_API_ AssertionResult AssertionFailure();
12456 
12457 // Makes a failed assertion result with the given failure message.
12458 // Deprecated; use AssertionFailure() << msg.
12459 GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
12460 
12461 }  // namespace testing
12462 
12463 // Includes the auto-generated header that implements a family of generic
12464 // predicate assertion macros. This include comes late because it relies on
12465 // APIs declared above.
12466 // Copyright 2006, Google Inc.
12467 // All rights reserved.
12468 //
12469 // Redistribution and use in source and binary forms, with or without
12470 // modification, are permitted provided that the following conditions are
12471 // met:
12472 //
12473 //     * Redistributions of source code must retain the above copyright
12474 // notice, this list of conditions and the following disclaimer.
12475 //     * Redistributions in binary form must reproduce the above
12476 // copyright notice, this list of conditions and the following disclaimer
12477 // in the documentation and/or other materials provided with the
12478 // distribution.
12479 //     * Neither the name of Google Inc. nor the names of its
12480 // contributors may be used to endorse or promote products derived from
12481 // this software without specific prior written permission.
12482 //
12483 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12484 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
12485 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12486 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12487 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12488 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12489 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12490 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12491 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12492 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12493 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12494 
12495 // This file is AUTOMATICALLY GENERATED on 01/02/2019 by command
12496 // 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
12497 //
12498 // Implements a family of generic predicate assertion macros.
12499 // GOOGLETEST_CM0001 DO NOT DELETE
12500 
12501 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
12502 #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
12503 
12504 
12505 namespace testing {
12506 
12507 // This header implements a family of generic predicate assertion
12508 // macros:
12509 //
12510 //   ASSERT_PRED_FORMAT1(pred_format, v1)
12511 //   ASSERT_PRED_FORMAT2(pred_format, v1, v2)
12512 //   ...
12513 //
12514 // where pred_format is a function or functor that takes n (in the
12515 // case of ASSERT_PRED_FORMATn) values and their source expression
12516 // text, and returns a testing::AssertionResult.  See the definition
12517 // of ASSERT_EQ in gtest.h for an example.
12518 //
12519 // If you don't care about formatting, you can use the more
12520 // restrictive version:
12521 //
12522 //   ASSERT_PRED1(pred, v1)
12523 //   ASSERT_PRED2(pred, v1, v2)
12524 //   ...
12525 //
12526 // where pred is an n-ary function or functor that returns bool,
12527 // and the values v1, v2, ..., must support the << operator for
12528 // streaming to std::ostream.
12529 //
12530 // We also define the EXPECT_* variations.
12531 //
12532 // For now we only support predicates whose arity is at most 5.
12533 // Please email googletestframework@googlegroups.com if you need
12534 // support for higher arities.
12535 
12536 // GTEST_ASSERT_ is the basic statement to which all of the assertions
12537 // in this file reduce.  Don't use this in your code.
12538 
12539 #define GTEST_ASSERT_(expression, on_failure) \
12540   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
12541   if (const ::testing::AssertionResult gtest_ar = (expression)) \
12542     ; \
12543   else \
12544     on_failure(gtest_ar.failure_message())
12545 
12546 
12547 // Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use
12548 // this in your code.
12549 template <typename Pred,
12550           typename T1>
12551 AssertionResult AssertPred1Helper(const char* pred_text,
12552                                   const char* e1,
12553                                   Pred pred,
12554                                   const T1& v1) {
12555   if (pred(v1)) return AssertionSuccess();
12556 
12557   return AssertionFailure()
12558          << pred_text << "(" << e1 << ") evaluates to false, where"
12559          << "\n"
12560          << e1 << " evaluates to " << ::testing::PrintToString(v1);
12561 }
12562 
12563 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
12564 // Don't use this in your code.
12565 #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
12566   GTEST_ASSERT_(pred_format(#v1, v1), \
12567                 on_failure)
12568 
12569 // Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use
12570 // this in your code.
12571 #define GTEST_PRED1_(pred, v1, on_failure)\
12572   GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
12573                                              #v1, \
12574                                              pred, \
12575                                              v1), on_failure)
12576 
12577 // Unary predicate assertion macros.
12578 #define EXPECT_PRED_FORMAT1(pred_format, v1) \
12579   GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
12580 #define EXPECT_PRED1(pred, v1) \
12581   GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
12582 #define ASSERT_PRED_FORMAT1(pred_format, v1) \
12583   GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
12584 #define ASSERT_PRED1(pred, v1) \
12585   GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
12586 
12587 
12588 
12589 // Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use
12590 // this in your code.
12591 template <typename Pred,
12592           typename T1,
12593           typename T2>
12594 AssertionResult AssertPred2Helper(const char* pred_text,
12595                                   const char* e1,
12596                                   const char* e2,
12597                                   Pred pred,
12598                                   const T1& v1,
12599                                   const T2& v2) {
12600   if (pred(v1, v2)) return AssertionSuccess();
12601 
12602   return AssertionFailure()
12603          << pred_text << "(" << e1 << ", " << e2
12604          << ") evaluates to false, where"
12605          << "\n"
12606          << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12607          << e2 << " evaluates to " << ::testing::PrintToString(v2);
12608 }
12609 
12610 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
12611 // Don't use this in your code.
12612 #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
12613   GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
12614                 on_failure)
12615 
12616 // Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use
12617 // this in your code.
12618 #define GTEST_PRED2_(pred, v1, v2, on_failure)\
12619   GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
12620                                              #v1, \
12621                                              #v2, \
12622                                              pred, \
12623                                              v1, \
12624                                              v2), on_failure)
12625 
12626 // Binary predicate assertion macros.
12627 #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
12628   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
12629 #define EXPECT_PRED2(pred, v1, v2) \
12630   GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
12631 #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
12632   GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
12633 #define ASSERT_PRED2(pred, v1, v2) \
12634   GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
12635 
12636 
12637 
12638 // Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use
12639 // this in your code.
12640 template <typename Pred,
12641           typename T1,
12642           typename T2,
12643           typename T3>
12644 AssertionResult AssertPred3Helper(const char* pred_text,
12645                                   const char* e1,
12646                                   const char* e2,
12647                                   const char* e3,
12648                                   Pred pred,
12649                                   const T1& v1,
12650                                   const T2& v2,
12651                                   const T3& v3) {
12652   if (pred(v1, v2, v3)) return AssertionSuccess();
12653 
12654   return AssertionFailure()
12655          << pred_text << "(" << e1 << ", " << e2 << ", " << e3
12656          << ") evaluates to false, where"
12657          << "\n"
12658          << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12659          << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12660          << e3 << " evaluates to " << ::testing::PrintToString(v3);
12661 }
12662 
12663 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
12664 // Don't use this in your code.
12665 #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
12666   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
12667                 on_failure)
12668 
12669 // Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use
12670 // this in your code.
12671 #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
12672   GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
12673                                              #v1, \
12674                                              #v2, \
12675                                              #v3, \
12676                                              pred, \
12677                                              v1, \
12678                                              v2, \
12679                                              v3), on_failure)
12680 
12681 // Ternary predicate assertion macros.
12682 #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
12683   GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
12684 #define EXPECT_PRED3(pred, v1, v2, v3) \
12685   GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
12686 #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
12687   GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
12688 #define ASSERT_PRED3(pred, v1, v2, v3) \
12689   GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
12690 
12691 
12692 
12693 // Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use
12694 // this in your code.
12695 template <typename Pred,
12696           typename T1,
12697           typename T2,
12698           typename T3,
12699           typename T4>
12700 AssertionResult AssertPred4Helper(const char* pred_text,
12701                                   const char* e1,
12702                                   const char* e2,
12703                                   const char* e3,
12704                                   const char* e4,
12705                                   Pred pred,
12706                                   const T1& v1,
12707                                   const T2& v2,
12708                                   const T3& v3,
12709                                   const T4& v4) {
12710   if (pred(v1, v2, v3, v4)) return AssertionSuccess();
12711 
12712   return AssertionFailure()
12713          << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
12714          << ") evaluates to false, where"
12715          << "\n"
12716          << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12717          << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12718          << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
12719          << e4 << " evaluates to " << ::testing::PrintToString(v4);
12720 }
12721 
12722 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
12723 // Don't use this in your code.
12724 #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
12725   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
12726                 on_failure)
12727 
12728 // Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use
12729 // this in your code.
12730 #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
12731   GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
12732                                              #v1, \
12733                                              #v2, \
12734                                              #v3, \
12735                                              #v4, \
12736                                              pred, \
12737                                              v1, \
12738                                              v2, \
12739                                              v3, \
12740                                              v4), on_failure)
12741 
12742 // 4-ary predicate assertion macros.
12743 #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
12744   GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
12745 #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
12746   GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
12747 #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
12748   GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
12749 #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
12750   GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
12751 
12752 
12753 
12754 // Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use
12755 // this in your code.
12756 template <typename Pred,
12757           typename T1,
12758           typename T2,
12759           typename T3,
12760           typename T4,
12761           typename T5>
12762 AssertionResult AssertPred5Helper(const char* pred_text,
12763                                   const char* e1,
12764                                   const char* e2,
12765                                   const char* e3,
12766                                   const char* e4,
12767                                   const char* e5,
12768                                   Pred pred,
12769                                   const T1& v1,
12770                                   const T2& v2,
12771                                   const T3& v3,
12772                                   const T4& v4,
12773                                   const T5& v5) {
12774   if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
12775 
12776   return AssertionFailure()
12777          << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
12778          << ", " << e5 << ") evaluates to false, where"
12779          << "\n"
12780          << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12781          << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12782          << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
12783          << e4 << " evaluates to " << ::testing::PrintToString(v4) << "\n"
12784          << e5 << " evaluates to " << ::testing::PrintToString(v5);
12785 }
12786 
12787 // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
12788 // Don't use this in your code.
12789 #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
12790   GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
12791                 on_failure)
12792 
12793 // Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use
12794 // this in your code.
12795 #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
12796   GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
12797                                              #v1, \
12798                                              #v2, \
12799                                              #v3, \
12800                                              #v4, \
12801                                              #v5, \
12802                                              pred, \
12803                                              v1, \
12804                                              v2, \
12805                                              v3, \
12806                                              v4, \
12807                                              v5), on_failure)
12808 
12809 // 5-ary predicate assertion macros.
12810 #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
12811   GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
12812 #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
12813   GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
12814 #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
12815   GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
12816 #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
12817   GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
12818 
12819 
12820 
12821 }  // namespace testing
12822 
12823 #endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
12824 
12825 namespace testing {
12826 
12827 // The abstract class that all tests inherit from.
12828 //
12829 // In Google Test, a unit test program contains one or many TestSuites, and
12830 // each TestSuite contains one or many Tests.
12831 //
12832 // When you define a test using the TEST macro, you don't need to
12833 // explicitly derive from Test - the TEST macro automatically does
12834 // this for you.
12835 //
12836 // The only time you derive from Test is when defining a test fixture
12837 // to be used in a TEST_F.  For example:
12838 //
12839 //   class FooTest : public testing::Test {
12840 //    protected:
12841 //     void SetUp() override { ... }
12842 //     void TearDown() override { ... }
12843 //     ...
12844 //   };
12845 //
12846 //   TEST_F(FooTest, Bar) { ... }
12847 //   TEST_F(FooTest, Baz) { ... }
12848 //
12849 // Test is not copyable.
12850 class GTEST_API_ Test {
12851  public:
12852   friend class TestInfo;
12853 
12854   // The d'tor is virtual as we intend to inherit from Test.
12855   virtual ~Test();
12856 
12857   // Sets up the stuff shared by all tests in this test case.
12858   //
12859   // Google Test will call Foo::SetUpTestSuite() before running the first
12860   // test in test case Foo.  Hence a sub-class can define its own
12861   // SetUpTestSuite() method to shadow the one defined in the super
12862   // class.
12863   static void SetUpTestSuite() {}
12864 
12865   // Tears down the stuff shared by all tests in this test case.
12866   //
12867   // Google Test will call Foo::TearDownTestSuite() after running the last
12868   // test in test case Foo.  Hence a sub-class can define its own
12869   // TearDownTestSuite() method to shadow the one defined in the super
12870   // class.
12871   static void TearDownTestSuite() {}
12872 
12873   // Legacy API is deprecated but still available
12874 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12875   static void TearDownTestCase() {}
12876   static void SetUpTestCase() {}
12877 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12878 
12879   // Returns true iff the current test has a fatal failure.
12880   static bool HasFatalFailure();
12881 
12882   // Returns true iff the current test has a non-fatal failure.
12883   static bool HasNonfatalFailure();
12884 
12885   // Returns true iff the current test was skipped.
12886   static bool IsSkipped();
12887 
12888   // Returns true iff the current test has a (either fatal or
12889   // non-fatal) failure.
12890   static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
12891 
12892   // Logs a property for the current test, test suite, or for the entire
12893   // invocation of the test program when used outside of the context of a
12894   // test suite.  Only the last value for a given key is remembered.  These
12895   // are public static so they can be called from utility functions that are
12896   // not members of the test fixture.  Calls to RecordProperty made during
12897   // lifespan of the test (from the moment its constructor starts to the
12898   // moment its destructor finishes) will be output in XML as attributes of
12899   // the <testcase> element.  Properties recorded from fixture's
12900   // SetUpTestSuite or TearDownTestSuite are logged as attributes of the
12901   // corresponding <testsuite> element.  Calls to RecordProperty made in the
12902   // global context (before or after invocation of RUN_ALL_TESTS and from
12903   // SetUp/TearDown method of Environment objects registered with Google
12904   // Test) will be output as attributes of the <testsuites> element.
12905   static void RecordProperty(const std::string& key, const std::string& value);
12906   static void RecordProperty(const std::string& key, int value);
12907 
12908  protected:
12909   // Creates a Test object.
12910   Test();
12911 
12912   // Sets up the test fixture.
12913   virtual void SetUp();
12914 
12915   // Tears down the test fixture.
12916   virtual void TearDown();
12917 
12918  private:
12919   // Returns true iff the current test has the same fixture class as
12920   // the first test in the current test suite.
12921   static bool HasSameFixtureClass();
12922 
12923   // Runs the test after the test fixture has been set up.
12924   //
12925   // A sub-class must implement this to define the test logic.
12926   //
12927   // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
12928   // Instead, use the TEST or TEST_F macro.
12929   virtual void TestBody() = 0;
12930 
12931   // Sets up, executes, and tears down the test.
12932   void Run();
12933 
12934   // Deletes self.  We deliberately pick an unusual name for this
12935   // internal method to avoid clashing with names used in user TESTs.
12936   void DeleteSelf_() { delete this; }
12937 
12938   const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
12939 
12940   // Often a user misspells SetUp() as Setup() and spends a long time
12941   // wondering why it is never called by Google Test.  The declaration of
12942   // the following method is solely for catching such an error at
12943   // compile time:
12944   //
12945   //   - The return type is deliberately chosen to be not void, so it
12946   //   will be a conflict if void Setup() is declared in the user's
12947   //   test fixture.
12948   //
12949   //   - This method is private, so it will be another compiler error
12950   //   if the method is called from the user's test fixture.
12951   //
12952   // DO NOT OVERRIDE THIS FUNCTION.
12953   //
12954   // If you see an error about overriding the following function or
12955   // about it being private, you have mis-spelled SetUp() as Setup().
12956   struct Setup_should_be_spelled_SetUp {};
12957   virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
12958 
12959   // We disallow copying Tests.
12960   GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
12961 };
12962 
12963 typedef internal::TimeInMillis TimeInMillis;
12964 
12965 // A copyable object representing a user specified test property which can be
12966 // output as a key/value string pair.
12967 //
12968 // Don't inherit from TestProperty as its destructor is not virtual.
12969 class TestProperty {
12970  public:
12971   // C'tor.  TestProperty does NOT have a default constructor.
12972   // Always use this constructor (with parameters) to create a
12973   // TestProperty object.
12974   TestProperty(const std::string& a_key, const std::string& a_value) :
12975     key_(a_key), value_(a_value) {
12976   }
12977 
12978   // Gets the user supplied key.
12979   const char* key() const {
12980     return key_.c_str();
12981   }
12982 
12983   // Gets the user supplied value.
12984   const char* value() const {
12985     return value_.c_str();
12986   }
12987 
12988   // Sets a new value, overriding the one supplied in the constructor.
12989   void SetValue(const std::string& new_value) {
12990     value_ = new_value;
12991   }
12992 
12993  private:
12994   // The key supplied by the user.
12995   std::string key_;
12996   // The value supplied by the user.
12997   std::string value_;
12998 };
12999 
13000 // The result of a single Test.  This includes a list of
13001 // TestPartResults, a list of TestProperties, a count of how many
13002 // death tests there are in the Test, and how much time it took to run
13003 // the Test.
13004 //
13005 // TestResult is not copyable.
13006 class GTEST_API_ TestResult {
13007  public:
13008   // Creates an empty TestResult.
13009   TestResult();
13010 
13011   // D'tor.  Do not inherit from TestResult.
13012   ~TestResult();
13013 
13014   // Gets the number of all test parts.  This is the sum of the number
13015   // of successful test parts and the number of failed test parts.
13016   int total_part_count() const;
13017 
13018   // Returns the number of the test properties.
13019   int test_property_count() const;
13020 
13021   // Returns true iff the test passed (i.e. no test part failed).
13022   bool Passed() const { return !Skipped() && !Failed(); }
13023 
13024   // Returns true iff the test was skipped.
13025   bool Skipped() const;
13026 
13027   // Returns true iff the test failed.
13028   bool Failed() const;
13029 
13030   // Returns true iff the test fatally failed.
13031   bool HasFatalFailure() const;
13032 
13033   // Returns true iff the test has a non-fatal failure.
13034   bool HasNonfatalFailure() const;
13035 
13036   // Returns the elapsed time, in milliseconds.
13037   TimeInMillis elapsed_time() const { return elapsed_time_; }
13038 
13039   // Returns the i-th test part result among all the results. i can range from 0
13040   // to total_part_count() - 1. If i is not in that range, aborts the program.
13041   const TestPartResult& GetTestPartResult(int i) const;
13042 
13043   // Returns the i-th test property. i can range from 0 to
13044   // test_property_count() - 1. If i is not in that range, aborts the
13045   // program.
13046   const TestProperty& GetTestProperty(int i) const;
13047 
13048  private:
13049   friend class TestInfo;
13050   friend class TestSuite;
13051   friend class UnitTest;
13052   friend class internal::DefaultGlobalTestPartResultReporter;
13053   friend class internal::ExecDeathTest;
13054   friend class internal::TestResultAccessor;
13055   friend class internal::UnitTestImpl;
13056   friend class internal::WindowsDeathTest;
13057   friend class internal::FuchsiaDeathTest;
13058 
13059   // Gets the vector of TestPartResults.
13060   const std::vector<TestPartResult>& test_part_results() const {
13061     return test_part_results_;
13062   }
13063 
13064   // Gets the vector of TestProperties.
13065   const std::vector<TestProperty>& test_properties() const {
13066     return test_properties_;
13067   }
13068 
13069   // Sets the elapsed time.
13070   void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
13071 
13072   // Adds a test property to the list. The property is validated and may add
13073   // a non-fatal failure if invalid (e.g., if it conflicts with reserved
13074   // key names). If a property is already recorded for the same key, the
13075   // value will be updated, rather than storing multiple values for the same
13076   // key.  xml_element specifies the element for which the property is being
13077   // recorded and is used for validation.
13078   void RecordProperty(const std::string& xml_element,
13079                       const TestProperty& test_property);
13080 
13081   // Adds a failure if the key is a reserved attribute of Google Test
13082   // testsuite tags.  Returns true if the property is valid.
13083   // FIXME: Validate attribute names are legal and human readable.
13084   static bool ValidateTestProperty(const std::string& xml_element,
13085                                    const TestProperty& test_property);
13086 
13087   // Adds a test part result to the list.
13088   void AddTestPartResult(const TestPartResult& test_part_result);
13089 
13090   // Returns the death test count.
13091   int death_test_count() const { return death_test_count_; }
13092 
13093   // Increments the death test count, returning the new count.
13094   int increment_death_test_count() { return ++death_test_count_; }
13095 
13096   // Clears the test part results.
13097   void ClearTestPartResults();
13098 
13099   // Clears the object.
13100   void Clear();
13101 
13102   // Protects mutable state of the property vector and of owned
13103   // properties, whose values may be updated.
13104   internal::Mutex test_properites_mutex_;
13105 
13106   // The vector of TestPartResults
13107   std::vector<TestPartResult> test_part_results_;
13108   // The vector of TestProperties
13109   std::vector<TestProperty> test_properties_;
13110   // Running count of death tests.
13111   int death_test_count_;
13112   // The elapsed time, in milliseconds.
13113   TimeInMillis elapsed_time_;
13114 
13115   // We disallow copying TestResult.
13116   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
13117 };  // class TestResult
13118 
13119 // A TestInfo object stores the following information about a test:
13120 //
13121 //   Test suite name
13122 //   Test name
13123 //   Whether the test should be run
13124 //   A function pointer that creates the test object when invoked
13125 //   Test result
13126 //
13127 // The constructor of TestInfo registers itself with the UnitTest
13128 // singleton such that the RUN_ALL_TESTS() macro knows which tests to
13129 // run.
13130 class GTEST_API_ TestInfo {
13131  public:
13132   // Destructs a TestInfo object.  This function is not virtual, so
13133   // don't inherit from TestInfo.
13134   ~TestInfo();
13135 
13136   // Returns the test suite name.
13137   const char* test_suite_name() const { return test_suite_name_.c_str(); }
13138 
13139 // Legacy API is deprecated but still available
13140 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13141   const char* test_case_name() const { return test_suite_name(); }
13142 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13143 
13144   // Returns the test name.
13145   const char* name() const { return name_.c_str(); }
13146 
13147   // Returns the name of the parameter type, or NULL if this is not a typed
13148   // or a type-parameterized test.
13149   const char* type_param() const {
13150     if (type_param_.get() != nullptr) return type_param_->c_str();
13151     return nullptr;
13152   }
13153 
13154   // Returns the text representation of the value parameter, or NULL if this
13155   // is not a value-parameterized test.
13156   const char* value_param() const {
13157     if (value_param_.get() != nullptr) return value_param_->c_str();
13158     return nullptr;
13159   }
13160 
13161   // Returns the file name where this test is defined.
13162   const char* file() const { return location_.file.c_str(); }
13163 
13164   // Returns the line where this test is defined.
13165   int line() const { return location_.line; }
13166 
13167   // Return true if this test should not be run because it's in another shard.
13168   bool is_in_another_shard() const { return is_in_another_shard_; }
13169 
13170   // Returns true if this test should run, that is if the test is not
13171   // disabled (or it is disabled but the also_run_disabled_tests flag has
13172   // been specified) and its full name matches the user-specified filter.
13173   //
13174   // Google Test allows the user to filter the tests by their full names.
13175   // The full name of a test Bar in test suite Foo is defined as
13176   // "Foo.Bar".  Only the tests that match the filter will run.
13177   //
13178   // A filter is a colon-separated list of glob (not regex) patterns,
13179   // optionally followed by a '-' and a colon-separated list of
13180   // negative patterns (tests to exclude).  A test is run if it
13181   // matches one of the positive patterns and does not match any of
13182   // the negative patterns.
13183   //
13184   // For example, *A*:Foo.* is a filter that matches any string that
13185   // contains the character 'A' or starts with "Foo.".
13186   bool should_run() const { return should_run_; }
13187 
13188   // Returns true iff this test will appear in the XML report.
13189   bool is_reportable() const {
13190     // The XML report includes tests matching the filter, excluding those
13191     // run in other shards.
13192     return matches_filter_ && !is_in_another_shard_;
13193   }
13194 
13195   // Returns the result of the test.
13196   const TestResult* result() const { return &result_; }
13197 
13198  private:
13199 #if GTEST_HAS_DEATH_TEST
13200   friend class internal::DefaultDeathTestFactory;
13201 #endif  // GTEST_HAS_DEATH_TEST
13202   friend class Test;
13203   friend class TestSuite;
13204   friend class internal::UnitTestImpl;
13205   friend class internal::StreamingListenerTest;
13206   friend TestInfo* internal::MakeAndRegisterTestInfo(
13207       const char* test_suite_name, const char* name, const char* type_param,
13208       const char* value_param, internal::CodeLocation code_location,
13209       internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
13210       internal::TearDownTestSuiteFunc tear_down_tc,
13211       internal::TestFactoryBase* factory);
13212 
13213   // Constructs a TestInfo object. The newly constructed instance assumes
13214   // ownership of the factory object.
13215   TestInfo(const std::string& test_suite_name, const std::string& name,
13216            const char* a_type_param,   // NULL if not a type-parameterized test
13217            const char* a_value_param,  // NULL if not a value-parameterized test
13218            internal::CodeLocation a_code_location,
13219            internal::TypeId fixture_class_id,
13220            internal::TestFactoryBase* factory);
13221 
13222   // Increments the number of death tests encountered in this test so
13223   // far.
13224   int increment_death_test_count() {
13225     return result_.increment_death_test_count();
13226   }
13227 
13228   // Creates the test object, runs it, records its result, and then
13229   // deletes it.
13230   void Run();
13231 
13232   static void ClearTestResult(TestInfo* test_info) {
13233     test_info->result_.Clear();
13234   }
13235 
13236   // These fields are immutable properties of the test.
13237   const std::string test_suite_name_;    // test suite name
13238   const std::string name_;               // Test name
13239   // Name of the parameter type, or NULL if this is not a typed or a
13240   // type-parameterized test.
13241   const std::unique_ptr<const ::std::string> type_param_;
13242   // Text representation of the value parameter, or NULL if this is not a
13243   // value-parameterized test.
13244   const std::unique_ptr<const ::std::string> value_param_;
13245   internal::CodeLocation location_;
13246   const internal::TypeId fixture_class_id_;   // ID of the test fixture class
13247   bool should_run_;                 // True iff this test should run
13248   bool is_disabled_;                // True iff this test is disabled
13249   bool matches_filter_;             // True if this test matches the
13250                                     // user-specified filter.
13251   bool is_in_another_shard_;        // Will be run in another shard.
13252   internal::TestFactoryBase* const factory_;  // The factory that creates
13253                                               // the test object
13254 
13255   // This field is mutable and needs to be reset before running the
13256   // test for the second time.
13257   TestResult result_;
13258 
13259   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
13260 };
13261 
13262 // A test suite, which consists of a vector of TestInfos.
13263 //
13264 // TestSuite is not copyable.
13265 class GTEST_API_ TestSuite {
13266  public:
13267   // Creates a TestSuite with the given name.
13268   //
13269   // TestSuite does NOT have a default constructor.  Always use this
13270   // constructor to create a TestSuite object.
13271   //
13272   // Arguments:
13273   //
13274   //   name:         name of the test suite
13275   //   a_type_param: the name of the test's type parameter, or NULL if
13276   //                 this is not a type-parameterized test.
13277   //   set_up_tc:    pointer to the function that sets up the test suite
13278   //   tear_down_tc: pointer to the function that tears down the test suite
13279   TestSuite(const char* name, const char* a_type_param,
13280             internal::SetUpTestSuiteFunc set_up_tc,
13281             internal::TearDownTestSuiteFunc tear_down_tc);
13282 
13283   // Destructor of TestSuite.
13284   virtual ~TestSuite();
13285 
13286   // Gets the name of the TestSuite.
13287   const char* name() const { return name_.c_str(); }
13288 
13289   // Returns the name of the parameter type, or NULL if this is not a
13290   // type-parameterized test suite.
13291   const char* type_param() const {
13292     if (type_param_.get() != nullptr) return type_param_->c_str();
13293     return nullptr;
13294   }
13295 
13296   // Returns true if any test in this test suite should run.
13297   bool should_run() const { return should_run_; }
13298 
13299   // Gets the number of successful tests in this test suite.
13300   int successful_test_count() const;
13301 
13302   // Gets the number of skipped tests in this test suite.
13303   int skipped_test_count() const;
13304 
13305   // Gets the number of failed tests in this test suite.
13306   int failed_test_count() const;
13307 
13308   // Gets the number of disabled tests that will be reported in the XML report.
13309   int reportable_disabled_test_count() const;
13310 
13311   // Gets the number of disabled tests in this test suite.
13312   int disabled_test_count() const;
13313 
13314   // Gets the number of tests to be printed in the XML report.
13315   int reportable_test_count() const;
13316 
13317   // Get the number of tests in this test suite that should run.
13318   int test_to_run_count() const;
13319 
13320   // Gets the number of all tests in this test suite.
13321   int total_test_count() const;
13322 
13323   // Returns true iff the test suite passed.
13324   bool Passed() const { return !Failed(); }
13325 
13326   // Returns true iff the test suite failed.
13327   bool Failed() const { return failed_test_count() > 0; }
13328 
13329   // Returns the elapsed time, in milliseconds.
13330   TimeInMillis elapsed_time() const { return elapsed_time_; }
13331 
13332   // Returns the i-th test among all the tests. i can range from 0 to
13333   // total_test_count() - 1. If i is not in that range, returns NULL.
13334   const TestInfo* GetTestInfo(int i) const;
13335 
13336   // Returns the TestResult that holds test properties recorded during
13337   // execution of SetUpTestSuite and TearDownTestSuite.
13338   const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
13339 
13340  private:
13341   friend class Test;
13342   friend class internal::UnitTestImpl;
13343 
13344   // Gets the (mutable) vector of TestInfos in this TestSuite.
13345   std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
13346 
13347   // Gets the (immutable) vector of TestInfos in this TestSuite.
13348   const std::vector<TestInfo*>& test_info_list() const {
13349     return test_info_list_;
13350   }
13351 
13352   // Returns the i-th test among all the tests. i can range from 0 to
13353   // total_test_count() - 1. If i is not in that range, returns NULL.
13354   TestInfo* GetMutableTestInfo(int i);
13355 
13356   // Sets the should_run member.
13357   void set_should_run(bool should) { should_run_ = should; }
13358 
13359   // Adds a TestInfo to this test suite.  Will delete the TestInfo upon
13360   // destruction of the TestSuite object.
13361   void AddTestInfo(TestInfo * test_info);
13362 
13363   // Clears the results of all tests in this test suite.
13364   void ClearResult();
13365 
13366   // Clears the results of all tests in the given test suite.
13367   static void ClearTestSuiteResult(TestSuite* test_suite) {
13368     test_suite->ClearResult();
13369   }
13370 
13371   // Runs every test in this TestSuite.
13372   void Run();
13373 
13374   // Runs SetUpTestSuite() for this TestSuite.  This wrapper is needed
13375   // for catching exceptions thrown from SetUpTestSuite().
13376   void RunSetUpTestSuite() {
13377     if (set_up_tc_ != nullptr) {
13378       (*set_up_tc_)();
13379     }
13380   }
13381 
13382   // Runs TearDownTestSuite() for this TestSuite.  This wrapper is
13383   // needed for catching exceptions thrown from TearDownTestSuite().
13384   void RunTearDownTestSuite() {
13385     if (tear_down_tc_ != nullptr) {
13386       (*tear_down_tc_)();
13387     }
13388   }
13389 
13390   // Returns true iff test passed.
13391   static bool TestPassed(const TestInfo* test_info) {
13392     return test_info->should_run() && test_info->result()->Passed();
13393   }
13394 
13395   // Returns true iff test skipped.
13396   static bool TestSkipped(const TestInfo* test_info) {
13397     return test_info->should_run() && test_info->result()->Skipped();
13398   }
13399 
13400   // Returns true iff test failed.
13401   static bool TestFailed(const TestInfo* test_info) {
13402     return test_info->should_run() && test_info->result()->Failed();
13403   }
13404 
13405   // Returns true iff the test is disabled and will be reported in the XML
13406   // report.
13407   static bool TestReportableDisabled(const TestInfo* test_info) {
13408     return test_info->is_reportable() && test_info->is_disabled_;
13409   }
13410 
13411   // Returns true iff test is disabled.
13412   static bool TestDisabled(const TestInfo* test_info) {
13413     return test_info->is_disabled_;
13414   }
13415 
13416   // Returns true iff this test will appear in the XML report.
13417   static bool TestReportable(const TestInfo* test_info) {
13418     return test_info->is_reportable();
13419   }
13420 
13421   // Returns true if the given test should run.
13422   static bool ShouldRunTest(const TestInfo* test_info) {
13423     return test_info->should_run();
13424   }
13425 
13426   // Shuffles the tests in this test suite.
13427   void ShuffleTests(internal::Random* random);
13428 
13429   // Restores the test order to before the first shuffle.
13430   void UnshuffleTests();
13431 
13432   // Name of the test suite.
13433   std::string name_;
13434   // Name of the parameter type, or NULL if this is not a typed or a
13435   // type-parameterized test.
13436   const std::unique_ptr<const ::std::string> type_param_;
13437   // The vector of TestInfos in their original order.  It owns the
13438   // elements in the vector.
13439   std::vector<TestInfo*> test_info_list_;
13440   // Provides a level of indirection for the test list to allow easy
13441   // shuffling and restoring the test order.  The i-th element in this
13442   // vector is the index of the i-th test in the shuffled test list.
13443   std::vector<int> test_indices_;
13444   // Pointer to the function that sets up the test suite.
13445   internal::SetUpTestSuiteFunc set_up_tc_;
13446   // Pointer to the function that tears down the test suite.
13447   internal::TearDownTestSuiteFunc tear_down_tc_;
13448   // True iff any test in this test suite should run.
13449   bool should_run_;
13450   // Elapsed time, in milliseconds.
13451   TimeInMillis elapsed_time_;
13452   // Holds test properties recorded during execution of SetUpTestSuite and
13453   // TearDownTestSuite.
13454   TestResult ad_hoc_test_result_;
13455 
13456   // We disallow copying TestSuites.
13457   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
13458 };
13459 
13460 // An Environment object is capable of setting up and tearing down an
13461 // environment.  You should subclass this to define your own
13462 // environment(s).
13463 //
13464 // An Environment object does the set-up and tear-down in virtual
13465 // methods SetUp() and TearDown() instead of the constructor and the
13466 // destructor, as:
13467 //
13468 //   1. You cannot safely throw from a destructor.  This is a problem
13469 //      as in some cases Google Test is used where exceptions are enabled, and
13470 //      we may want to implement ASSERT_* using exceptions where they are
13471 //      available.
13472 //   2. You cannot use ASSERT_* directly in a constructor or
13473 //      destructor.
13474 class Environment {
13475  public:
13476   // The d'tor is virtual as we need to subclass Environment.
13477   virtual ~Environment() {}
13478 
13479   // Override this to define how to set up the environment.
13480   virtual void SetUp() {}
13481 
13482   // Override this to define how to tear down the environment.
13483   virtual void TearDown() {}
13484  private:
13485   // If you see an error about overriding the following function or
13486   // about it being private, you have mis-spelled SetUp() as Setup().
13487   struct Setup_should_be_spelled_SetUp {};
13488   virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
13489 };
13490 
13491 #if GTEST_HAS_EXCEPTIONS
13492 
13493 // Exception which can be thrown from TestEventListener::OnTestPartResult.
13494 class GTEST_API_ AssertionException
13495     : public internal::GoogleTestFailureException {
13496  public:
13497   explicit AssertionException(const TestPartResult& result)
13498       : GoogleTestFailureException(result) {}
13499 };
13500 
13501 #endif  // GTEST_HAS_EXCEPTIONS
13502 
13503 // The interface for tracing execution of tests. The methods are organized in
13504 // the order the corresponding events are fired.
13505 class TestEventListener {
13506  public:
13507   virtual ~TestEventListener() {}
13508 
13509   // Fired before any test activity starts.
13510   virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
13511 
13512   // Fired before each iteration of tests starts.  There may be more than
13513   // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
13514   // index, starting from 0.
13515   virtual void OnTestIterationStart(const UnitTest& unit_test,
13516                                     int iteration) = 0;
13517 
13518   // Fired before environment set-up for each iteration of tests starts.
13519   virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
13520 
13521   // Fired after environment set-up for each iteration of tests ends.
13522   virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
13523 
13524   // Fired before the test suite starts.
13525   virtual void OnTestSuiteStart(const TestSuite& /*test_suite*/) {}
13526 
13527   //  Legacy API is deprecated but still available
13528 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13529   virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
13530 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13531 
13532   // Fired before the test starts.
13533   virtual void OnTestStart(const TestInfo& test_info) = 0;
13534 
13535   // Fired after a failed assertion or a SUCCEED() invocation.
13536   // If you want to throw an exception from this function to skip to the next
13537   // TEST, it must be AssertionException defined above, or inherited from it.
13538   virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
13539 
13540   // Fired after the test ends.
13541   virtual void OnTestEnd(const TestInfo& test_info) = 0;
13542 
13543   // Fired after the test suite ends.
13544   virtual void OnTestSuiteEnd(const TestSuite& /*test_suite*/) {}
13545 
13546 //  Legacy API is deprecated but still available
13547 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13548   virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
13549 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13550 
13551   // Fired before environment tear-down for each iteration of tests starts.
13552   virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
13553 
13554   // Fired after environment tear-down for each iteration of tests ends.
13555   virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
13556 
13557   // Fired after each iteration of tests finishes.
13558   virtual void OnTestIterationEnd(const UnitTest& unit_test,
13559                                   int iteration) = 0;
13560 
13561   // Fired after all test activities have ended.
13562   virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
13563 };
13564 
13565 // The convenience class for users who need to override just one or two
13566 // methods and are not concerned that a possible change to a signature of
13567 // the methods they override will not be caught during the build.  For
13568 // comments about each method please see the definition of TestEventListener
13569 // above.
13570 class EmptyTestEventListener : public TestEventListener {
13571  public:
13572   void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
13573   void OnTestIterationStart(const UnitTest& /*unit_test*/,
13574                             int /*iteration*/) override {}
13575   void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
13576   void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
13577   void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}
13578 //  Legacy API is deprecated but still available
13579 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13580   void OnTestCaseStart(const TestCase& /*test_case*/) override {}
13581 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13582 
13583   void OnTestStart(const TestInfo& /*test_info*/) override {}
13584   void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
13585   void OnTestEnd(const TestInfo& /*test_info*/) override {}
13586   void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}
13587 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13588   void OnTestCaseEnd(const TestCase& /*test_case*/) override {}
13589 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13590 
13591   void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
13592   void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
13593   void OnTestIterationEnd(const UnitTest& /*unit_test*/,
13594                           int /*iteration*/) override {}
13595   void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
13596 };
13597 
13598 // TestEventListeners lets users add listeners to track events in Google Test.
13599 class GTEST_API_ TestEventListeners {
13600  public:
13601   TestEventListeners();
13602   ~TestEventListeners();
13603 
13604   // Appends an event listener to the end of the list. Google Test assumes
13605   // the ownership of the listener (i.e. it will delete the listener when
13606   // the test program finishes).
13607   void Append(TestEventListener* listener);
13608 
13609   // Removes the given event listener from the list and returns it.  It then
13610   // becomes the caller's responsibility to delete the listener. Returns
13611   // NULL if the listener is not found in the list.
13612   TestEventListener* Release(TestEventListener* listener);
13613 
13614   // Returns the standard listener responsible for the default console
13615   // output.  Can be removed from the listeners list to shut down default
13616   // console output.  Note that removing this object from the listener list
13617   // with Release transfers its ownership to the caller and makes this
13618   // function return NULL the next time.
13619   TestEventListener* default_result_printer() const {
13620     return default_result_printer_;
13621   }
13622 
13623   // Returns the standard listener responsible for the default XML output
13624   // controlled by the --gtest_output=xml flag.  Can be removed from the
13625   // listeners list by users who want to shut down the default XML output
13626   // controlled by this flag and substitute it with custom one.  Note that
13627   // removing this object from the listener list with Release transfers its
13628   // ownership to the caller and makes this function return NULL the next
13629   // time.
13630   TestEventListener* default_xml_generator() const {
13631     return default_xml_generator_;
13632   }
13633 
13634  private:
13635   friend class TestSuite;
13636   friend class TestInfo;
13637   friend class internal::DefaultGlobalTestPartResultReporter;
13638   friend class internal::NoExecDeathTest;
13639   friend class internal::TestEventListenersAccessor;
13640   friend class internal::UnitTestImpl;
13641 
13642   // Returns repeater that broadcasts the TestEventListener events to all
13643   // subscribers.
13644   TestEventListener* repeater();
13645 
13646   // Sets the default_result_printer attribute to the provided listener.
13647   // The listener is also added to the listener list and previous
13648   // default_result_printer is removed from it and deleted. The listener can
13649   // also be NULL in which case it will not be added to the list. Does
13650   // nothing if the previous and the current listener objects are the same.
13651   void SetDefaultResultPrinter(TestEventListener* listener);
13652 
13653   // Sets the default_xml_generator attribute to the provided listener.  The
13654   // listener is also added to the listener list and previous
13655   // default_xml_generator is removed from it and deleted. The listener can
13656   // also be NULL in which case it will not be added to the list. Does
13657   // nothing if the previous and the current listener objects are the same.
13658   void SetDefaultXmlGenerator(TestEventListener* listener);
13659 
13660   // Controls whether events will be forwarded by the repeater to the
13661   // listeners in the list.
13662   bool EventForwardingEnabled() const;
13663   void SuppressEventForwarding();
13664 
13665   // The actual list of listeners.
13666   internal::TestEventRepeater* repeater_;
13667   // Listener responsible for the standard result output.
13668   TestEventListener* default_result_printer_;
13669   // Listener responsible for the creation of the XML output file.
13670   TestEventListener* default_xml_generator_;
13671 
13672   // We disallow copying TestEventListeners.
13673   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
13674 };
13675 
13676 // A UnitTest consists of a vector of TestSuites.
13677 //
13678 // This is a singleton class.  The only instance of UnitTest is
13679 // created when UnitTest::GetInstance() is first called.  This
13680 // instance is never deleted.
13681 //
13682 // UnitTest is not copyable.
13683 //
13684 // This class is thread-safe as long as the methods are called
13685 // according to their specification.
13686 class GTEST_API_ UnitTest {
13687  public:
13688   // Gets the singleton UnitTest object.  The first time this method
13689   // is called, a UnitTest object is constructed and returned.
13690   // Consecutive calls will return the same object.
13691   static UnitTest* GetInstance();
13692 
13693   // Runs all tests in this UnitTest object and prints the result.
13694   // Returns 0 if successful, or 1 otherwise.
13695   //
13696   // This method can only be called from the main thread.
13697   //
13698   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
13699   int Run() GTEST_MUST_USE_RESULT_;
13700 
13701   // Returns the working directory when the first TEST() or TEST_F()
13702   // was executed.  The UnitTest object owns the string.
13703   const char* original_working_dir() const;
13704 
13705   // Returns the TestSuite object for the test that's currently running,
13706   // or NULL if no test is running.
13707   const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
13708 
13709 // Legacy API is still available but deprecated
13710 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13711   const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);
13712 #endif
13713 
13714   // Returns the TestInfo object for the test that's currently running,
13715   // or NULL if no test is running.
13716   const TestInfo* current_test_info() const
13717       GTEST_LOCK_EXCLUDED_(mutex_);
13718 
13719   // Returns the random seed used at the start of the current test run.
13720   int random_seed() const;
13721 
13722   // Returns the ParameterizedTestSuiteRegistry object used to keep track of
13723   // value-parameterized tests and instantiate and register them.
13724   //
13725   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
13726   internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
13727       GTEST_LOCK_EXCLUDED_(mutex_);
13728 
13729   // Gets the number of successful test suites.
13730   int successful_test_suite_count() const;
13731 
13732   // Gets the number of failed test suites.
13733   int failed_test_suite_count() const;
13734 
13735   // Gets the number of all test suites.
13736   int total_test_suite_count() const;
13737 
13738   // Gets the number of all test suites that contain at least one test
13739   // that should run.
13740   int test_suite_to_run_count() const;
13741 
13742   //  Legacy API is deprecated but still available
13743 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13744   int successful_test_case_count() const;
13745   int failed_test_case_count() const;
13746   int total_test_case_count() const;
13747   int test_case_to_run_count() const;
13748 #endif  //  EMOVE_LEGACY_TEST_CASEAPI
13749 
13750   // Gets the number of successful tests.
13751   int successful_test_count() const;
13752 
13753   // Gets the number of skipped tests.
13754   int skipped_test_count() const;
13755 
13756   // Gets the number of failed tests.
13757   int failed_test_count() const;
13758 
13759   // Gets the number of disabled tests that will be reported in the XML report.
13760   int reportable_disabled_test_count() const;
13761 
13762   // Gets the number of disabled tests.
13763   int disabled_test_count() const;
13764 
13765   // Gets the number of tests to be printed in the XML report.
13766   int reportable_test_count() const;
13767 
13768   // Gets the number of all tests.
13769   int total_test_count() const;
13770 
13771   // Gets the number of tests that should run.
13772   int test_to_run_count() const;
13773 
13774   // Gets the time of the test program start, in ms from the start of the
13775   // UNIX epoch.
13776   TimeInMillis start_timestamp() const;
13777 
13778   // Gets the elapsed time, in milliseconds.
13779   TimeInMillis elapsed_time() const;
13780 
13781   // Returns true iff the unit test passed (i.e. all test suites passed).
13782   bool Passed() const;
13783 
13784   // Returns true iff the unit test failed (i.e. some test suite failed
13785   // or something outside of all tests failed).
13786   bool Failed() const;
13787 
13788   // Gets the i-th test suite among all the test suites. i can range from 0 to
13789   // total_test_suite_count() - 1. If i is not in that range, returns NULL.
13790   const TestSuite* GetTestSuite(int i) const;
13791 
13792 //  Legacy API is deprecated but still available
13793 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13794   const TestCase* GetTestCase(int i) const;
13795 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13796 
13797   // Returns the TestResult containing information on test failures and
13798   // properties logged outside of individual test suites.
13799   const TestResult& ad_hoc_test_result() const;
13800 
13801   // Returns the list of event listeners that can be used to track events
13802   // inside Google Test.
13803   TestEventListeners& listeners();
13804 
13805  private:
13806   // Registers and returns a global test environment.  When a test
13807   // program is run, all global test environments will be set-up in
13808   // the order they were registered.  After all tests in the program
13809   // have finished, all global test environments will be torn-down in
13810   // the *reverse* order they were registered.
13811   //
13812   // The UnitTest object takes ownership of the given environment.
13813   //
13814   // This method can only be called from the main thread.
13815   Environment* AddEnvironment(Environment* env);
13816 
13817   // Adds a TestPartResult to the current TestResult object.  All
13818   // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
13819   // eventually call this to report their results.  The user code
13820   // should use the assertion macros instead of calling this directly.
13821   void AddTestPartResult(TestPartResult::Type result_type,
13822                          const char* file_name,
13823                          int line_number,
13824                          const std::string& message,
13825                          const std::string& os_stack_trace)
13826       GTEST_LOCK_EXCLUDED_(mutex_);
13827 
13828   // Adds a TestProperty to the current TestResult object when invoked from
13829   // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked
13830   // from SetUpTestSuite or TearDownTestSuite, or to the global property set
13831   // when invoked elsewhere.  If the result already contains a property with
13832   // the same key, the value will be updated.
13833   void RecordProperty(const std::string& key, const std::string& value);
13834 
13835   // Gets the i-th test suite among all the test suites. i can range from 0 to
13836   // total_test_suite_count() - 1. If i is not in that range, returns NULL.
13837   TestSuite* GetMutableTestSuite(int i);
13838 
13839   // Accessors for the implementation object.
13840   internal::UnitTestImpl* impl() { return impl_; }
13841   const internal::UnitTestImpl* impl() const { return impl_; }
13842 
13843   // These classes and functions are friends as they need to access private
13844   // members of UnitTest.
13845   friend class ScopedTrace;
13846   friend class Test;
13847   friend class internal::AssertHelper;
13848   friend class internal::StreamingListenerTest;
13849   friend class internal::UnitTestRecordPropertyTestHelper;
13850   friend Environment* AddGlobalTestEnvironment(Environment* env);
13851   friend internal::UnitTestImpl* internal::GetUnitTestImpl();
13852   friend void internal::ReportFailureInUnknownLocation(
13853       TestPartResult::Type result_type,
13854       const std::string& message);
13855 
13856   // Creates an empty UnitTest.
13857   UnitTest();
13858 
13859   // D'tor
13860   virtual ~UnitTest();
13861 
13862   // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
13863   // Google Test trace stack.
13864   void PushGTestTrace(const internal::TraceInfo& trace)
13865       GTEST_LOCK_EXCLUDED_(mutex_);
13866 
13867   // Pops a trace from the per-thread Google Test trace stack.
13868   void PopGTestTrace()
13869       GTEST_LOCK_EXCLUDED_(mutex_);
13870 
13871   // Protects mutable state in *impl_.  This is mutable as some const
13872   // methods need to lock it too.
13873   mutable internal::Mutex mutex_;
13874 
13875   // Opaque implementation object.  This field is never changed once
13876   // the object is constructed.  We don't mark it as const here, as
13877   // doing so will cause a warning in the constructor of UnitTest.
13878   // Mutable state in *impl_ is protected by mutex_.
13879   internal::UnitTestImpl* impl_;
13880 
13881   // We disallow copying UnitTest.
13882   GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
13883 };
13884 
13885 // A convenient wrapper for adding an environment for the test
13886 // program.
13887 //
13888 // You should call this before RUN_ALL_TESTS() is called, probably in
13889 // main().  If you use gtest_main, you need to call this before main()
13890 // starts for it to take effect.  For example, you can define a global
13891 // variable like this:
13892 //
13893 //   testing::Environment* const foo_env =
13894 //       testing::AddGlobalTestEnvironment(new FooEnvironment);
13895 //
13896 // However, we strongly recommend you to write your own main() and
13897 // call AddGlobalTestEnvironment() there, as relying on initialization
13898 // of global variables makes the code harder to read and may cause
13899 // problems when you register multiple environments from different
13900 // translation units and the environments have dependencies among them
13901 // (remember that the compiler doesn't guarantee the order in which
13902 // global variables from different translation units are initialized).
13903 inline Environment* AddGlobalTestEnvironment(Environment* env) {
13904   return UnitTest::GetInstance()->AddEnvironment(env);
13905 }
13906 
13907 // Initializes Google Test.  This must be called before calling
13908 // RUN_ALL_TESTS().  In particular, it parses a command line for the
13909 // flags that Google Test recognizes.  Whenever a Google Test flag is
13910 // seen, it is removed from argv, and *argc is decremented.
13911 //
13912 // No value is returned.  Instead, the Google Test flag variables are
13913 // updated.
13914 //
13915 // Calling the function for the second time has no user-visible effect.
13916 GTEST_API_ void InitGoogleTest(int* argc, char** argv);
13917 
13918 // This overloaded version can be used in Windows programs compiled in
13919 // UNICODE mode.
13920 GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
13921 
13922 // This overloaded version can be used on Arduino/embedded platforms where
13923 // there is no argc/argv.
13924 GTEST_API_ void InitGoogleTest();
13925 
13926 namespace internal {
13927 
13928 // Separate the error generating code from the code path to reduce the stack
13929 // frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers
13930 // when calling EXPECT_* in a tight loop.
13931 template <typename T1, typename T2>
13932 AssertionResult CmpHelperEQFailure(const char* lhs_expression,
13933                                    const char* rhs_expression,
13934                                    const T1& lhs, const T2& rhs) {
13935   return EqFailure(lhs_expression,
13936                    rhs_expression,
13937                    FormatForComparisonFailureMessage(lhs, rhs),
13938                    FormatForComparisonFailureMessage(rhs, lhs),
13939                    false);
13940 }
13941 
13942 // This block of code defines operator==/!=
13943 // to block lexical scope lookup.
13944 // It prevents using invalid operator==/!= defined at namespace scope.
13945 struct faketype {};
13946 inline bool operator==(faketype, faketype) { return true; }
13947 inline bool operator!=(faketype, faketype) { return false; }
13948 
13949 // The helper function for {ASSERT|EXPECT}_EQ.
13950 template <typename T1, typename T2>
13951 AssertionResult CmpHelperEQ(const char* lhs_expression,
13952                             const char* rhs_expression,
13953                             const T1& lhs,
13954                             const T2& rhs) {
13955   if (lhs == rhs) {
13956     return AssertionSuccess();
13957   }
13958 
13959   return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
13960 }
13961 
13962 // With this overloaded version, we allow anonymous enums to be used
13963 // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
13964 // can be implicitly cast to BiggestInt.
13965 GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
13966                                        const char* rhs_expression,
13967                                        BiggestInt lhs,
13968                                        BiggestInt rhs);
13969 
13970 class EqHelper {
13971  public:
13972   // This templatized version is for the general case.
13973   template <
13974       typename T1, typename T2,
13975       // Disable this overload for cases where one argument is a pointer
13976       // and the other is the null pointer constant.
13977       typename std::enable_if<!std::is_integral<T1>::value ||
13978                               !std::is_pointer<T2>::value>::type* = nullptr>
13979   static AssertionResult Compare(const char* lhs_expression,
13980                                  const char* rhs_expression, const T1& lhs,
13981                                  const T2& rhs) {
13982     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
13983   }
13984 
13985   // With this overloaded version, we allow anonymous enums to be used
13986   // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
13987   // enums can be implicitly cast to BiggestInt.
13988   //
13989   // Even though its body looks the same as the above version, we
13990   // cannot merge the two, as it will make anonymous enums unhappy.
13991   static AssertionResult Compare(const char* lhs_expression,
13992                                  const char* rhs_expression,
13993                                  BiggestInt lhs,
13994                                  BiggestInt rhs) {
13995     return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
13996   }
13997 
13998   template <typename T>
13999   static AssertionResult Compare(
14000       const char* lhs_expression, const char* rhs_expression,
14001       // Handle cases where '0' is used as a null pointer literal.
14002       std::nullptr_t /* lhs */, T* rhs) {
14003     // We already know that 'lhs' is a null pointer.
14004     return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
14005                        rhs);
14006   }
14007 };
14008 
14009 // Separate the error generating code from the code path to reduce the stack
14010 // frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers
14011 // when calling EXPECT_OP in a tight loop.
14012 template <typename T1, typename T2>
14013 AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
14014                                    const T1& val1, const T2& val2,
14015                                    const char* op) {
14016   return AssertionFailure()
14017          << "Expected: (" << expr1 << ") " << op << " (" << expr2
14018          << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
14019          << " vs " << FormatForComparisonFailureMessage(val2, val1);
14020 }
14021 
14022 // A macro for implementing the helper functions needed to implement
14023 // ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste
14024 // of similar code.
14025 //
14026 // For each templatized helper function, we also define an overloaded
14027 // version for BiggestInt in order to reduce code bloat and allow
14028 // anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
14029 // with gcc 4.
14030 //
14031 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14032 
14033 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
14034 template <typename T1, typename T2>\
14035 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
14036                                    const T1& val1, const T2& val2) {\
14037   if (val1 op val2) {\
14038     return AssertionSuccess();\
14039   } else {\
14040     return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
14041   }\
14042 }\
14043 GTEST_API_ AssertionResult CmpHelper##op_name(\
14044     const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
14045 
14046 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14047 
14048 // Implements the helper function for {ASSERT|EXPECT}_NE
14049 GTEST_IMPL_CMP_HELPER_(NE, !=);
14050 // Implements the helper function for {ASSERT|EXPECT}_LE
14051 GTEST_IMPL_CMP_HELPER_(LE, <=);
14052 // Implements the helper function for {ASSERT|EXPECT}_LT
14053 GTEST_IMPL_CMP_HELPER_(LT, <);
14054 // Implements the helper function for {ASSERT|EXPECT}_GE
14055 GTEST_IMPL_CMP_HELPER_(GE, >=);
14056 // Implements the helper function for {ASSERT|EXPECT}_GT
14057 GTEST_IMPL_CMP_HELPER_(GT, >);
14058 
14059 #undef GTEST_IMPL_CMP_HELPER_
14060 
14061 // The helper function for {ASSERT|EXPECT}_STREQ.
14062 //
14063 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14064 GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
14065                                           const char* s2_expression,
14066                                           const char* s1,
14067                                           const char* s2);
14068 
14069 // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
14070 //
14071 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14072 GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
14073                                               const char* s2_expression,
14074                                               const char* s1,
14075                                               const char* s2);
14076 
14077 // The helper function for {ASSERT|EXPECT}_STRNE.
14078 //
14079 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14080 GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
14081                                           const char* s2_expression,
14082                                           const char* s1,
14083                                           const char* s2);
14084 
14085 // The helper function for {ASSERT|EXPECT}_STRCASENE.
14086 //
14087 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14088 GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
14089                                               const char* s2_expression,
14090                                               const char* s1,
14091                                               const char* s2);
14092 
14093 
14094 // Helper function for *_STREQ on wide strings.
14095 //
14096 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14097 GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
14098                                           const char* s2_expression,
14099                                           const wchar_t* s1,
14100                                           const wchar_t* s2);
14101 
14102 // Helper function for *_STRNE on wide strings.
14103 //
14104 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14105 GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
14106                                           const char* s2_expression,
14107                                           const wchar_t* s1,
14108                                           const wchar_t* s2);
14109 
14110 }  // namespace internal
14111 
14112 // IsSubstring() and IsNotSubstring() are intended to be used as the
14113 // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
14114 // themselves.  They check whether needle is a substring of haystack
14115 // (NULL is considered a substring of itself only), and return an
14116 // appropriate error message when they fail.
14117 //
14118 // The {needle,haystack}_expr arguments are the stringified
14119 // expressions that generated the two real arguments.
14120 GTEST_API_ AssertionResult IsSubstring(
14121     const char* needle_expr, const char* haystack_expr,
14122     const char* needle, const char* haystack);
14123 GTEST_API_ AssertionResult IsSubstring(
14124     const char* needle_expr, const char* haystack_expr,
14125     const wchar_t* needle, const wchar_t* haystack);
14126 GTEST_API_ AssertionResult IsNotSubstring(
14127     const char* needle_expr, const char* haystack_expr,
14128     const char* needle, const char* haystack);
14129 GTEST_API_ AssertionResult IsNotSubstring(
14130     const char* needle_expr, const char* haystack_expr,
14131     const wchar_t* needle, const wchar_t* haystack);
14132 GTEST_API_ AssertionResult IsSubstring(
14133     const char* needle_expr, const char* haystack_expr,
14134     const ::std::string& needle, const ::std::string& haystack);
14135 GTEST_API_ AssertionResult IsNotSubstring(
14136     const char* needle_expr, const char* haystack_expr,
14137     const ::std::string& needle, const ::std::string& haystack);
14138 
14139 #if GTEST_HAS_STD_WSTRING
14140 GTEST_API_ AssertionResult IsSubstring(
14141     const char* needle_expr, const char* haystack_expr,
14142     const ::std::wstring& needle, const ::std::wstring& haystack);
14143 GTEST_API_ AssertionResult IsNotSubstring(
14144     const char* needle_expr, const char* haystack_expr,
14145     const ::std::wstring& needle, const ::std::wstring& haystack);
14146 #endif  // GTEST_HAS_STD_WSTRING
14147 
14148 namespace internal {
14149 
14150 // Helper template function for comparing floating-points.
14151 //
14152 // Template parameter:
14153 //
14154 //   RawType: the raw floating-point type (either float or double)
14155 //
14156 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14157 template <typename RawType>
14158 AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
14159                                          const char* rhs_expression,
14160                                          RawType lhs_value,
14161                                          RawType rhs_value) {
14162   const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
14163 
14164   if (lhs.AlmostEquals(rhs)) {
14165     return AssertionSuccess();
14166   }
14167 
14168   ::std::stringstream lhs_ss;
14169   lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
14170          << lhs_value;
14171 
14172   ::std::stringstream rhs_ss;
14173   rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
14174          << rhs_value;
14175 
14176   return EqFailure(lhs_expression,
14177                    rhs_expression,
14178                    StringStreamToString(&lhs_ss),
14179                    StringStreamToString(&rhs_ss),
14180                    false);
14181 }
14182 
14183 // Helper function for implementing ASSERT_NEAR.
14184 //
14185 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14186 GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
14187                                                 const char* expr2,
14188                                                 const char* abs_error_expr,
14189                                                 double val1,
14190                                                 double val2,
14191                                                 double abs_error);
14192 
14193 // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
14194 // A class that enables one to stream messages to assertion macros
14195 class GTEST_API_ AssertHelper {
14196  public:
14197   // Constructor.
14198   AssertHelper(TestPartResult::Type type,
14199                const char* file,
14200                int line,
14201                const char* message);
14202   ~AssertHelper();
14203 
14204   // Message assignment is a semantic trick to enable assertion
14205   // streaming; see the GTEST_MESSAGE_ macro below.
14206   void operator=(const Message& message) const;
14207 
14208  private:
14209   // We put our data in a struct so that the size of the AssertHelper class can
14210   // be as small as possible.  This is important because gcc is incapable of
14211   // re-using stack space even for temporary variables, so every EXPECT_EQ
14212   // reserves stack space for another AssertHelper.
14213   struct AssertHelperData {
14214     AssertHelperData(TestPartResult::Type t,
14215                      const char* srcfile,
14216                      int line_num,
14217                      const char* msg)
14218         : type(t), file(srcfile), line(line_num), message(msg) { }
14219 
14220     TestPartResult::Type const type;
14221     const char* const file;
14222     int const line;
14223     std::string const message;
14224 
14225    private:
14226     GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
14227   };
14228 
14229   AssertHelperData* const data_;
14230 
14231   GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
14232 };
14233 
14234 enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW };
14235 
14236 GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color,
14237                                                             const char* fmt,
14238                                                             ...);
14239 
14240 }  // namespace internal
14241 
14242 // The pure interface class that all value-parameterized tests inherit from.
14243 // A value-parameterized class must inherit from both ::testing::Test and
14244 // ::testing::WithParamInterface. In most cases that just means inheriting
14245 // from ::testing::TestWithParam, but more complicated test hierarchies
14246 // may need to inherit from Test and WithParamInterface at different levels.
14247 //
14248 // This interface has support for accessing the test parameter value via
14249 // the GetParam() method.
14250 //
14251 // Use it with one of the parameter generator defining functions, like Range(),
14252 // Values(), ValuesIn(), Bool(), and Combine().
14253 //
14254 // class FooTest : public ::testing::TestWithParam<int> {
14255 //  protected:
14256 //   FooTest() {
14257 //     // Can use GetParam() here.
14258 //   }
14259 //   ~FooTest() override {
14260 //     // Can use GetParam() here.
14261 //   }
14262 //   void SetUp() override {
14263 //     // Can use GetParam() here.
14264 //   }
14265 //   void TearDown override {
14266 //     // Can use GetParam() here.
14267 //   }
14268 // };
14269 // TEST_P(FooTest, DoesBar) {
14270 //   // Can use GetParam() method here.
14271 //   Foo foo;
14272 //   ASSERT_TRUE(foo.DoesBar(GetParam()));
14273 // }
14274 // INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
14275 
14276 template <typename T>
14277 class WithParamInterface {
14278  public:
14279   typedef T ParamType;
14280   virtual ~WithParamInterface() {}
14281 
14282   // The current parameter value. Is also available in the test fixture's
14283   // constructor.
14284   static const ParamType& GetParam() {
14285     GTEST_CHECK_(parameter_ != nullptr)
14286         << "GetParam() can only be called inside a value-parameterized test "
14287         << "-- did you intend to write TEST_P instead of TEST_F?";
14288     return *parameter_;
14289   }
14290 
14291  private:
14292   // Sets parameter value. The caller is responsible for making sure the value
14293   // remains alive and unchanged throughout the current test.
14294   static void SetParam(const ParamType* parameter) {
14295     parameter_ = parameter;
14296   }
14297 
14298   // Static value used for accessing parameter during a test lifetime.
14299   static const ParamType* parameter_;
14300 
14301   // TestClass must be a subclass of WithParamInterface<T> and Test.
14302   template <class TestClass> friend class internal::ParameterizedTestFactory;
14303 };
14304 
14305 template <typename T>
14306 const T* WithParamInterface<T>::parameter_ = nullptr;
14307 
14308 // Most value-parameterized classes can ignore the existence of
14309 // WithParamInterface, and can just inherit from ::testing::TestWithParam.
14310 
14311 template <typename T>
14312 class TestWithParam : public Test, public WithParamInterface<T> {
14313 };
14314 
14315 // Macros for indicating success/failure in test code.
14316 
14317 // Skips test in runtime.
14318 // Skipping test aborts current function.
14319 // Skipped tests are neither successful nor failed.
14320 #define GTEST_SKIP() GTEST_SKIP_("Skipped")
14321 
14322 // ADD_FAILURE unconditionally adds a failure to the current test.
14323 // SUCCEED generates a success - it doesn't automatically make the
14324 // current test successful, as a test is only successful when it has
14325 // no failure.
14326 //
14327 // EXPECT_* verifies that a certain condition is satisfied.  If not,
14328 // it behaves like ADD_FAILURE.  In particular:
14329 //
14330 //   EXPECT_TRUE  verifies that a Boolean condition is true.
14331 //   EXPECT_FALSE verifies that a Boolean condition is false.
14332 //
14333 // FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
14334 // that they will also abort the current function on failure.  People
14335 // usually want the fail-fast behavior of FAIL and ASSERT_*, but those
14336 // writing data-driven tests often find themselves using ADD_FAILURE
14337 // and EXPECT_* more.
14338 
14339 // Generates a nonfatal failure with a generic message.
14340 #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
14341 
14342 // Generates a nonfatal failure at the given source file location with
14343 // a generic message.
14344 #define ADD_FAILURE_AT(file, line) \
14345   GTEST_MESSAGE_AT_(file, line, "Failed", \
14346                     ::testing::TestPartResult::kNonFatalFailure)
14347 
14348 // Generates a fatal failure with a generic message.
14349 #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
14350 
14351 // Define this macro to 1 to omit the definition of FAIL(), which is a
14352 // generic name and clashes with some other libraries.
14353 #if !GTEST_DONT_DEFINE_FAIL
14354 # define FAIL() GTEST_FAIL()
14355 #endif
14356 
14357 // Generates a success with a generic message.
14358 #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
14359 
14360 // Define this macro to 1 to omit the definition of SUCCEED(), which
14361 // is a generic name and clashes with some other libraries.
14362 #if !GTEST_DONT_DEFINE_SUCCEED
14363 # define SUCCEED() GTEST_SUCCEED()
14364 #endif
14365 
14366 // Macros for testing exceptions.
14367 //
14368 //    * {ASSERT|EXPECT}_THROW(statement, expected_exception):
14369 //         Tests that the statement throws the expected exception.
14370 //    * {ASSERT|EXPECT}_NO_THROW(statement):
14371 //         Tests that the statement doesn't throw any exception.
14372 //    * {ASSERT|EXPECT}_ANY_THROW(statement):
14373 //         Tests that the statement throws an exception.
14374 
14375 #define EXPECT_THROW(statement, expected_exception) \
14376   GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
14377 #define EXPECT_NO_THROW(statement) \
14378   GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
14379 #define EXPECT_ANY_THROW(statement) \
14380   GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
14381 #define ASSERT_THROW(statement, expected_exception) \
14382   GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
14383 #define ASSERT_NO_THROW(statement) \
14384   GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
14385 #define ASSERT_ANY_THROW(statement) \
14386   GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
14387 
14388 // Boolean assertions. Condition can be either a Boolean expression or an
14389 // AssertionResult. For more information on how to use AssertionResult with
14390 // these macros see comments on that class.
14391 #define EXPECT_TRUE(condition) \
14392   GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
14393                       GTEST_NONFATAL_FAILURE_)
14394 #define EXPECT_FALSE(condition) \
14395   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
14396                       GTEST_NONFATAL_FAILURE_)
14397 #define ASSERT_TRUE(condition) \
14398   GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
14399                       GTEST_FATAL_FAILURE_)
14400 #define ASSERT_FALSE(condition) \
14401   GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
14402                       GTEST_FATAL_FAILURE_)
14403 
14404 // Macros for testing equalities and inequalities.
14405 //
14406 //    * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
14407 //    * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
14408 //    * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
14409 //    * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
14410 //    * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
14411 //    * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
14412 //
14413 // When they are not, Google Test prints both the tested expressions and
14414 // their actual values.  The values must be compatible built-in types,
14415 // or you will get a compiler error.  By "compatible" we mean that the
14416 // values can be compared by the respective operator.
14417 //
14418 // Note:
14419 //
14420 //   1. It is possible to make a user-defined type work with
14421 //   {ASSERT|EXPECT}_??(), but that requires overloading the
14422 //   comparison operators and is thus discouraged by the Google C++
14423 //   Usage Guide.  Therefore, you are advised to use the
14424 //   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
14425 //   equal.
14426 //
14427 //   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
14428 //   pointers (in particular, C strings).  Therefore, if you use it
14429 //   with two C strings, you are testing how their locations in memory
14430 //   are related, not how their content is related.  To compare two C
14431 //   strings by content, use {ASSERT|EXPECT}_STR*().
14432 //
14433 //   3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to
14434 //   {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you
14435 //   what the actual value is when it fails, and similarly for the
14436 //   other comparisons.
14437 //
14438 //   4. Do not depend on the order in which {ASSERT|EXPECT}_??()
14439 //   evaluate their arguments, which is undefined.
14440 //
14441 //   5. These macros evaluate their arguments exactly once.
14442 //
14443 // Examples:
14444 //
14445 //   EXPECT_NE(Foo(), 5);
14446 //   EXPECT_EQ(a_pointer, NULL);
14447 //   ASSERT_LT(i, array_size);
14448 //   ASSERT_GT(records.size(), 0) << "There is no record left.";
14449 
14450 #define EXPECT_EQ(val1, val2) \
14451   EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
14452 #define EXPECT_NE(val1, val2) \
14453   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
14454 #define EXPECT_LE(val1, val2) \
14455   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
14456 #define EXPECT_LT(val1, val2) \
14457   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
14458 #define EXPECT_GE(val1, val2) \
14459   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
14460 #define EXPECT_GT(val1, val2) \
14461   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
14462 
14463 #define GTEST_ASSERT_EQ(val1, val2) \
14464   ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
14465 #define GTEST_ASSERT_NE(val1, val2) \
14466   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
14467 #define GTEST_ASSERT_LE(val1, val2) \
14468   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
14469 #define GTEST_ASSERT_LT(val1, val2) \
14470   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
14471 #define GTEST_ASSERT_GE(val1, val2) \
14472   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
14473 #define GTEST_ASSERT_GT(val1, val2) \
14474   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
14475 
14476 // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
14477 // ASSERT_XY(), which clashes with some users' own code.
14478 
14479 #if !GTEST_DONT_DEFINE_ASSERT_EQ
14480 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
14481 #endif
14482 
14483 #if !GTEST_DONT_DEFINE_ASSERT_NE
14484 # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
14485 #endif
14486 
14487 #if !GTEST_DONT_DEFINE_ASSERT_LE
14488 # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
14489 #endif
14490 
14491 #if !GTEST_DONT_DEFINE_ASSERT_LT
14492 # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
14493 #endif
14494 
14495 #if !GTEST_DONT_DEFINE_ASSERT_GE
14496 # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
14497 #endif
14498 
14499 #if !GTEST_DONT_DEFINE_ASSERT_GT
14500 # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
14501 #endif
14502 
14503 // C-string Comparisons.  All tests treat NULL and any non-NULL string
14504 // as different.  Two NULLs are equal.
14505 //
14506 //    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2
14507 //    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2
14508 //    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
14509 //    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
14510 //
14511 // For wide or narrow string objects, you can use the
14512 // {ASSERT|EXPECT}_??() macros.
14513 //
14514 // Don't depend on the order in which the arguments are evaluated,
14515 // which is undefined.
14516 //
14517 // These macros evaluate their arguments exactly once.
14518 
14519 #define EXPECT_STREQ(s1, s2) \
14520   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
14521 #define EXPECT_STRNE(s1, s2) \
14522   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
14523 #define EXPECT_STRCASEEQ(s1, s2) \
14524   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
14525 #define EXPECT_STRCASENE(s1, s2)\
14526   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
14527 
14528 #define ASSERT_STREQ(s1, s2) \
14529   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
14530 #define ASSERT_STRNE(s1, s2) \
14531   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
14532 #define ASSERT_STRCASEEQ(s1, s2) \
14533   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
14534 #define ASSERT_STRCASENE(s1, s2)\
14535   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
14536 
14537 // Macros for comparing floating-point numbers.
14538 //
14539 //    * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):
14540 //         Tests that two float values are almost equal.
14541 //    * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):
14542 //         Tests that two double values are almost equal.
14543 //    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
14544 //         Tests that v1 and v2 are within the given distance to each other.
14545 //
14546 // Google Test uses ULP-based comparison to automatically pick a default
14547 // error bound that is appropriate for the operands.  See the
14548 // FloatingPoint template class in gtest-internal.h if you are
14549 // interested in the implementation details.
14550 
14551 #define EXPECT_FLOAT_EQ(val1, val2)\
14552   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
14553                       val1, val2)
14554 
14555 #define EXPECT_DOUBLE_EQ(val1, val2)\
14556   EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
14557                       val1, val2)
14558 
14559 #define ASSERT_FLOAT_EQ(val1, val2)\
14560   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
14561                       val1, val2)
14562 
14563 #define ASSERT_DOUBLE_EQ(val1, val2)\
14564   ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
14565                       val1, val2)
14566 
14567 #define EXPECT_NEAR(val1, val2, abs_error)\
14568   EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
14569                       val1, val2, abs_error)
14570 
14571 #define ASSERT_NEAR(val1, val2, abs_error)\
14572   ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
14573                       val1, val2, abs_error)
14574 
14575 // These predicate format functions work on floating-point values, and
14576 // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
14577 //
14578 //   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
14579 
14580 // Asserts that val1 is less than, or almost equal to, val2.  Fails
14581 // otherwise.  In particular, it fails if either val1 or val2 is NaN.
14582 GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
14583                                    float val1, float val2);
14584 GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
14585                                     double val1, double val2);
14586 
14587 
14588 #if GTEST_OS_WINDOWS
14589 
14590 // Macros that test for HRESULT failure and success, these are only useful
14591 // on Windows, and rely on Windows SDK macros and APIs to compile.
14592 //
14593 //    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
14594 //
14595 // When expr unexpectedly fails or succeeds, Google Test prints the
14596 // expected result and the actual result with both a human-readable
14597 // string representation of the error, if available, as well as the
14598 // hex result code.
14599 # define EXPECT_HRESULT_SUCCEEDED(expr) \
14600     EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
14601 
14602 # define ASSERT_HRESULT_SUCCEEDED(expr) \
14603     ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
14604 
14605 # define EXPECT_HRESULT_FAILED(expr) \
14606     EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
14607 
14608 # define ASSERT_HRESULT_FAILED(expr) \
14609     ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
14610 
14611 #endif  // GTEST_OS_WINDOWS
14612 
14613 // Macros that execute statement and check that it doesn't generate new fatal
14614 // failures in the current thread.
14615 //
14616 //   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
14617 //
14618 // Examples:
14619 //
14620 //   EXPECT_NO_FATAL_FAILURE(Process());
14621 //   ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
14622 //
14623 #define ASSERT_NO_FATAL_FAILURE(statement) \
14624     GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
14625 #define EXPECT_NO_FATAL_FAILURE(statement) \
14626     GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
14627 
14628 // Causes a trace (including the given source file path and line number,
14629 // and the given message) to be included in every test failure message generated
14630 // by code in the scope of the lifetime of an instance of this class. The effect
14631 // is undone with the destruction of the instance.
14632 //
14633 // The message argument can be anything streamable to std::ostream.
14634 //
14635 // Example:
14636 //   testing::ScopedTrace trace("file.cc", 123, "message");
14637 //
14638 class GTEST_API_ ScopedTrace {
14639  public:
14640   // The c'tor pushes the given source file location and message onto
14641   // a trace stack maintained by Google Test.
14642 
14643   // Template version. Uses Message() to convert the values into strings.
14644   // Slow, but flexible.
14645   template <typename T>
14646   ScopedTrace(const char* file, int line, const T& message) {
14647     PushTrace(file, line, (Message() << message).GetString());
14648   }
14649 
14650   // Optimize for some known types.
14651   ScopedTrace(const char* file, int line, const char* message) {
14652     PushTrace(file, line, message ? message : "(null)");
14653   }
14654 
14655   ScopedTrace(const char* file, int line, const std::string& message) {
14656     PushTrace(file, line, message);
14657   }
14658 
14659   // The d'tor pops the info pushed by the c'tor.
14660   //
14661   // Note that the d'tor is not virtual in order to be efficient.
14662   // Don't inherit from ScopedTrace!
14663   ~ScopedTrace();
14664 
14665  private:
14666   void PushTrace(const char* file, int line, std::string message);
14667 
14668   GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
14669 } GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its
14670                             // c'tor and d'tor.  Therefore it doesn't
14671                             // need to be used otherwise.
14672 
14673 // Causes a trace (including the source file path, the current line
14674 // number, and the given message) to be included in every test failure
14675 // message generated by code in the current scope.  The effect is
14676 // undone when the control leaves the current scope.
14677 //
14678 // The message argument can be anything streamable to std::ostream.
14679 //
14680 // In the implementation, we include the current line number as part
14681 // of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
14682 // to appear in the same block - as long as they are on different
14683 // lines.
14684 //
14685 // Assuming that each thread maintains its own stack of traces.
14686 // Therefore, a SCOPED_TRACE() would (correctly) only affect the
14687 // assertions in its own thread.
14688 #define SCOPED_TRACE(message) \
14689   ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
14690     __FILE__, __LINE__, (message))
14691 
14692 
14693 // Compile-time assertion for type equality.
14694 // StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
14695 // the same type.  The value it returns is not interesting.
14696 //
14697 // Instead of making StaticAssertTypeEq a class template, we make it a
14698 // function template that invokes a helper class template.  This
14699 // prevents a user from misusing StaticAssertTypeEq<T1, T2> by
14700 // defining objects of that type.
14701 //
14702 // CAVEAT:
14703 //
14704 // When used inside a method of a class template,
14705 // StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
14706 // instantiated.  For example, given:
14707 //
14708 //   template <typename T> class Foo {
14709 //    public:
14710 //     void Bar() { testing::StaticAssertTypeEq<int, T>(); }
14711 //   };
14712 //
14713 // the code:
14714 //
14715 //   void Test1() { Foo<bool> foo; }
14716 //
14717 // will NOT generate a compiler error, as Foo<bool>::Bar() is never
14718 // actually instantiated.  Instead, you need:
14719 //
14720 //   void Test2() { Foo<bool> foo; foo.Bar(); }
14721 //
14722 // to cause a compiler error.
14723 template <typename T1, typename T2>
14724 bool StaticAssertTypeEq() {
14725   (void)internal::StaticAssertTypeEqHelper<T1, T2>();
14726   return true;
14727 }
14728 
14729 // Defines a test.
14730 //
14731 // The first parameter is the name of the test suite, and the second
14732 // parameter is the name of the test within the test suite.
14733 //
14734 // The convention is to end the test suite name with "Test".  For
14735 // example, a test suite for the Foo class can be named FooTest.
14736 //
14737 // Test code should appear between braces after an invocation of
14738 // this macro.  Example:
14739 //
14740 //   TEST(FooTest, InitializesCorrectly) {
14741 //     Foo foo;
14742 //     EXPECT_TRUE(foo.StatusIsOK());
14743 //   }
14744 
14745 // Note that we call GetTestTypeId() instead of GetTypeId<
14746 // ::testing::Test>() here to get the type ID of testing::Test.  This
14747 // is to work around a suspected linker bug when using Google Test as
14748 // a framework on Mac OS X.  The bug causes GetTypeId<
14749 // ::testing::Test>() to return different values depending on whether
14750 // the call is from the Google Test framework itself or from user test
14751 // code.  GetTestTypeId() is guaranteed to always return the same
14752 // value, as it always calls GetTypeId<>() from the Google Test
14753 // framework.
14754 #define GTEST_TEST(test_suite_name, test_name)             \
14755   GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
14756               ::testing::internal::GetTestTypeId())
14757 
14758 // Define this macro to 1 to omit the definition of TEST(), which
14759 // is a generic name and clashes with some other libraries.
14760 #if !GTEST_DONT_DEFINE_TEST
14761 #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
14762 #endif
14763 
14764 // Defines a test that uses a test fixture.
14765 //
14766 // The first parameter is the name of the test fixture class, which
14767 // also doubles as the test suite name.  The second parameter is the
14768 // name of the test within the test suite.
14769 //
14770 // A test fixture class must be declared earlier.  The user should put
14771 // the test code between braces after using this macro.  Example:
14772 //
14773 //   class FooTest : public testing::Test {
14774 //    protected:
14775 //     void SetUp() override { b_.AddElement(3); }
14776 //
14777 //     Foo a_;
14778 //     Foo b_;
14779 //   };
14780 //
14781 //   TEST_F(FooTest, InitializesCorrectly) {
14782 //     EXPECT_TRUE(a_.StatusIsOK());
14783 //   }
14784 //
14785 //   TEST_F(FooTest, ReturnsElementCountCorrectly) {
14786 //     EXPECT_EQ(a_.size(), 0);
14787 //     EXPECT_EQ(b_.size(), 1);
14788 //   }
14789 //
14790 // GOOGLETEST_CM0011 DO NOT DELETE
14791 #define TEST_F(test_fixture, test_name)\
14792   GTEST_TEST_(test_fixture, test_name, test_fixture, \
14793               ::testing::internal::GetTypeId<test_fixture>())
14794 
14795 // Returns a path to temporary directory.
14796 // Tries to determine an appropriate directory for the platform.
14797 GTEST_API_ std::string TempDir();
14798 
14799 #ifdef _MSC_VER
14800 #  pragma warning(pop)
14801 #endif
14802 
14803 // Dynamically registers a test with the framework.
14804 //
14805 // This is an advanced API only to be used when the `TEST` macros are
14806 // insufficient. The macros should be preferred when possible, as they avoid
14807 // most of the complexity of calling this function.
14808 //
14809 // The `factory` argument is a factory callable (move-constructible) object or
14810 // function pointer that creates a new instance of the Test object. It
14811 // handles ownership to the caller. The signature of the callable is
14812 // `Fixture*()`, where `Fixture` is the test fixture class for the test. All
14813 // tests registered with the same `test_suite_name` must return the same
14814 // fixture type. This is checked at runtime.
14815 //
14816 // The framework will infer the fixture class from the factory and will call
14817 // the `SetUpTestSuite` and `TearDownTestSuite` for it.
14818 //
14819 // Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is
14820 // undefined.
14821 //
14822 // Use case example:
14823 //
14824 // class MyFixture : public ::testing::Test {
14825 //  public:
14826 //   // All of these optional, just like in regular macro usage.
14827 //   static void SetUpTestSuite() { ... }
14828 //   static void TearDownTestSuite() { ... }
14829 //   void SetUp() override { ... }
14830 //   void TearDown() override { ... }
14831 // };
14832 //
14833 // class MyTest : public MyFixture {
14834 //  public:
14835 //   explicit MyTest(int data) : data_(data) {}
14836 //   void TestBody() override { ... }
14837 //
14838 //  private:
14839 //   int data_;
14840 // };
14841 //
14842 // void RegisterMyTests(const std::vector<int>& values) {
14843 //   for (int v : values) {
14844 //     ::testing::RegisterTest(
14845 //         "MyFixture", ("Test" + std::to_string(v)).c_str(), nullptr,
14846 //         std::to_string(v).c_str(),
14847 //         __FILE__, __LINE__,
14848 //         // Important to use the fixture type as the return type here.
14849 //         [=]() -> MyFixture* { return new MyTest(v); });
14850 //   }
14851 // }
14852 // ...
14853 // int main(int argc, char** argv) {
14854 //   std::vector<int> values_to_test = LoadValuesFromConfig();
14855 //   RegisterMyTests(values_to_test);
14856 //   ...
14857 //   return RUN_ALL_TESTS();
14858 // }
14859 //
14860 template <int&... ExplicitParameterBarrier, typename Factory>
14861 TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
14862                        const char* type_param, const char* value_param,
14863                        const char* file, int line, Factory factory) {
14864   using TestT = typename std::remove_pointer<decltype(factory())>::type;
14865 
14866   class FactoryImpl : public internal::TestFactoryBase {
14867    public:
14868     explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
14869     Test* CreateTest() override { return factory_(); }
14870 
14871    private:
14872     Factory factory_;
14873   };
14874 
14875   return internal::MakeAndRegisterTestInfo(
14876       test_suite_name, test_name, type_param, value_param,
14877       internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),
14878       internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(),
14879       internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(),
14880       new FactoryImpl{std::move(factory)});
14881 }
14882 
14883 }  // namespace testing
14884 
14885 // Use this function in main() to run all tests.  It returns 0 if all
14886 // tests are successful, or 1 otherwise.
14887 //
14888 // RUN_ALL_TESTS() should be invoked after the command line has been
14889 // parsed by InitGoogleTest().
14890 //
14891 // This function was formerly a macro; thus, it is in the global
14892 // namespace and has an all-caps name.
14893 int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
14894 
14895 inline int RUN_ALL_TESTS() {
14896   return ::testing::UnitTest::GetInstance()->Run();
14897 }
14898 
14899 GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
14900 
14901 #endif  // GTEST_INCLUDE_GTEST_GTEST_H_
14902