blob: a8344fe0710f2205f8a01e10580dc6bdef487c52 [file] [log] [blame]
Austin Schuh70cc9552019-01-21 19:46:48 -08001// 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.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080029
Austin Schuh70cc9552019-01-21 19:46:48 -080030//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080031// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -080032//
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
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080050// GOOGLETEST_CM0001 DO NOT DELETE
51
Austin Schuh70cc9552019-01-21 19:46:48 -080052#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
53#define GTEST_INCLUDE_GTEST_GTEST_H_
54
55#include <limits>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080056#include <memory>
Austin Schuh70cc9552019-01-21 19:46:48 -080057#include <ostream>
58#include <vector>
59
60// Copyright 2005, Google Inc.
61// All rights reserved.
62//
63// Redistribution and use in source and binary forms, with or without
64// modification, are permitted provided that the following conditions are
65// met:
66//
67// * Redistributions of source code must retain the above copyright
68// notice, this list of conditions and the following disclaimer.
69// * Redistributions in binary form must reproduce the above
70// copyright notice, this list of conditions and the following disclaimer
71// in the documentation and/or other materials provided with the
72// distribution.
73// * Neither the name of Google Inc. nor the names of its
74// contributors may be used to endorse or promote products derived from
75// this software without specific prior written permission.
76//
77// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
78// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
79// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
80// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
81// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
82// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
83// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
84// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
85// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080089// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -080090//
91// This header file declares functions and macros used internally by
92// Google Test. They are subject to change without notice.
93
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080094// GOOGLETEST_CM0001 DO NOT DELETE
95
Austin Schuh70cc9552019-01-21 19:46:48 -080096#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
97#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
98
99// Copyright 2005, Google Inc.
100// All rights reserved.
101//
102// Redistribution and use in source and binary forms, with or without
103// modification, are permitted provided that the following conditions are
104// met:
105//
106// * Redistributions of source code must retain the above copyright
107// notice, this list of conditions and the following disclaimer.
108// * Redistributions in binary form must reproduce the above
109// copyright notice, this list of conditions and the following disclaimer
110// in the documentation and/or other materials provided with the
111// distribution.
112// * Neither the name of Google Inc. nor the names of its
113// contributors may be used to endorse or promote products derived from
114// this software without specific prior written permission.
115//
116// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
117// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
118// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
119// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
120// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
121// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
122// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
123// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
124// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
125// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
126// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
127//
Austin Schuh70cc9552019-01-21 19:46:48 -0800128// Low-level types and utilities for porting Google Test to various
129// platforms. All macros ending with _ and symbols defined in an
130// internal namespace are subject to change without notice. Code
131// outside Google Test MUST NOT USE THEM DIRECTLY. Macros that don't
132// end with _ are part of Google Test's public API and can be used by
133// code outside Google Test.
134//
135// This file is fundamental to Google Test. All other Google Test source
136// files are expected to #include this. Therefore, it cannot #include
137// any other Google Test header.
138
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800139// GOOGLETEST_CM0001 DO NOT DELETE
140
Austin Schuh70cc9552019-01-21 19:46:48 -0800141#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
142#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
143
144// Environment-describing macros
145// -----------------------------
146//
147// Google Test can be used in many different environments. Macros in
148// this section tell Google Test what kind of environment it is being
149// used in, such that Google Test can provide environment-specific
150// features and implementations.
151//
152// Google Test tries to automatically detect the properties of its
153// environment, so users usually don't need to worry about these
154// macros. However, the automatic detection is not perfect.
155// Sometimes it's necessary for a user to define some of the following
156// macros in the build script to override Google Test's decisions.
157//
158// If the user doesn't define a macro in the list, Google Test will
159// provide a default definition. After this header is #included, all
160// macros in this list will be defined to either 1 or 0.
161//
162// Notes to maintainers:
163// - Each macro here is a user-tweakable knob; do not grow the list
164// lightly.
165// - Use #if to key off these macros. Don't use #ifdef or "#if
166// defined(...)", which will not work as these macros are ALWAYS
167// defined.
168//
169// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
170// is/isn't available.
171// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
172// are enabled.
173// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800174// is/isn't available
175// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring
176// is/isn't available
Austin Schuh70cc9552019-01-21 19:46:48 -0800177// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular
178// expressions are/aren't available.
179// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
180// is/isn't available.
181// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
182// enabled.
183// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
184// std::wstring does/doesn't work (Google Test can
185// be used where std::wstring is unavailable).
Austin Schuh70cc9552019-01-21 19:46:48 -0800186// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
187// compiler supports Microsoft's "Structured
188// Exception Handling".
189// GTEST_HAS_STREAM_REDIRECTION
190// - Define it to 1/0 to indicate whether the
191// platform supports I/O stream redirection using
192// dup() and dup2().
Austin Schuh70cc9552019-01-21 19:46:48 -0800193// GTEST_LINKED_AS_SHARED_LIBRARY
194// - Define to 1 when compiling tests that use
195// Google Test as a shared library (known as
196// DLL on Windows).
197// GTEST_CREATE_SHARED_LIBRARY
198// - Define to 1 when compiling Google Test itself
199// as a shared library.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800200// GTEST_DEFAULT_DEATH_TEST_STYLE
201// - The default value of --gtest_death_test_style.
202// The legacy default has been "fast" in the open
203// source version since 2008. The recommended value
204// is "threadsafe", and can be set in
205// custom/gtest-port.h.
Austin Schuh70cc9552019-01-21 19:46:48 -0800206
207// Platform-indicating macros
208// --------------------------
209//
210// Macros indicating the platform on which Google Test is being used
211// (a macro is defined to 1 if compiled on the given platform;
212// otherwise UNDEFINED -- it's never defined to 0.). Google Test
213// defines these macros automatically. Code outside Google Test MUST
214// NOT define them.
215//
216// GTEST_OS_AIX - IBM AIX
217// GTEST_OS_CYGWIN - Cygwin
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800218// GTEST_OS_DRAGONFLY - DragonFlyBSD
Austin Schuh70cc9552019-01-21 19:46:48 -0800219// GTEST_OS_FREEBSD - FreeBSD
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800220// GTEST_OS_FUCHSIA - Fuchsia
221// GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
Austin Schuh70cc9552019-01-21 19:46:48 -0800222// GTEST_OS_HPUX - HP-UX
223// GTEST_OS_LINUX - Linux
224// GTEST_OS_LINUX_ANDROID - Google Android
225// GTEST_OS_MAC - Mac OS X
226// GTEST_OS_IOS - iOS
227// GTEST_OS_NACL - Google Native Client (NaCl)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800228// GTEST_OS_NETBSD - NetBSD
Austin Schuh70cc9552019-01-21 19:46:48 -0800229// GTEST_OS_OPENBSD - OpenBSD
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800230// GTEST_OS_OS2 - OS/2
Austin Schuh70cc9552019-01-21 19:46:48 -0800231// GTEST_OS_QNX - QNX
232// GTEST_OS_SOLARIS - Sun Solaris
Austin Schuh70cc9552019-01-21 19:46:48 -0800233// GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile)
234// GTEST_OS_WINDOWS_DESKTOP - Windows Desktop
235// GTEST_OS_WINDOWS_MINGW - MinGW
236// GTEST_OS_WINDOWS_MOBILE - Windows Mobile
237// GTEST_OS_WINDOWS_PHONE - Windows Phone
238// GTEST_OS_WINDOWS_RT - Windows Store App/WinRT
239// GTEST_OS_ZOS - z/OS
240//
241// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
242// most stable support. Since core members of the Google Test project
243// don't have access to other platforms, support for them may be less
244// stable. If you notice any problems on your platform, please notify
245// googletestframework@googlegroups.com (patches for fixing them are
246// even more welcome!).
247//
248// It is possible that none of the GTEST_OS_* macros are defined.
249
250// Feature-indicating macros
251// -------------------------
252//
253// Macros indicating which Google Test features are available (a macro
254// is defined to 1 if the corresponding feature is supported;
255// otherwise UNDEFINED -- it's never defined to 0.). Google Test
256// defines these macros automatically. Code outside Google Test MUST
257// NOT define them.
258//
259// These macros are public so that portable tests can be written.
260// Such tests typically surround code using a feature with an #if
261// which controls that code. For example:
262//
263// #if GTEST_HAS_DEATH_TEST
264// EXPECT_DEATH(DoSomethingDeadly());
265// #endif
266//
Austin Schuh70cc9552019-01-21 19:46:48 -0800267// GTEST_HAS_DEATH_TEST - death tests
Austin Schuh70cc9552019-01-21 19:46:48 -0800268// GTEST_HAS_TYPED_TEST - typed tests
269// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
270// GTEST_IS_THREADSAFE - Google Test is thread-safe.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800271// GOOGLETEST_CM0007 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -0800272// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
273// GTEST_HAS_POSIX_RE (see above) which users can
274// define themselves.
275// GTEST_USES_SIMPLE_RE - our own simple regex is used;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800276// the above RE\b(s) are mutually exclusive.
Austin Schuh70cc9552019-01-21 19:46:48 -0800277
278// Misc public macros
279// ------------------
280//
281// GTEST_FLAG(flag_name) - references the variable corresponding to
282// the given Google Test flag.
283
284// Internal utilities
285// ------------------
286//
287// The following macros and utilities are for Google Test's INTERNAL
288// use only. Code outside Google Test MUST NOT USE THEM DIRECTLY.
289//
290// Macros for basic C++ coding:
291// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
292// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
293// variable don't have to be used.
294// GTEST_DISALLOW_ASSIGN_ - disables operator=.
295// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
296// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
297// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
298// suppressed (constant conditional).
299// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
300// is suppressed.
301//
Austin Schuh70cc9552019-01-21 19:46:48 -0800302// Synchronization:
303// Mutex, MutexLock, ThreadLocal, GetThreadCount()
304// - synchronization primitives.
305//
306// Template meta programming:
Austin Schuh70cc9552019-01-21 19:46:48 -0800307// IteratorTraits - partial implementation of std::iterator_traits, which
308// is not available in libCstd when compiled with Sun C++.
309//
Austin Schuh70cc9552019-01-21 19:46:48 -0800310//
311// Regular expressions:
312// RE - a simple regular expression class using the POSIX
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800313// Extended Regular Expression syntax on UNIX-like platforms
314// GOOGLETEST_CM0008 DO NOT DELETE
315// or a reduced regular exception syntax on other
316// platforms, including Windows.
Austin Schuh70cc9552019-01-21 19:46:48 -0800317// Logging:
318// GTEST_LOG_() - logs messages at the specified severity level.
319// LogToStderr() - directs all log messages to stderr.
320// FlushInfoLog() - flushes informational log messages.
321//
322// Stdout and stderr capturing:
323// CaptureStdout() - starts capturing stdout.
324// GetCapturedStdout() - stops capturing stdout and returns the captured
325// string.
326// CaptureStderr() - starts capturing stderr.
327// GetCapturedStderr() - stops capturing stderr and returns the captured
328// string.
329//
330// Integer types:
331// TypeWithSize - maps an integer to a int type.
332// Int32, UInt32, Int64, UInt64, TimeInMillis
333// - integers of known sizes.
334// BiggestInt - the biggest signed integer type.
335//
336// Command-line utilities:
337// GTEST_DECLARE_*() - declares a flag.
338// GTEST_DEFINE_*() - defines a flag.
339// GetInjectableArgvs() - returns the command line as a vector of strings.
340//
341// Environment variable utilities:
342// GetEnv() - gets the value of an environment variable.
343// BoolFromGTestEnv() - parses a bool environment variable.
344// Int32FromGTestEnv() - parses an Int32 environment variable.
345// StringFromGTestEnv() - parses a string environment variable.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800346//
347// Deprecation warnings:
348// GTEST_INTERNAL_DEPRECATED(message) - attribute marking a function as
349// deprecated; calling a marked function
350// should generate a compiler warning
Austin Schuh70cc9552019-01-21 19:46:48 -0800351
352#include <ctype.h> // for isspace, etc
353#include <stddef.h> // for ptrdiff_t
Austin Schuh70cc9552019-01-21 19:46:48 -0800354#include <stdio.h>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800355#include <stdlib.h>
Austin Schuh70cc9552019-01-21 19:46:48 -0800356#include <string.h>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800357#include <memory>
358#include <type_traits>
359
Austin Schuh70cc9552019-01-21 19:46:48 -0800360#ifndef _WIN32_WCE
361# include <sys/types.h>
362# include <sys/stat.h>
363#endif // !_WIN32_WCE
364
365#if defined __APPLE__
366# include <AvailabilityMacros.h>
367# include <TargetConditionals.h>
368#endif
369
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800370// Brings in the definition of HAS_GLOBAL_STRING. This must be done
371// BEFORE we test HAS_GLOBAL_STRING.
372#include <string> // NOLINT
Austin Schuh70cc9552019-01-21 19:46:48 -0800373#include <algorithm> // NOLINT
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800374#include <iostream> // NOLINT
375#include <sstream> // NOLINT
376#include <tuple>
Austin Schuh70cc9552019-01-21 19:46:48 -0800377#include <utility>
378#include <vector> // NOLINT
379
380// Copyright 2015, Google Inc.
381// All rights reserved.
382//
383// Redistribution and use in source and binary forms, with or without
384// modification, are permitted provided that the following conditions are
385// met:
386//
387// * Redistributions of source code must retain the above copyright
388// notice, this list of conditions and the following disclaimer.
389// * Redistributions in binary form must reproduce the above
390// copyright notice, this list of conditions and the following disclaimer
391// in the documentation and/or other materials provided with the
392// distribution.
393// * Neither the name of Google Inc. nor the names of its
394// contributors may be used to endorse or promote products derived from
395// this software without specific prior written permission.
396//
397// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
398// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
399// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
400// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
401// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
402// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
403// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
404// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
405// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
406// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
407// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
408//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800409// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -0800410//
411// This header file defines the GTEST_OS_* macro.
412// It is separate from gtest-port.h so that custom/gtest-port.h can include it.
413
414#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
415#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
416
417// Determines the platform on which Google Test is compiled.
418#ifdef __CYGWIN__
419# define GTEST_OS_CYGWIN 1
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800420# elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
421# define GTEST_OS_WINDOWS_MINGW 1
422# define GTEST_OS_WINDOWS 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800423#elif defined _WIN32
424# define GTEST_OS_WINDOWS 1
425# ifdef _WIN32_WCE
426# define GTEST_OS_WINDOWS_MOBILE 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800427# elif defined(WINAPI_FAMILY)
428# include <winapifamily.h>
429# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
430# define GTEST_OS_WINDOWS_DESKTOP 1
431# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
432# define GTEST_OS_WINDOWS_PHONE 1
433# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
434# define GTEST_OS_WINDOWS_RT 1
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800435# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
436# define GTEST_OS_WINDOWS_PHONE 1
437# define GTEST_OS_WINDOWS_TV_TITLE 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800438# else
439 // WINAPI_FAMILY defined but no known partition matched.
440 // Default to desktop.
441# define GTEST_OS_WINDOWS_DESKTOP 1
442# endif
443# else
444# define GTEST_OS_WINDOWS_DESKTOP 1
445# endif // _WIN32_WCE
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800446#elif defined __OS2__
447# define GTEST_OS_OS2 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800448#elif defined __APPLE__
449# define GTEST_OS_MAC 1
450# if TARGET_OS_IPHONE
451# define GTEST_OS_IOS 1
452# endif
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800453#elif defined __DragonFly__
454# define GTEST_OS_DRAGONFLY 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800455#elif defined __FreeBSD__
456# define GTEST_OS_FREEBSD 1
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800457#elif defined __Fuchsia__
458# define GTEST_OS_FUCHSIA 1
459#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
460# define GTEST_OS_GNU_KFREEBSD 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800461#elif defined __linux__
462# define GTEST_OS_LINUX 1
463# if defined __ANDROID__
464# define GTEST_OS_LINUX_ANDROID 1
465# endif
466#elif defined __MVS__
467# define GTEST_OS_ZOS 1
468#elif defined(__sun) && defined(__SVR4)
469# define GTEST_OS_SOLARIS 1
470#elif defined(_AIX)
471# define GTEST_OS_AIX 1
472#elif defined(__hpux)
473# define GTEST_OS_HPUX 1
474#elif defined __native_client__
475# define GTEST_OS_NACL 1
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800476#elif defined __NetBSD__
477# define GTEST_OS_NETBSD 1
Austin Schuh70cc9552019-01-21 19:46:48 -0800478#elif defined __OpenBSD__
479# define GTEST_OS_OPENBSD 1
480#elif defined __QNX__
481# define GTEST_OS_QNX 1
482#endif // __CYGWIN__
483
484#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
485// Copyright 2015, Google Inc.
486// All rights reserved.
487//
488// Redistribution and use in source and binary forms, with or without
489// modification, are permitted provided that the following conditions are
490// met:
491//
492// * Redistributions of source code must retain the above copyright
493// notice, this list of conditions and the following disclaimer.
494// * Redistributions in binary form must reproduce the above
495// copyright notice, this list of conditions and the following disclaimer
496// in the documentation and/or other materials provided with the
497// distribution.
498// * Neither the name of Google Inc. nor the names of its
499// contributors may be used to endorse or promote products derived from
500// this software without specific prior written permission.
501//
502// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
503// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
504// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
505// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
506// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
507// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
508// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
509// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
510// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
511// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
512// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
513//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800514// Injection point for custom user configurations. See README for details
Austin Schuh70cc9552019-01-21 19:46:48 -0800515//
516// ** Custom implementation starts here **
517
518#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
519#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
520
521#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
522
523#if !defined(GTEST_DEV_EMAIL_)
524# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
525# define GTEST_FLAG_PREFIX_ "gtest_"
526# define GTEST_FLAG_PREFIX_DASH_ "gtest-"
527# define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
528# define GTEST_NAME_ "Google Test"
529# define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
530#endif // !defined(GTEST_DEV_EMAIL_)
531
532#if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
533# define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
534#endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
535
536// Determines the version of gcc that is used to compile this.
537#ifdef __GNUC__
538// 40302 means version 4.3.2.
539# define GTEST_GCC_VER_ \
540 (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
541#endif // __GNUC__
542
543// Macros for disabling Microsoft Visual C++ warnings.
544//
545// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
546// /* code that triggers warnings C4800 and C4385 */
547// GTEST_DISABLE_MSC_WARNINGS_POP_()
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800548#if defined(_MSC_VER)
Austin Schuh70cc9552019-01-21 19:46:48 -0800549# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
550 __pragma(warning(push)) \
551 __pragma(warning(disable: warnings))
552# define GTEST_DISABLE_MSC_WARNINGS_POP_() \
553 __pragma(warning(pop))
554#else
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800555// Not all compilers are MSVC
Austin Schuh70cc9552019-01-21 19:46:48 -0800556# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
557# define GTEST_DISABLE_MSC_WARNINGS_POP_()
558#endif
559
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800560// Clang on Windows does not understand MSVC's pragma warning.
561// We need clang-specific way to disable function deprecation warning.
562#ifdef __clang__
563# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
564 _Pragma("clang diagnostic push") \
565 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
566 _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
567#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
568 _Pragma("clang diagnostic pop")
569#else
570# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
571 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
572# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
573 GTEST_DISABLE_MSC_WARNINGS_POP_()
Austin Schuh70cc9552019-01-21 19:46:48 -0800574#endif
575
576// Brings in definitions for functions used in the testing::internal::posix
577// namespace (read, write, close, chdir, isatty, stat). We do not currently
578// use them on Windows Mobile.
579#if GTEST_OS_WINDOWS
580# if !GTEST_OS_WINDOWS_MOBILE
581# include <direct.h>
582# include <io.h>
583# endif
584// In order to avoid having to include <windows.h>, use forward declaration
585#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
586// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
587// separate (equivalent) structs, instead of using typedef
588typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
589#else
590// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
591// This assumption is verified by
592// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
593typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
594#endif
595#else
596// This assumes that non-Windows OSes provide unistd.h. For OSes where this
597// is not the case, we need to include headers that provide the functions
598// mentioned above.
599# include <unistd.h>
600# include <strings.h>
601#endif // GTEST_OS_WINDOWS
602
603#if GTEST_OS_LINUX_ANDROID
604// Used to define __ANDROID_API__ matching the target NDK API level.
605# include <android/api-level.h> // NOLINT
606#endif
607
608// Defines this to true iff Google Test can use POSIX regular expressions.
609#ifndef GTEST_HAS_POSIX_RE
610# if GTEST_OS_LINUX_ANDROID
611// On Android, <regex.h> is only available starting with Gingerbread.
612# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
613# else
614# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
615# endif
616#endif
617
618#if GTEST_USES_PCRE
619// The appropriate headers have already been included.
620
621#elif GTEST_HAS_POSIX_RE
622
623// On some platforms, <regex.h> needs someone to define size_t, and
624// won't compile otherwise. We can #include it here as we already
625// included <stdlib.h>, which is guaranteed to define size_t through
626// <stddef.h>.
627# include <regex.h> // NOLINT
628
629# define GTEST_USES_POSIX_RE 1
630
631#elif GTEST_OS_WINDOWS
632
633// <regex.h> is not available on Windows. Use our own simple regex
634// implementation instead.
635# define GTEST_USES_SIMPLE_RE 1
636
637#else
638
639// <regex.h> may not be available on this platform. Use our own
640// simple regex implementation instead.
641# define GTEST_USES_SIMPLE_RE 1
642
643#endif // GTEST_USES_PCRE
644
645#ifndef GTEST_HAS_EXCEPTIONS
646// The user didn't tell us whether exceptions are enabled, so we need
647// to figure it out.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800648# if defined(_MSC_VER) && defined(_CPPUNWIND)
649// MSVC defines _CPPUNWIND to 1 iff exceptions are enabled.
650# define GTEST_HAS_EXCEPTIONS 1
651# elif defined(__BORLANDC__)
652// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
Austin Schuh70cc9552019-01-21 19:46:48 -0800653// macro to enable exceptions, so we'll do the same.
654// Assumes that exceptions are enabled by default.
655# ifndef _HAS_EXCEPTIONS
656# define _HAS_EXCEPTIONS 1
657# endif // _HAS_EXCEPTIONS
658# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
659# elif defined(__clang__)
660// clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,
661// but iff cleanups are enabled after that. In Obj-C++ files, there can be
662// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
663// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
664// exceptions starting at clang r206352, but which checked for cleanups prior to
665// that. To reliably check for C++ exception availability with clang, check for
666// __EXCEPTIONS && __has_feature(cxx_exceptions).
667# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
668# elif defined(__GNUC__) && __EXCEPTIONS
669// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
670# define GTEST_HAS_EXCEPTIONS 1
671# elif defined(__SUNPRO_CC)
672// Sun Pro CC supports exceptions. However, there is no compile-time way of
673// detecting whether they are enabled or not. Therefore, we assume that
674// they are enabled unless the user tells us otherwise.
675# define GTEST_HAS_EXCEPTIONS 1
676# elif defined(__IBMCPP__) && __EXCEPTIONS
677// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
678# define GTEST_HAS_EXCEPTIONS 1
679# elif defined(__HP_aCC)
680// Exception handling is in effect by default in HP aCC compiler. It has to
681// be turned of by +noeh compiler option if desired.
682# define GTEST_HAS_EXCEPTIONS 1
683# else
684// For other compilers, we assume exceptions are disabled to be
685// conservative.
686# define GTEST_HAS_EXCEPTIONS 0
687# endif // defined(_MSC_VER) || defined(__BORLANDC__)
688#endif // GTEST_HAS_EXCEPTIONS
689
690#if !defined(GTEST_HAS_STD_STRING)
691// Even though we don't use this macro any longer, we keep it in case
692// some clients still depend on it.
693# define GTEST_HAS_STD_STRING 1
694#elif !GTEST_HAS_STD_STRING
695// The user told us that ::std::string isn't available.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800696# error "::std::string isn't available."
Austin Schuh70cc9552019-01-21 19:46:48 -0800697#endif // !defined(GTEST_HAS_STD_STRING)
698
699#ifndef GTEST_HAS_GLOBAL_STRING
Austin Schuh70cc9552019-01-21 19:46:48 -0800700# define GTEST_HAS_GLOBAL_STRING 0
Austin Schuh70cc9552019-01-21 19:46:48 -0800701#endif // GTEST_HAS_GLOBAL_STRING
702
703#ifndef GTEST_HAS_STD_WSTRING
704// The user didn't tell us whether ::std::wstring is available, so we need
705// to figure it out.
Austin Schuh70cc9552019-01-21 19:46:48 -0800706// Cygwin 1.7 and below doesn't support ::std::wstring.
707// Solaris' libc++ doesn't support it either. Android has
708// no support for it at least as recent as Froyo (2.2).
709# define GTEST_HAS_STD_WSTRING \
710 (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
711
712#endif // GTEST_HAS_STD_WSTRING
713
714#ifndef GTEST_HAS_GLOBAL_WSTRING
715// The user didn't tell us whether ::wstring is available, so we need
716// to figure it out.
717# define GTEST_HAS_GLOBAL_WSTRING \
718 (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
719#endif // GTEST_HAS_GLOBAL_WSTRING
720
721// Determines whether RTTI is available.
722#ifndef GTEST_HAS_RTTI
723// The user didn't tell us whether RTTI is enabled, so we need to
724// figure it out.
725
726# ifdef _MSC_VER
727
728# ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled.
729# define GTEST_HAS_RTTI 1
730# else
731# define GTEST_HAS_RTTI 0
732# endif
733
734// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800735# elif defined(__GNUC__)
Austin Schuh70cc9552019-01-21 19:46:48 -0800736
737# ifdef __GXX_RTTI
738// When building against STLport with the Android NDK and with
739// -frtti -fno-exceptions, the build fails at link time with undefined
740// references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
741// so disable RTTI when detected.
742# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
743 !defined(__EXCEPTIONS)
744# define GTEST_HAS_RTTI 0
745# else
746# define GTEST_HAS_RTTI 1
747# endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
748# else
749# define GTEST_HAS_RTTI 0
750# endif // __GXX_RTTI
751
752// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
753// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
754// first version with C++ support.
755# elif defined(__clang__)
756
757# define GTEST_HAS_RTTI __has_feature(cxx_rtti)
758
759// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
760// both the typeid and dynamic_cast features are present.
761# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
762
763# ifdef __RTTI_ALL__
764# define GTEST_HAS_RTTI 1
765# else
766# define GTEST_HAS_RTTI 0
767# endif
768
769# else
770
771// For all other compilers, we assume RTTI is enabled.
772# define GTEST_HAS_RTTI 1
773
774# endif // _MSC_VER
775
776#endif // GTEST_HAS_RTTI
777
778// It's this header's responsibility to #include <typeinfo> when RTTI
779// is enabled.
780#if GTEST_HAS_RTTI
781# include <typeinfo>
782#endif
783
784// Determines whether Google Test can use the pthreads library.
785#ifndef GTEST_HAS_PTHREAD
786// The user didn't tell us explicitly, so we make reasonable assumptions about
787// which platforms have pthreads support.
788//
789// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
790// to your compiler flags.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800791#define GTEST_HAS_PTHREAD \
792 (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
793 GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
794 GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD)
Austin Schuh70cc9552019-01-21 19:46:48 -0800795#endif // GTEST_HAS_PTHREAD
796
797#if GTEST_HAS_PTHREAD
798// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
799// true.
800# include <pthread.h> // NOLINT
801
802// For timespec and nanosleep, used below.
803# include <time.h> // NOLINT
804#endif
805
Austin Schuh70cc9552019-01-21 19:46:48 -0800806// Determines whether clone(2) is supported.
807// Usually it will only be available on Linux, excluding
808// Linux on the Itanium architecture.
809// Also see http://linux.die.net/man/2/clone.
810#ifndef GTEST_HAS_CLONE
811// The user didn't tell us, so we need to figure it out.
812
813# if GTEST_OS_LINUX && !defined(__ia64__)
814# if GTEST_OS_LINUX_ANDROID
815// On Android, clone() became available at different API levels for each 32-bit
816// architecture.
817# if defined(__LP64__) || \
818 (defined(__arm__) && __ANDROID_API__ >= 9) || \
819 (defined(__mips__) && __ANDROID_API__ >= 12) || \
820 (defined(__i386__) && __ANDROID_API__ >= 17)
821# define GTEST_HAS_CLONE 1
822# else
823# define GTEST_HAS_CLONE 0
824# endif
825# else
826# define GTEST_HAS_CLONE 1
827# endif
828# else
829# define GTEST_HAS_CLONE 0
830# endif // GTEST_OS_LINUX && !defined(__ia64__)
831
832#endif // GTEST_HAS_CLONE
833
834// Determines whether to support stream redirection. This is used to test
835// output correctness and to implement death tests.
836#ifndef GTEST_HAS_STREAM_REDIRECTION
837// By default, we assume that stream redirection is supported on all
838// platforms except known mobile ones.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800839# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
Austin Schuh70cc9552019-01-21 19:46:48 -0800840# define GTEST_HAS_STREAM_REDIRECTION 0
841# else
842# define GTEST_HAS_STREAM_REDIRECTION 1
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800843# endif // !GTEST_OS_WINDOWS_MOBILE
Austin Schuh70cc9552019-01-21 19:46:48 -0800844#endif // GTEST_HAS_STREAM_REDIRECTION
845
846// Determines whether to support death tests.
Austin Schuh70cc9552019-01-21 19:46:48 -0800847// pops up a dialog window that cannot be suppressed programmatically.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800848#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
849 (GTEST_OS_MAC && !GTEST_OS_IOS) || \
850 (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || \
Austin Schuh70cc9552019-01-21 19:46:48 -0800851 GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800852 GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
853 GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || GTEST_OS_DRAGONFLY || \
854 GTEST_OS_GNU_KFREEBSD)
Austin Schuh70cc9552019-01-21 19:46:48 -0800855# define GTEST_HAS_DEATH_TEST 1
856#endif
857
Austin Schuh70cc9552019-01-21 19:46:48 -0800858// Determines whether to support type-driven tests.
859
860// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
861// Sun Pro CC, IBM Visual Age, and HP aCC support.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800862#if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
Austin Schuh70cc9552019-01-21 19:46:48 -0800863 defined(__IBMCPP__) || defined(__HP_aCC)
864# define GTEST_HAS_TYPED_TEST 1
865# define GTEST_HAS_TYPED_TEST_P 1
866#endif
867
Austin Schuh70cc9552019-01-21 19:46:48 -0800868// Determines whether the system compiler uses UTF-16 for encoding wide strings.
869#define GTEST_WIDE_STRING_USES_UTF16_ \
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800870 (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
Austin Schuh70cc9552019-01-21 19:46:48 -0800871
872// Determines whether test results can be streamed to a socket.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800873#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \
874 GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
Austin Schuh70cc9552019-01-21 19:46:48 -0800875# define GTEST_CAN_STREAM_RESULTS_ 1
876#endif
877
878// Defines some utility macros.
879
880// The GNU compiler emits a warning if nested "if" statements are followed by
881// an "else" statement and braces are not used to explicitly disambiguate the
882// "else" binding. This leads to problems with code like:
883//
884// if (gate)
885// ASSERT_*(condition) << "Some message";
886//
887// The "switch (0) case 0:" idiom is used to suppress this.
888#ifdef __INTEL_COMPILER
889# define GTEST_AMBIGUOUS_ELSE_BLOCKER_
890#else
891# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT
892#endif
893
894// Use this annotation at the end of a struct/class definition to
895// prevent the compiler from optimizing away instances that are never
896// used. This is useful when all interesting logic happens inside the
897// c'tor and / or d'tor. Example:
898//
899// struct Foo {
900// Foo() { ... }
901// } GTEST_ATTRIBUTE_UNUSED_;
902//
903// Also use it after a variable or parameter declaration to tell the
904// compiler the variable/parameter does not have to be used.
905#if defined(__GNUC__) && !defined(COMPILER_ICC)
906# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
907#elif defined(__clang__)
908# if __has_attribute(unused)
909# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
910# endif
911#endif
912#ifndef GTEST_ATTRIBUTE_UNUSED_
913# define GTEST_ATTRIBUTE_UNUSED_
914#endif
915
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800916// Use this annotation before a function that takes a printf format string.
917#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)
918# if defined(__MINGW_PRINTF_FORMAT)
919// MinGW has two different printf implementations. Ensure the format macro
920// matches the selected implementation. See
921// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
922# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
923 __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \
924 first_to_check)))
925# else
926# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
927 __attribute__((__format__(__printf__, string_index, first_to_check)))
928# endif
929#else
930# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
931#endif
932
933
Austin Schuh70cc9552019-01-21 19:46:48 -0800934// A macro to disallow operator=
935// This should be used in the private: declarations for a class.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800936#define GTEST_DISALLOW_ASSIGN_(type) \
937 void operator=(type const &) = delete
Austin Schuh70cc9552019-01-21 19:46:48 -0800938
939// A macro to disallow copy constructor and operator=
940// This should be used in the private: declarations for a class.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800941#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
942 type(type const &) = delete; \
Austin Schuh70cc9552019-01-21 19:46:48 -0800943 GTEST_DISALLOW_ASSIGN_(type)
944
945// Tell the compiler to warn about unused return values for functions declared
946// with this macro. The macro should be used on function declarations
947// following the argument list:
948//
949// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800950#if defined(__GNUC__) && !defined(COMPILER_ICC)
Austin Schuh70cc9552019-01-21 19:46:48 -0800951# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
952#else
953# define GTEST_MUST_USE_RESULT_
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800954#endif // __GNUC__ && !COMPILER_ICC
Austin Schuh70cc9552019-01-21 19:46:48 -0800955
956// MS C++ compiler emits warning when a conditional expression is compile time
957// constant. In some contexts this warning is false positive and needs to be
958// suppressed. Use the following two macros in such cases:
959//
960// GTEST_INTENTIONAL_CONST_COND_PUSH_()
961// while (true) {
962// GTEST_INTENTIONAL_CONST_COND_POP_()
963// }
964# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
965 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
966# define GTEST_INTENTIONAL_CONST_COND_POP_() \
967 GTEST_DISABLE_MSC_WARNINGS_POP_()
968
969// Determine whether the compiler supports Microsoft's Structured Exception
970// Handling. This is supported by several Windows compilers but generally
971// does not exist on any other system.
972#ifndef GTEST_HAS_SEH
973// The user didn't tell us, so we need to figure it out.
974
975# if defined(_MSC_VER) || defined(__BORLANDC__)
976// These two compilers are known to support SEH.
977# define GTEST_HAS_SEH 1
978# else
979// Assume no SEH.
980# define GTEST_HAS_SEH 0
981# endif
982
Austin Schuh70cc9552019-01-21 19:46:48 -0800983#endif // GTEST_HAS_SEH
984
Austin Schuh1d1e6ea2020-12-23 21:56:30 -0800985#ifndef GTEST_IS_THREADSAFE
986
987#define GTEST_IS_THREADSAFE \
988 (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \
989 (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \
990 GTEST_HAS_PTHREAD)
991
992#endif // GTEST_IS_THREADSAFE
993
994// GTEST_API_ qualifies all symbols that must be exported. The definitions below
995// are guarded by #ifndef to give embedders a chance to define GTEST_API_ in
996// gtest/internal/custom/gtest-port.h
997#ifndef GTEST_API_
998
Austin Schuh70cc9552019-01-21 19:46:48 -0800999#ifdef _MSC_VER
1000# if GTEST_LINKED_AS_SHARED_LIBRARY
1001# define GTEST_API_ __declspec(dllimport)
1002# elif GTEST_CREATE_SHARED_LIBRARY
1003# define GTEST_API_ __declspec(dllexport)
1004# endif
1005#elif __GNUC__ >= 4 || defined(__clang__)
1006# define GTEST_API_ __attribute__((visibility ("default")))
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001007#endif // _MSC_VER
1008
1009#endif // GTEST_API_
Austin Schuh70cc9552019-01-21 19:46:48 -08001010
1011#ifndef GTEST_API_
1012# define GTEST_API_
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001013#endif // GTEST_API_
1014
1015#ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
1016# define GTEST_DEFAULT_DEATH_TEST_STYLE "fast"
1017#endif // GTEST_DEFAULT_DEATH_TEST_STYLE
Austin Schuh70cc9552019-01-21 19:46:48 -08001018
1019#ifdef __GNUC__
1020// Ask the compiler to never inline a given function.
1021# define GTEST_NO_INLINE_ __attribute__((noinline))
1022#else
1023# define GTEST_NO_INLINE_
1024#endif
1025
1026// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001027#if !defined(GTEST_HAS_CXXABI_H_)
1028# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
1029# define GTEST_HAS_CXXABI_H_ 1
1030# else
1031# define GTEST_HAS_CXXABI_H_ 0
1032# endif
Austin Schuh70cc9552019-01-21 19:46:48 -08001033#endif
1034
1035// A function level attribute to disable checking for use of uninitialized
1036// memory when built with MemorySanitizer.
1037#if defined(__clang__)
1038# if __has_feature(memory_sanitizer)
1039# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
1040 __attribute__((no_sanitize_memory))
1041# else
1042# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
1043# endif // __has_feature(memory_sanitizer)
1044#else
1045# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
1046#endif // __clang__
1047
1048// A function level attribute to disable AddressSanitizer instrumentation.
1049#if defined(__clang__)
1050# if __has_feature(address_sanitizer)
1051# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
1052 __attribute__((no_sanitize_address))
1053# else
1054# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
1055# endif // __has_feature(address_sanitizer)
1056#else
1057# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
1058#endif // __clang__
1059
1060// A function level attribute to disable ThreadSanitizer instrumentation.
1061#if defined(__clang__)
1062# if __has_feature(thread_sanitizer)
1063# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \
1064 __attribute__((no_sanitize_thread))
1065# else
1066# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
1067# endif // __has_feature(thread_sanitizer)
1068#else
1069# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
1070#endif // __clang__
1071
1072namespace testing {
1073
1074class Message;
1075
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001076// Legacy imports for backwards compatibility.
1077// New code should use std:: names directly.
1078using std::get;
1079using std::make_tuple;
1080using std::tuple;
1081using std::tuple_element;
1082using std::tuple_size;
Austin Schuh70cc9552019-01-21 19:46:48 -08001083
1084namespace internal {
1085
1086// A secret type that Google Test users don't know about. It has no
1087// definition on purpose. Therefore it's impossible to create a
1088// Secret object, which is what we want.
1089class Secret;
1090
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001091// The GTEST_COMPILE_ASSERT_ is a legacy macro used to verify that a compile
1092// time expression is true (in new code, use static_assert instead). For
1093// example, you could use it to verify the size of a static array:
Austin Schuh70cc9552019-01-21 19:46:48 -08001094//
1095// GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,
1096// names_incorrect_size);
1097//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001098// The second argument to the macro must be a valid C++ identifier. If the
1099// expression is false, compiler will issue an error containing this identifier.
1100#define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
Austin Schuh70cc9552019-01-21 19:46:48 -08001101
1102// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
1103//
1104// This template is declared, but intentionally undefined.
1105template <typename T1, typename T2>
1106struct StaticAssertTypeEqHelper;
1107
1108template <typename T>
1109struct StaticAssertTypeEqHelper<T, T> {
1110 enum { value = true };
1111};
1112
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001113// Same as std::is_same<>.
1114template <typename T, typename U>
1115struct IsSame {
1116 enum { value = false };
1117};
1118template <typename T>
1119struct IsSame<T, T> {
1120 enum { value = true };
1121};
1122
Austin Schuh70cc9552019-01-21 19:46:48 -08001123// Evaluates to the number of elements in 'array'.
1124#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
1125
1126#if GTEST_HAS_GLOBAL_STRING
1127typedef ::string string;
1128#else
1129typedef ::std::string string;
1130#endif // GTEST_HAS_GLOBAL_STRING
1131
1132#if GTEST_HAS_GLOBAL_WSTRING
1133typedef ::wstring wstring;
1134#elif GTEST_HAS_STD_WSTRING
1135typedef ::std::wstring wstring;
1136#endif // GTEST_HAS_GLOBAL_WSTRING
1137
1138// A helper for suppressing warnings on constant condition. It just
1139// returns 'condition'.
1140GTEST_API_ bool IsTrue(bool condition);
1141
Austin Schuh70cc9552019-01-21 19:46:48 -08001142// Defines RE.
1143
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001144#if GTEST_USES_PCRE
1145// if used, PCRE is injected by custom/gtest-port.h
1146#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
1147
Austin Schuh70cc9552019-01-21 19:46:48 -08001148// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
1149// Regular Expression syntax.
1150class GTEST_API_ RE {
1151 public:
1152 // A copy constructor is required by the Standard to initialize object
1153 // references from r-values.
1154 RE(const RE& other) { Init(other.pattern()); }
1155
1156 // Constructs an RE from a string.
1157 RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
1158
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001159# if GTEST_HAS_GLOBAL_STRING
Austin Schuh70cc9552019-01-21 19:46:48 -08001160
1161 RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
1162
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001163# endif // GTEST_HAS_GLOBAL_STRING
Austin Schuh70cc9552019-01-21 19:46:48 -08001164
1165 RE(const char* regex) { Init(regex); } // NOLINT
1166 ~RE();
1167
1168 // Returns the string representation of the regex.
1169 const char* pattern() const { return pattern_; }
1170
1171 // FullMatch(str, re) returns true iff regular expression re matches
1172 // the entire str.
1173 // PartialMatch(str, re) returns true iff regular expression re
1174 // matches a substring of str (including str itself).
Austin Schuh70cc9552019-01-21 19:46:48 -08001175 static bool FullMatch(const ::std::string& str, const RE& re) {
1176 return FullMatch(str.c_str(), re);
1177 }
1178 static bool PartialMatch(const ::std::string& str, const RE& re) {
1179 return PartialMatch(str.c_str(), re);
1180 }
1181
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001182# if GTEST_HAS_GLOBAL_STRING
Austin Schuh70cc9552019-01-21 19:46:48 -08001183
1184 static bool FullMatch(const ::string& str, const RE& re) {
1185 return FullMatch(str.c_str(), re);
1186 }
1187 static bool PartialMatch(const ::string& str, const RE& re) {
1188 return PartialMatch(str.c_str(), re);
1189 }
1190
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001191# endif // GTEST_HAS_GLOBAL_STRING
Austin Schuh70cc9552019-01-21 19:46:48 -08001192
1193 static bool FullMatch(const char* str, const RE& re);
1194 static bool PartialMatch(const char* str, const RE& re);
1195
1196 private:
1197 void Init(const char* regex);
Austin Schuh70cc9552019-01-21 19:46:48 -08001198 const char* pattern_;
1199 bool is_valid_;
1200
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001201# if GTEST_USES_POSIX_RE
Austin Schuh70cc9552019-01-21 19:46:48 -08001202
1203 regex_t full_regex_; // For FullMatch().
1204 regex_t partial_regex_; // For PartialMatch().
1205
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001206# else // GTEST_USES_SIMPLE_RE
Austin Schuh70cc9552019-01-21 19:46:48 -08001207
1208 const char* full_pattern_; // For FullMatch();
1209
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001210# endif
Austin Schuh70cc9552019-01-21 19:46:48 -08001211
1212 GTEST_DISALLOW_ASSIGN_(RE);
1213};
1214
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001215#endif // GTEST_USES_PCRE
1216
Austin Schuh70cc9552019-01-21 19:46:48 -08001217// Formats a source file path and a line number as they would appear
1218// in an error message from the compiler used to compile this code.
1219GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
1220
1221// Formats a file location for compiler-independent XML output.
1222// Although this function is not platform dependent, we put it next to
1223// FormatFileLocation in order to contrast the two functions.
1224GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
1225 int line);
1226
1227// Defines logging utilities:
1228// GTEST_LOG_(severity) - logs messages at the specified severity level. The
1229// message itself is streamed into the macro.
1230// LogToStderr() - directs all log messages to stderr.
1231// FlushInfoLog() - flushes informational log messages.
1232
1233enum GTestLogSeverity {
1234 GTEST_INFO,
1235 GTEST_WARNING,
1236 GTEST_ERROR,
1237 GTEST_FATAL
1238};
1239
1240// Formats log entry severity, provides a stream object for streaming the
1241// log message, and terminates the message with a newline when going out of
1242// scope.
1243class GTEST_API_ GTestLog {
1244 public:
1245 GTestLog(GTestLogSeverity severity, const char* file, int line);
1246
1247 // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
1248 ~GTestLog();
1249
1250 ::std::ostream& GetStream() { return ::std::cerr; }
1251
1252 private:
1253 const GTestLogSeverity severity_;
1254
1255 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
1256};
1257
1258#if !defined(GTEST_LOG_)
1259
1260# define GTEST_LOG_(severity) \
1261 ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
1262 __FILE__, __LINE__).GetStream()
1263
1264inline void LogToStderr() {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001265inline void FlushInfoLog() { fflush(nullptr); }
Austin Schuh70cc9552019-01-21 19:46:48 -08001266
1267#endif // !defined(GTEST_LOG_)
1268
1269#if !defined(GTEST_CHECK_)
1270// INTERNAL IMPLEMENTATION - DO NOT USE.
1271//
1272// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
1273// is not satisfied.
1274// Synopsys:
1275// GTEST_CHECK_(boolean_condition);
1276// or
1277// GTEST_CHECK_(boolean_condition) << "Additional message";
1278//
1279// This checks the condition and if the condition is not satisfied
1280// it prints message about the condition violation, including the
1281// condition itself, plus additional message streamed into it, if any,
1282// and then it aborts the program. It aborts the program irrespective of
1283// whether it is built in the debug mode or not.
1284# define GTEST_CHECK_(condition) \
1285 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1286 if (::testing::internal::IsTrue(condition)) \
1287 ; \
1288 else \
1289 GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
1290#endif // !defined(GTEST_CHECK_)
1291
1292// An all-mode assert to verify that the given POSIX-style function
1293// call returns 0 (indicating success). Known limitation: this
1294// doesn't expand to a balanced 'if' statement, so enclose the macro
1295// in {} if you need to use it as the only statement in an 'if'
1296// branch.
1297#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
1298 if (const int gtest_error = (posix_call)) \
1299 GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
1300 << gtest_error
1301
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001302// Adds reference to a type if it is not a reference type,
1303// otherwise leaves it unchanged. This is the same as
1304// tr1::add_reference, which is not widely available yet.
Austin Schuh70cc9552019-01-21 19:46:48 -08001305template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001306struct AddReference { typedef T& type; }; // NOLINT
1307template <typename T>
1308struct AddReference<T&> { typedef T& type; }; // NOLINT
1309
1310// A handy wrapper around AddReference that works when the argument T
1311// depends on template parameters.
1312#define GTEST_ADD_REFERENCE_(T) \
1313 typename ::testing::internal::AddReference<T>::type
1314
1315// Transforms "T" into "const T&" according to standard reference collapsing
1316// rules (this is only needed as a backport for C++98 compilers that do not
1317// support reference collapsing). Specifically, it transforms:
1318//
1319// char ==> const char&
1320// const char ==> const char&
1321// char& ==> char&
1322// const char& ==> const char&
1323//
1324// Note that the non-const reference will not have "const" added. This is
1325// standard, and necessary so that "T" can always bind to "const T&".
1326template <typename T>
1327struct ConstRef { typedef const T& type; };
1328template <typename T>
1329struct ConstRef<T&> { typedef T& type; };
1330
1331// The argument T must depend on some template parameters.
1332#define GTEST_REFERENCE_TO_CONST_(T) \
1333 typename ::testing::internal::ConstRef<T>::type
Austin Schuh70cc9552019-01-21 19:46:48 -08001334
1335// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
1336//
1337// Use ImplicitCast_ as a safe version of static_cast for upcasting in
1338// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
1339// const Foo*). When you use ImplicitCast_, the compiler checks that
1340// the cast is safe. Such explicit ImplicitCast_s are necessary in
1341// surprisingly many situations where C++ demands an exact type match
1342// instead of an argument type convertable to a target type.
1343//
1344// The syntax for using ImplicitCast_ is the same as for static_cast:
1345//
1346// ImplicitCast_<ToType>(expr)
1347//
1348// ImplicitCast_ would have been part of the C++ standard library,
1349// but the proposal was submitted too late. It will probably make
1350// its way into the language in the future.
1351//
1352// This relatively ugly name is intentional. It prevents clashes with
1353// similar functions users may have (e.g., implicit_cast). The internal
1354// namespace alone is not enough because the function can be found by ADL.
1355template<typename To>
1356inline To ImplicitCast_(To x) { return x; }
1357
1358// When you upcast (that is, cast a pointer from type Foo to type
1359// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
1360// always succeed. When you downcast (that is, cast a pointer from
1361// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
1362// how do you know the pointer is really of type SubclassOfFoo? It
1363// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus,
1364// when you downcast, you should use this macro. In debug mode, we
1365// use dynamic_cast<> to double-check the downcast is legal (we die
1366// if it's not). In normal mode, we do the efficient static_cast<>
1367// instead. Thus, it's important to test in debug mode to make sure
1368// the cast is legal!
1369// This is the only place in the code we should use dynamic_cast<>.
1370// In particular, you SHOULDN'T be using dynamic_cast<> in order to
1371// do RTTI (eg code like this:
1372// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
1373// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
1374// You should design the code some other way not to need this.
1375//
1376// This relatively ugly name is intentional. It prevents clashes with
1377// similar functions users may have (e.g., down_cast). The internal
1378// namespace alone is not enough because the function can be found by ADL.
1379template<typename To, typename From> // use like this: DownCast_<T*>(foo);
1380inline To DownCast_(From* f) { // so we only accept pointers
1381 // Ensures that To is a sub-type of From *. This test is here only
1382 // for compile-time type checking, and has no overhead in an
1383 // optimized build at run-time, as it will be optimized away
1384 // completely.
1385 GTEST_INTENTIONAL_CONST_COND_PUSH_()
1386 if (false) {
1387 GTEST_INTENTIONAL_CONST_COND_POP_()
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001388 const To to = nullptr;
1389 ::testing::internal::ImplicitCast_<From*>(to);
Austin Schuh70cc9552019-01-21 19:46:48 -08001390 }
1391
1392#if GTEST_HAS_RTTI
1393 // RTTI: debug mode only!
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001394 GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);
Austin Schuh70cc9552019-01-21 19:46:48 -08001395#endif
1396 return static_cast<To>(f);
1397}
1398
1399// Downcasts the pointer of type Base to Derived.
1400// Derived must be a subclass of Base. The parameter MUST
1401// point to a class of type Derived, not any subclass of it.
1402// When RTTI is available, the function performs a runtime
1403// check to enforce this.
1404template <class Derived, class Base>
1405Derived* CheckedDowncastToActualType(Base* base) {
1406#if GTEST_HAS_RTTI
1407 GTEST_CHECK_(typeid(*base) == typeid(Derived));
1408#endif
1409
1410#if GTEST_HAS_DOWNCAST_
1411 return ::down_cast<Derived*>(base);
1412#elif GTEST_HAS_RTTI
1413 return dynamic_cast<Derived*>(base); // NOLINT
1414#else
1415 return static_cast<Derived*>(base); // Poor man's downcast.
1416#endif
1417}
1418
1419#if GTEST_HAS_STREAM_REDIRECTION
1420
1421// Defines the stderr capturer:
1422// CaptureStdout - starts capturing stdout.
1423// GetCapturedStdout - stops capturing stdout and returns the captured string.
1424// CaptureStderr - starts capturing stderr.
1425// GetCapturedStderr - stops capturing stderr and returns the captured string.
1426//
1427GTEST_API_ void CaptureStdout();
1428GTEST_API_ std::string GetCapturedStdout();
1429GTEST_API_ void CaptureStderr();
1430GTEST_API_ std::string GetCapturedStderr();
1431
1432#endif // GTEST_HAS_STREAM_REDIRECTION
Austin Schuh70cc9552019-01-21 19:46:48 -08001433// Returns the size (in bytes) of a file.
1434GTEST_API_ size_t GetFileSize(FILE* file);
1435
1436// Reads the entire content of a file as a string.
1437GTEST_API_ std::string ReadEntireFile(FILE* file);
1438
1439// All command line arguments.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001440GTEST_API_ std::vector<std::string> GetArgvs();
Austin Schuh70cc9552019-01-21 19:46:48 -08001441
1442#if GTEST_HAS_DEATH_TEST
1443
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001444std::vector<std::string> GetInjectableArgvs();
1445// Deprecated: pass the args vector by value instead.
1446void SetInjectableArgvs(const std::vector<std::string>* new_argvs);
1447void SetInjectableArgvs(const std::vector<std::string>& new_argvs);
1448#if GTEST_HAS_GLOBAL_STRING
1449void SetInjectableArgvs(const std::vector< ::string>& new_argvs);
1450#endif // GTEST_HAS_GLOBAL_STRING
1451void ClearInjectableArgvs();
Austin Schuh70cc9552019-01-21 19:46:48 -08001452
1453#endif // GTEST_HAS_DEATH_TEST
1454
1455// Defines synchronization primitives.
1456#if GTEST_IS_THREADSAFE
1457# if GTEST_HAS_PTHREAD
1458// Sleeps for (roughly) n milliseconds. This function is only for testing
1459// Google Test's own constructs. Don't use it in user tests, either
1460// directly or indirectly.
1461inline void SleepMilliseconds(int n) {
1462 const timespec time = {
1463 0, // 0 seconds.
1464 n * 1000L * 1000L, // And n ms.
1465 };
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001466 nanosleep(&time, nullptr);
Austin Schuh70cc9552019-01-21 19:46:48 -08001467}
1468# endif // GTEST_HAS_PTHREAD
1469
1470# if GTEST_HAS_NOTIFICATION_
1471// Notification has already been imported into the namespace.
1472// Nothing to do here.
1473
1474# elif GTEST_HAS_PTHREAD
1475// Allows a controller thread to pause execution of newly created
1476// threads until notified. Instances of this class must be created
1477// and destroyed in the controller thread.
1478//
1479// This class is only for testing Google Test's own constructs. Do not
1480// use it in user tests, either directly or indirectly.
1481class Notification {
1482 public:
1483 Notification() : notified_(false) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001484 GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
Austin Schuh70cc9552019-01-21 19:46:48 -08001485 }
1486 ~Notification() {
1487 pthread_mutex_destroy(&mutex_);
1488 }
1489
1490 // Notifies all threads created with this notification to start. Must
1491 // be called from the controller thread.
1492 void Notify() {
1493 pthread_mutex_lock(&mutex_);
1494 notified_ = true;
1495 pthread_mutex_unlock(&mutex_);
1496 }
1497
1498 // Blocks until the controller thread notifies. Must be called from a test
1499 // thread.
1500 void WaitForNotification() {
1501 for (;;) {
1502 pthread_mutex_lock(&mutex_);
1503 const bool notified = notified_;
1504 pthread_mutex_unlock(&mutex_);
1505 if (notified)
1506 break;
1507 SleepMilliseconds(10);
1508 }
1509 }
1510
1511 private:
1512 pthread_mutex_t mutex_;
1513 bool notified_;
1514
1515 GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
1516};
1517
1518# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
1519
1520GTEST_API_ void SleepMilliseconds(int n);
1521
1522// Provides leak-safe Windows kernel handle ownership.
1523// Used in death tests and in threading support.
1524class GTEST_API_ AutoHandle {
1525 public:
1526 // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to
1527 // avoid including <windows.h> in this header file. Including <windows.h> is
1528 // undesirable because it defines a lot of symbols and macros that tend to
1529 // conflict with client code. This assumption is verified by
1530 // WindowsTypesTest.HANDLEIsVoidStar.
1531 typedef void* Handle;
1532 AutoHandle();
1533 explicit AutoHandle(Handle handle);
1534
1535 ~AutoHandle();
1536
1537 Handle Get() const;
1538 void Reset();
1539 void Reset(Handle handle);
1540
1541 private:
1542 // Returns true iff the handle is a valid handle object that can be closed.
1543 bool IsCloseable() const;
1544
1545 Handle handle_;
1546
1547 GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
1548};
1549
1550// Allows a controller thread to pause execution of newly created
1551// threads until notified. Instances of this class must be created
1552// and destroyed in the controller thread.
1553//
1554// This class is only for testing Google Test's own constructs. Do not
1555// use it in user tests, either directly or indirectly.
1556class GTEST_API_ Notification {
1557 public:
1558 Notification();
1559 void Notify();
1560 void WaitForNotification();
1561
1562 private:
1563 AutoHandle event_;
1564
1565 GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
1566};
1567# endif // GTEST_HAS_NOTIFICATION_
1568
1569// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD
1570// defined, but we don't want to use MinGW's pthreads implementation, which
1571// has conformance problems with some versions of the POSIX standard.
1572# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW
1573
1574// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
1575// Consequently, it cannot select a correct instantiation of ThreadWithParam
1576// in order to call its Run(). Introducing ThreadWithParamBase as a
1577// non-templated base class for ThreadWithParam allows us to bypass this
1578// problem.
1579class ThreadWithParamBase {
1580 public:
1581 virtual ~ThreadWithParamBase() {}
1582 virtual void Run() = 0;
1583};
1584
1585// pthread_create() accepts a pointer to a function type with the C linkage.
1586// According to the Standard (7.5/1), function types with different linkages
1587// are different even if they are otherwise identical. Some compilers (for
1588// example, SunStudio) treat them as different types. Since class methods
1589// cannot be defined with C-linkage we need to define a free C-function to
1590// pass into pthread_create().
1591extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
1592 static_cast<ThreadWithParamBase*>(thread)->Run();
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001593 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -08001594}
1595
1596// Helper class for testing Google Test's multi-threading constructs.
1597// To use it, write:
1598//
1599// void ThreadFunc(int param) { /* Do things with param */ }
1600// Notification thread_can_start;
1601// ...
1602// // The thread_can_start parameter is optional; you can supply NULL.
1603// ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
1604// thread_can_start.Notify();
1605//
1606// These classes are only for testing Google Test's own constructs. Do
1607// not use them in user tests, either directly or indirectly.
1608template <typename T>
1609class ThreadWithParam : public ThreadWithParamBase {
1610 public:
1611 typedef void UserThreadFunc(T);
1612
1613 ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
1614 : func_(func),
1615 param_(param),
1616 thread_can_start_(thread_can_start),
1617 finished_(false) {
1618 ThreadWithParamBase* const base = this;
1619 // The thread can be created only after all fields except thread_
1620 // have been initialized.
1621 GTEST_CHECK_POSIX_SUCCESS_(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001622 pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));
Austin Schuh70cc9552019-01-21 19:46:48 -08001623 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001624 ~ThreadWithParam() override { Join(); }
Austin Schuh70cc9552019-01-21 19:46:48 -08001625
1626 void Join() {
1627 if (!finished_) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001628 GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr));
Austin Schuh70cc9552019-01-21 19:46:48 -08001629 finished_ = true;
1630 }
1631 }
1632
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001633 void Run() override {
1634 if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();
Austin Schuh70cc9552019-01-21 19:46:48 -08001635 func_(param_);
1636 }
1637
1638 private:
1639 UserThreadFunc* const func_; // User-supplied thread function.
1640 const T param_; // User-supplied parameter to the thread function.
1641 // When non-NULL, used to block execution until the controller thread
1642 // notifies.
1643 Notification* const thread_can_start_;
1644 bool finished_; // true iff we know that the thread function has finished.
1645 pthread_t thread_; // The native thread object.
1646
1647 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
1648};
1649# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
1650 // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1651
1652# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1653// Mutex and ThreadLocal have already been imported into the namespace.
1654// Nothing to do here.
1655
1656# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
1657
1658// Mutex implements mutex on Windows platforms. It is used in conjunction
1659// with class MutexLock:
1660//
1661// Mutex mutex;
1662// ...
1663// MutexLock lock(&mutex); // Acquires the mutex and releases it at the
1664// // end of the current scope.
1665//
1666// A static Mutex *must* be defined or declared using one of the following
1667// macros:
1668// GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
1669// GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
1670//
1671// (A non-static Mutex is defined/declared in the usual way).
1672class GTEST_API_ Mutex {
1673 public:
1674 enum MutexType { kStatic = 0, kDynamic = 1 };
1675 // We rely on kStaticMutex being 0 as it is to what the linker initializes
1676 // type_ in static mutexes. critical_section_ will be initialized lazily
1677 // in ThreadSafeLazyInit().
1678 enum StaticConstructorSelector { kStaticMutex = 0 };
1679
1680 // This constructor intentionally does nothing. It relies on type_ being
1681 // statically initialized to 0 (effectively setting it to kStatic) and on
1682 // ThreadSafeLazyInit() to lazily initialize the rest of the members.
1683 explicit Mutex(StaticConstructorSelector /*dummy*/) {}
1684
1685 Mutex();
1686 ~Mutex();
1687
1688 void Lock();
1689
1690 void Unlock();
1691
1692 // Does nothing if the current thread holds the mutex. Otherwise, crashes
1693 // with high probability.
1694 void AssertHeld();
1695
1696 private:
1697 // Initializes owner_thread_id_ and critical_section_ in static mutexes.
1698 void ThreadSafeLazyInit();
1699
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001700 // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503,
Austin Schuh70cc9552019-01-21 19:46:48 -08001701 // we assume that 0 is an invalid value for thread IDs.
1702 unsigned int owner_thread_id_;
1703
1704 // For static mutexes, we rely on these members being initialized to zeros
1705 // by the linker.
1706 MutexType type_;
1707 long critical_section_init_phase_; // NOLINT
1708 GTEST_CRITICAL_SECTION* critical_section_;
1709
1710 GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
1711};
1712
1713# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1714 extern ::testing::internal::Mutex mutex
1715
1716# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1717 ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
1718
1719// We cannot name this class MutexLock because the ctor declaration would
1720// conflict with a macro named MutexLock, which is defined on some
1721// platforms. That macro is used as a defensive measure to prevent against
1722// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
1723// "MutexLock l(&mu)". Hence the typedef trick below.
1724class GTestMutexLock {
1725 public:
1726 explicit GTestMutexLock(Mutex* mutex)
1727 : mutex_(mutex) { mutex_->Lock(); }
1728
1729 ~GTestMutexLock() { mutex_->Unlock(); }
1730
1731 private:
1732 Mutex* const mutex_;
1733
1734 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
1735};
1736
1737typedef GTestMutexLock MutexLock;
1738
1739// Base class for ValueHolder<T>. Allows a caller to hold and delete a value
1740// without knowing its type.
1741class ThreadLocalValueHolderBase {
1742 public:
1743 virtual ~ThreadLocalValueHolderBase() {}
1744};
1745
1746// Provides a way for a thread to send notifications to a ThreadLocal
1747// regardless of its parameter type.
1748class ThreadLocalBase {
1749 public:
1750 // Creates a new ValueHolder<T> object holding a default value passed to
1751 // this ThreadLocal<T>'s constructor and returns it. It is the caller's
1752 // responsibility not to call this when the ThreadLocal<T> instance already
1753 // has a value on the current thread.
1754 virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;
1755
1756 protected:
1757 ThreadLocalBase() {}
1758 virtual ~ThreadLocalBase() {}
1759
1760 private:
1761 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);
1762};
1763
1764// Maps a thread to a set of ThreadLocals that have values instantiated on that
1765// thread and notifies them when the thread exits. A ThreadLocal instance is
1766// expected to persist until all threads it has values on have terminated.
1767class GTEST_API_ ThreadLocalRegistry {
1768 public:
1769 // Registers thread_local_instance as having value on the current thread.
1770 // Returns a value that can be used to identify the thread from other threads.
1771 static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
1772 const ThreadLocalBase* thread_local_instance);
1773
1774 // Invoked when a ThreadLocal instance is destroyed.
1775 static void OnThreadLocalDestroyed(
1776 const ThreadLocalBase* thread_local_instance);
1777};
1778
1779class GTEST_API_ ThreadWithParamBase {
1780 public:
1781 void Join();
1782
1783 protected:
1784 class Runnable {
1785 public:
1786 virtual ~Runnable() {}
1787 virtual void Run() = 0;
1788 };
1789
1790 ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);
1791 virtual ~ThreadWithParamBase();
1792
1793 private:
1794 AutoHandle thread_;
1795};
1796
1797// Helper class for testing Google Test's multi-threading constructs.
1798template <typename T>
1799class ThreadWithParam : public ThreadWithParamBase {
1800 public:
1801 typedef void UserThreadFunc(T);
1802
1803 ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
1804 : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {
1805 }
1806 virtual ~ThreadWithParam() {}
1807
1808 private:
1809 class RunnableImpl : public Runnable {
1810 public:
1811 RunnableImpl(UserThreadFunc* func, T param)
1812 : func_(func),
1813 param_(param) {
1814 }
1815 virtual ~RunnableImpl() {}
1816 virtual void Run() {
1817 func_(param_);
1818 }
1819
1820 private:
1821 UserThreadFunc* const func_;
1822 const T param_;
1823
1824 GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);
1825 };
1826
1827 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
1828};
1829
1830// Implements thread-local storage on Windows systems.
1831//
1832// // Thread 1
1833// ThreadLocal<int> tl(100); // 100 is the default value for each thread.
1834//
1835// // Thread 2
1836// tl.set(150); // Changes the value for thread 2 only.
1837// EXPECT_EQ(150, tl.get());
1838//
1839// // Thread 1
1840// EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value.
1841// tl.set(200);
1842// EXPECT_EQ(200, tl.get());
1843//
1844// The template type argument T must have a public copy constructor.
1845// In addition, the default ThreadLocal constructor requires T to have
1846// a public default constructor.
1847//
1848// The users of a TheadLocal instance have to make sure that all but one
1849// threads (including the main one) using that instance have exited before
1850// destroying it. Otherwise, the per-thread objects managed for them by the
1851// ThreadLocal instance are not guaranteed to be destroyed on all platforms.
1852//
1853// Google Test only uses global ThreadLocal objects. That means they
1854// will die after main() has returned. Therefore, no per-thread
1855// object managed by Google Test will be leaked as long as all threads
1856// using Google Test have exited when main() returns.
1857template <typename T>
1858class ThreadLocal : public ThreadLocalBase {
1859 public:
1860 ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
1861 explicit ThreadLocal(const T& value)
1862 : default_factory_(new InstanceValueHolderFactory(value)) {}
1863
1864 ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }
1865
1866 T* pointer() { return GetOrCreateValue(); }
1867 const T* pointer() const { return GetOrCreateValue(); }
1868 const T& get() const { return *pointer(); }
1869 void set(const T& value) { *pointer() = value; }
1870
1871 private:
1872 // Holds a value of T. Can be deleted via its base class without the caller
1873 // knowing the type of T.
1874 class ValueHolder : public ThreadLocalValueHolderBase {
1875 public:
1876 ValueHolder() : value_() {}
1877 explicit ValueHolder(const T& value) : value_(value) {}
1878
1879 T* pointer() { return &value_; }
1880
1881 private:
1882 T value_;
1883 GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
1884 };
1885
1886
1887 T* GetOrCreateValue() const {
1888 return static_cast<ValueHolder*>(
1889 ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();
1890 }
1891
1892 virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {
1893 return default_factory_->MakeNewHolder();
1894 }
1895
1896 class ValueHolderFactory {
1897 public:
1898 ValueHolderFactory() {}
1899 virtual ~ValueHolderFactory() {}
1900 virtual ValueHolder* MakeNewHolder() const = 0;
1901
1902 private:
1903 GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
1904 };
1905
1906 class DefaultValueHolderFactory : public ValueHolderFactory {
1907 public:
1908 DefaultValueHolderFactory() {}
1909 virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
1910
1911 private:
1912 GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
1913 };
1914
1915 class InstanceValueHolderFactory : public ValueHolderFactory {
1916 public:
1917 explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
1918 virtual ValueHolder* MakeNewHolder() const {
1919 return new ValueHolder(value_);
1920 }
1921
1922 private:
1923 const T value_; // The value for each thread.
1924
1925 GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
1926 };
1927
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001928 std::unique_ptr<ValueHolderFactory> default_factory_;
Austin Schuh70cc9552019-01-21 19:46:48 -08001929
1930 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
1931};
1932
1933# elif GTEST_HAS_PTHREAD
1934
1935// MutexBase and Mutex implement mutex on pthreads-based platforms.
1936class MutexBase {
1937 public:
1938 // Acquires this mutex.
1939 void Lock() {
1940 GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
1941 owner_ = pthread_self();
1942 has_owner_ = true;
1943 }
1944
1945 // Releases this mutex.
1946 void Unlock() {
1947 // Since the lock is being released the owner_ field should no longer be
1948 // considered valid. We don't protect writing to has_owner_ here, as it's
1949 // the caller's responsibility to ensure that the current thread holds the
1950 // mutex when this is called.
1951 has_owner_ = false;
1952 GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
1953 }
1954
1955 // Does nothing if the current thread holds the mutex. Otherwise, crashes
1956 // with high probability.
1957 void AssertHeld() const {
1958 GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
1959 << "The current thread is not holding the mutex @" << this;
1960 }
1961
1962 // A static mutex may be used before main() is entered. It may even
1963 // be used before the dynamic initialization stage. Therefore we
1964 // must be able to initialize a static mutex object at link time.
1965 // This means MutexBase has to be a POD and its member variables
1966 // have to be public.
1967 public:
1968 pthread_mutex_t mutex_; // The underlying pthread mutex.
1969 // has_owner_ indicates whether the owner_ field below contains a valid thread
1970 // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
1971 // accesses to the owner_ field should be protected by a check of this field.
1972 // An alternative might be to memset() owner_ to all zeros, but there's no
1973 // guarantee that a zero'd pthread_t is necessarily invalid or even different
1974 // from pthread_self().
1975 bool has_owner_;
1976 pthread_t owner_; // The thread holding the mutex.
1977};
1978
1979// Forward-declares a static mutex.
1980# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1981 extern ::testing::internal::MutexBase mutex
1982
1983// Defines and statically (i.e. at link time) initializes a static mutex.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001984// The initialization list here does not explicitly initialize each field,
1985// instead relying on default initialization for the unspecified fields. In
1986// particular, the owner_ field (a pthread_t) is not explicitly initialized.
1987// This allows initialization to work whether pthread_t is a scalar or struct.
1988// The flag -Wmissing-field-initializers must not be specified for this to work.
1989#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1990 ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
Austin Schuh70cc9552019-01-21 19:46:48 -08001991
1992// The Mutex class can only be used for mutexes created at runtime. It
1993// shares its API with MutexBase otherwise.
1994class Mutex : public MutexBase {
1995 public:
1996 Mutex() {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08001997 GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
Austin Schuh70cc9552019-01-21 19:46:48 -08001998 has_owner_ = false;
1999 }
2000 ~Mutex() {
2001 GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
2002 }
2003
2004 private:
2005 GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
2006};
2007
2008// We cannot name this class MutexLock because the ctor declaration would
2009// conflict with a macro named MutexLock, which is defined on some
2010// platforms. That macro is used as a defensive measure to prevent against
2011// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
2012// "MutexLock l(&mu)". Hence the typedef trick below.
2013class GTestMutexLock {
2014 public:
2015 explicit GTestMutexLock(MutexBase* mutex)
2016 : mutex_(mutex) { mutex_->Lock(); }
2017
2018 ~GTestMutexLock() { mutex_->Unlock(); }
2019
2020 private:
2021 MutexBase* const mutex_;
2022
2023 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
2024};
2025
2026typedef GTestMutexLock MutexLock;
2027
2028// Helpers for ThreadLocal.
2029
2030// pthread_key_create() requires DeleteThreadLocalValue() to have
2031// C-linkage. Therefore it cannot be templatized to access
2032// ThreadLocal<T>. Hence the need for class
2033// ThreadLocalValueHolderBase.
2034class ThreadLocalValueHolderBase {
2035 public:
2036 virtual ~ThreadLocalValueHolderBase() {}
2037};
2038
2039// Called by pthread to delete thread-local data stored by
2040// pthread_setspecific().
2041extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
2042 delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
2043}
2044
2045// Implements thread-local storage on pthreads-based systems.
2046template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002047class GTEST_API_ ThreadLocal {
Austin Schuh70cc9552019-01-21 19:46:48 -08002048 public:
2049 ThreadLocal()
2050 : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
2051 explicit ThreadLocal(const T& value)
2052 : key_(CreateKey()),
2053 default_factory_(new InstanceValueHolderFactory(value)) {}
2054
2055 ~ThreadLocal() {
2056 // Destroys the managed object for the current thread, if any.
2057 DeleteThreadLocalValue(pthread_getspecific(key_));
2058
2059 // Releases resources associated with the key. This will *not*
2060 // delete managed objects for other threads.
2061 GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
2062 }
2063
2064 T* pointer() { return GetOrCreateValue(); }
2065 const T* pointer() const { return GetOrCreateValue(); }
2066 const T& get() const { return *pointer(); }
2067 void set(const T& value) { *pointer() = value; }
2068
2069 private:
2070 // Holds a value of type T.
2071 class ValueHolder : public ThreadLocalValueHolderBase {
2072 public:
2073 ValueHolder() : value_() {}
2074 explicit ValueHolder(const T& value) : value_(value) {}
2075
2076 T* pointer() { return &value_; }
2077
2078 private:
2079 T value_;
2080 GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
2081 };
2082
2083 static pthread_key_t CreateKey() {
2084 pthread_key_t key;
2085 // When a thread exits, DeleteThreadLocalValue() will be called on
2086 // the object managed for that thread.
2087 GTEST_CHECK_POSIX_SUCCESS_(
2088 pthread_key_create(&key, &DeleteThreadLocalValue));
2089 return key;
2090 }
2091
2092 T* GetOrCreateValue() const {
2093 ThreadLocalValueHolderBase* const holder =
2094 static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002095 if (holder != nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -08002096 return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
2097 }
2098
2099 ValueHolder* const new_holder = default_factory_->MakeNewHolder();
2100 ThreadLocalValueHolderBase* const holder_base = new_holder;
2101 GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
2102 return new_holder->pointer();
2103 }
2104
2105 class ValueHolderFactory {
2106 public:
2107 ValueHolderFactory() {}
2108 virtual ~ValueHolderFactory() {}
2109 virtual ValueHolder* MakeNewHolder() const = 0;
2110
2111 private:
2112 GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
2113 };
2114
2115 class DefaultValueHolderFactory : public ValueHolderFactory {
2116 public:
2117 DefaultValueHolderFactory() {}
2118 virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
2119
2120 private:
2121 GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
2122 };
2123
2124 class InstanceValueHolderFactory : public ValueHolderFactory {
2125 public:
2126 explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
2127 virtual ValueHolder* MakeNewHolder() const {
2128 return new ValueHolder(value_);
2129 }
2130
2131 private:
2132 const T value_; // The value for each thread.
2133
2134 GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
2135 };
2136
2137 // A key pthreads uses for looking up per-thread values.
2138 const pthread_key_t key_;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002139 std::unique_ptr<ValueHolderFactory> default_factory_;
Austin Schuh70cc9552019-01-21 19:46:48 -08002140
2141 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
2142};
2143
2144# endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
2145
2146#else // GTEST_IS_THREADSAFE
2147
2148// A dummy implementation of synchronization primitives (mutex, lock,
2149// and thread-local variable). Necessary for compiling Google Test where
2150// mutex is not supported - using Google Test in multiple threads is not
2151// supported on such platforms.
2152
2153class Mutex {
2154 public:
2155 Mutex() {}
2156 void Lock() {}
2157 void Unlock() {}
2158 void AssertHeld() const {}
2159};
2160
2161# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
2162 extern ::testing::internal::Mutex mutex
2163
2164# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
2165
2166// We cannot name this class MutexLock because the ctor declaration would
2167// conflict with a macro named MutexLock, which is defined on some
2168// platforms. That macro is used as a defensive measure to prevent against
2169// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
2170// "MutexLock l(&mu)". Hence the typedef trick below.
2171class GTestMutexLock {
2172 public:
2173 explicit GTestMutexLock(Mutex*) {} // NOLINT
2174};
2175
2176typedef GTestMutexLock MutexLock;
2177
2178template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002179class GTEST_API_ ThreadLocal {
Austin Schuh70cc9552019-01-21 19:46:48 -08002180 public:
2181 ThreadLocal() : value_() {}
2182 explicit ThreadLocal(const T& value) : value_(value) {}
2183 T* pointer() { return &value_; }
2184 const T* pointer() const { return &value_; }
2185 const T& get() const { return value_; }
2186 void set(const T& value) { value_ = value; }
2187 private:
2188 T value_;
2189};
2190
2191#endif // GTEST_IS_THREADSAFE
2192
2193// Returns the number of threads running in the process, or 0 to indicate that
2194// we cannot detect it.
2195GTEST_API_ size_t GetThreadCount();
2196
Austin Schuh70cc9552019-01-21 19:46:48 -08002197template <bool bool_value>
2198struct bool_constant {
2199 typedef bool_constant<bool_value> type;
2200 static const bool value = bool_value;
2201};
2202template <bool bool_value> const bool bool_constant<bool_value>::value;
2203
2204typedef bool_constant<false> false_type;
2205typedef bool_constant<true> true_type;
2206
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002207template <typename T, typename U>
2208struct is_same : public false_type {};
Austin Schuh70cc9552019-01-21 19:46:48 -08002209
2210template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002211struct is_same<T, T> : public true_type {};
Austin Schuh70cc9552019-01-21 19:46:48 -08002212
2213template <typename Iterator>
2214struct IteratorTraits {
2215 typedef typename Iterator::value_type value_type;
2216};
2217
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002218
Austin Schuh70cc9552019-01-21 19:46:48 -08002219template <typename T>
2220struct IteratorTraits<T*> {
2221 typedef T value_type;
2222};
2223
2224template <typename T>
2225struct IteratorTraits<const T*> {
2226 typedef T value_type;
2227};
2228
2229#if GTEST_OS_WINDOWS
2230# define GTEST_PATH_SEP_ "\\"
2231# define GTEST_HAS_ALT_PATH_SEP_ 1
2232// The biggest signed integer type the compiler supports.
2233typedef __int64 BiggestInt;
2234#else
2235# define GTEST_PATH_SEP_ "/"
2236# define GTEST_HAS_ALT_PATH_SEP_ 0
2237typedef long long BiggestInt; // NOLINT
2238#endif // GTEST_OS_WINDOWS
2239
2240// Utilities for char.
2241
2242// isspace(int ch) and friends accept an unsigned char or EOF. char
2243// may be signed, depending on the compiler (or compiler flags).
2244// Therefore we need to cast a char to unsigned char before calling
2245// isspace(), etc.
2246
2247inline bool IsAlpha(char ch) {
2248 return isalpha(static_cast<unsigned char>(ch)) != 0;
2249}
2250inline bool IsAlNum(char ch) {
2251 return isalnum(static_cast<unsigned char>(ch)) != 0;
2252}
2253inline bool IsDigit(char ch) {
2254 return isdigit(static_cast<unsigned char>(ch)) != 0;
2255}
2256inline bool IsLower(char ch) {
2257 return islower(static_cast<unsigned char>(ch)) != 0;
2258}
2259inline bool IsSpace(char ch) {
2260 return isspace(static_cast<unsigned char>(ch)) != 0;
2261}
2262inline bool IsUpper(char ch) {
2263 return isupper(static_cast<unsigned char>(ch)) != 0;
2264}
2265inline bool IsXDigit(char ch) {
2266 return isxdigit(static_cast<unsigned char>(ch)) != 0;
2267}
2268inline bool IsXDigit(wchar_t ch) {
2269 const unsigned char low_byte = static_cast<unsigned char>(ch);
2270 return ch == low_byte && isxdigit(low_byte) != 0;
2271}
2272
2273inline char ToLower(char ch) {
2274 return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
2275}
2276inline char ToUpper(char ch) {
2277 return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
2278}
2279
2280inline std::string StripTrailingSpaces(std::string str) {
2281 std::string::iterator it = str.end();
2282 while (it != str.begin() && IsSpace(*--it))
2283 it = str.erase(it);
2284 return str;
2285}
2286
2287// The testing::internal::posix namespace holds wrappers for common
2288// POSIX functions. These wrappers hide the differences between
2289// Windows/MSVC and POSIX systems. Since some compilers define these
2290// standard functions as macros, the wrapper cannot have the same name
2291// as the wrapped function.
2292
2293namespace posix {
2294
2295// Functions with a different name on Windows.
2296
2297#if GTEST_OS_WINDOWS
2298
2299typedef struct _stat StatStruct;
2300
2301# ifdef __BORLANDC__
2302inline int IsATTY(int fd) { return isatty(fd); }
2303inline int StrCaseCmp(const char* s1, const char* s2) {
2304 return stricmp(s1, s2);
2305}
2306inline char* StrDup(const char* src) { return strdup(src); }
2307# else // !__BORLANDC__
2308# if GTEST_OS_WINDOWS_MOBILE
2309inline int IsATTY(int /* fd */) { return 0; }
2310# else
2311inline int IsATTY(int fd) { return _isatty(fd); }
2312# endif // GTEST_OS_WINDOWS_MOBILE
2313inline int StrCaseCmp(const char* s1, const char* s2) {
2314 return _stricmp(s1, s2);
2315}
2316inline char* StrDup(const char* src) { return _strdup(src); }
2317# endif // __BORLANDC__
2318
2319# if GTEST_OS_WINDOWS_MOBILE
2320inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
2321// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
2322// time and thus not defined there.
2323# else
2324inline int FileNo(FILE* file) { return _fileno(file); }
2325inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
2326inline int RmDir(const char* dir) { return _rmdir(dir); }
2327inline bool IsDir(const StatStruct& st) {
2328 return (_S_IFDIR & st.st_mode) != 0;
2329}
2330# endif // GTEST_OS_WINDOWS_MOBILE
2331
2332#else
2333
2334typedef struct stat StatStruct;
2335
2336inline int FileNo(FILE* file) { return fileno(file); }
2337inline int IsATTY(int fd) { return isatty(fd); }
2338inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
2339inline int StrCaseCmp(const char* s1, const char* s2) {
2340 return strcasecmp(s1, s2);
2341}
2342inline char* StrDup(const char* src) { return strdup(src); }
2343inline int RmDir(const char* dir) { return rmdir(dir); }
2344inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
2345
2346#endif // GTEST_OS_WINDOWS
2347
2348// Functions deprecated by MSVC 8.0.
2349
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002350GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
Austin Schuh70cc9552019-01-21 19:46:48 -08002351
2352inline const char* StrNCpy(char* dest, const char* src, size_t n) {
2353 return strncpy(dest, src, n);
2354}
2355
2356// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
2357// StrError() aren't needed on Windows CE at this time and thus not
2358// defined there.
2359
2360#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
2361inline int ChDir(const char* dir) { return chdir(dir); }
2362#endif
2363inline FILE* FOpen(const char* path, const char* mode) {
2364 return fopen(path, mode);
2365}
2366#if !GTEST_OS_WINDOWS_MOBILE
2367inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
2368 return freopen(path, mode, stream);
2369}
2370inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
2371#endif
2372inline int FClose(FILE* fp) { return fclose(fp); }
2373#if !GTEST_OS_WINDOWS_MOBILE
2374inline int Read(int fd, void* buf, unsigned int count) {
2375 return static_cast<int>(read(fd, buf, count));
2376}
2377inline int Write(int fd, const void* buf, unsigned int count) {
2378 return static_cast<int>(write(fd, buf, count));
2379}
2380inline int Close(int fd) { return close(fd); }
2381inline const char* StrError(int errnum) { return strerror(errnum); }
2382#endif
2383inline const char* GetEnv(const char* name) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002384#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
Austin Schuh70cc9552019-01-21 19:46:48 -08002385 // We are on Windows CE, which has no environment variables.
2386 static_cast<void>(name); // To prevent 'unused argument' warning.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002387 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -08002388#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
2389 // Environment variables which we programmatically clear will be set to the
2390 // empty string rather than unset (NULL). Handle that case.
2391 const char* const env = getenv(name);
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002392 return (env != nullptr && env[0] != '\0') ? env : nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -08002393#else
2394 return getenv(name);
2395#endif
2396}
2397
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002398GTEST_DISABLE_MSC_DEPRECATED_POP_()
Austin Schuh70cc9552019-01-21 19:46:48 -08002399
2400#if GTEST_OS_WINDOWS_MOBILE
2401// Windows CE has no C library. The abort() function is used in
2402// several places in Google Test. This implementation provides a reasonable
2403// imitation of standard behaviour.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002404[[noreturn]] void Abort();
Austin Schuh70cc9552019-01-21 19:46:48 -08002405#else
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002406[[noreturn]] inline void Abort() { abort(); }
Austin Schuh70cc9552019-01-21 19:46:48 -08002407#endif // GTEST_OS_WINDOWS_MOBILE
2408
2409} // namespace posix
2410
2411// MSVC "deprecates" snprintf and issues warnings wherever it is used. In
2412// order to avoid these warnings, we need to use _snprintf or _snprintf_s on
2413// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
2414// function in order to achieve that. We use macro definition here because
2415// snprintf is a variadic function.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002416#if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE
Austin Schuh70cc9552019-01-21 19:46:48 -08002417// MSVC 2005 and above support variadic macros.
2418# define GTEST_SNPRINTF_(buffer, size, format, ...) \
2419 _snprintf_s(buffer, size, size, format, __VA_ARGS__)
2420#elif defined(_MSC_VER)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002421// Windows CE does not define _snprintf_s
Austin Schuh70cc9552019-01-21 19:46:48 -08002422# define GTEST_SNPRINTF_ _snprintf
2423#else
2424# define GTEST_SNPRINTF_ snprintf
2425#endif
2426
2427// The maximum number a BiggestInt can represent. This definition
2428// works no matter BiggestInt is represented in one's complement or
2429// two's complement.
2430//
2431// We cannot rely on numeric_limits in STL, as __int64 and long long
2432// are not part of standard C++ and numeric_limits doesn't need to be
2433// defined for them.
2434const BiggestInt kMaxBiggestInt =
2435 ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
2436
2437// This template class serves as a compile-time function from size to
2438// type. It maps a size in bytes to a primitive type with that
2439// size. e.g.
2440//
2441// TypeWithSize<4>::UInt
2442//
2443// is typedef-ed to be unsigned int (unsigned integer made up of 4
2444// bytes).
2445//
2446// Such functionality should belong to STL, but I cannot find it
2447// there.
2448//
2449// Google Test uses this class in the implementation of floating-point
2450// comparison.
2451//
2452// For now it only handles UInt (unsigned int) as that's all Google Test
2453// needs. Other types can be easily added in the future if need
2454// arises.
2455template <size_t size>
2456class TypeWithSize {
2457 public:
2458 // This prevents the user from using TypeWithSize<N> with incorrect
2459 // values of N.
2460 typedef void UInt;
2461};
2462
2463// The specialization for size 4.
2464template <>
2465class TypeWithSize<4> {
2466 public:
2467 // unsigned int has size 4 in both gcc and MSVC.
2468 //
2469 // As base/basictypes.h doesn't compile on Windows, we cannot use
2470 // uint32, uint64, and etc here.
2471 typedef int Int;
2472 typedef unsigned int UInt;
2473};
2474
2475// The specialization for size 8.
2476template <>
2477class TypeWithSize<8> {
2478 public:
2479#if GTEST_OS_WINDOWS
2480 typedef __int64 Int;
2481 typedef unsigned __int64 UInt;
2482#else
2483 typedef long long Int; // NOLINT
2484 typedef unsigned long long UInt; // NOLINT
2485#endif // GTEST_OS_WINDOWS
2486};
2487
2488// Integer types of known sizes.
2489typedef TypeWithSize<4>::Int Int32;
2490typedef TypeWithSize<4>::UInt UInt32;
2491typedef TypeWithSize<8>::Int Int64;
2492typedef TypeWithSize<8>::UInt UInt64;
2493typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
2494
2495// Utilities for command line flags and environment variables.
2496
2497// Macro for referencing flags.
2498#if !defined(GTEST_FLAG)
2499# define GTEST_FLAG(name) FLAGS_gtest_##name
2500#endif // !defined(GTEST_FLAG)
2501
2502#if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
2503# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
2504#endif // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
2505
2506#if !defined(GTEST_DECLARE_bool_)
2507# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
2508
2509// Macros for declaring flags.
2510# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
2511# define GTEST_DECLARE_int32_(name) \
2512 GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002513# define GTEST_DECLARE_string_(name) \
Austin Schuh70cc9552019-01-21 19:46:48 -08002514 GTEST_API_ extern ::std::string GTEST_FLAG(name)
2515
2516// Macros for defining flags.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002517# define GTEST_DEFINE_bool_(name, default_val, doc) \
Austin Schuh70cc9552019-01-21 19:46:48 -08002518 GTEST_API_ bool GTEST_FLAG(name) = (default_val)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002519# define GTEST_DEFINE_int32_(name, default_val, doc) \
Austin Schuh70cc9552019-01-21 19:46:48 -08002520 GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002521# define GTEST_DEFINE_string_(name, default_val, doc) \
Austin Schuh70cc9552019-01-21 19:46:48 -08002522 GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
2523
2524#endif // !defined(GTEST_DECLARE_bool_)
2525
2526// Thread annotations
2527#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2528# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
2529# define GTEST_LOCK_EXCLUDED_(locks)
2530#endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2531
2532// Parses 'str' for a 32-bit signed integer. If successful, writes the result
2533// to *value and returns true; otherwise leaves *value unchanged and returns
2534// false.
Austin Schuh70cc9552019-01-21 19:46:48 -08002535bool ParseInt32(const Message& src_text, const char* str, Int32* value);
2536
2537// Parses a bool/Int32/string from the environment variable
2538// corresponding to the given Google Test flag.
2539bool BoolFromGTestEnv(const char* flag, bool default_val);
2540GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002541std::string OutputFlagAlsoCheckEnvVar();
2542const char* StringFromGTestEnv(const char* flag, const char* default_val);
Austin Schuh70cc9552019-01-21 19:46:48 -08002543
2544} // namespace internal
2545} // namespace testing
2546
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002547#if !defined(GTEST_INTERNAL_DEPRECATED)
2548
2549// Internal Macro to mark an API deprecated, for googletest usage only
2550// Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or
2551// GTEST_INTERNAL_DEPRECATED(message) <return_type> myFunction(); Every usage of
2552// a deprecated entity will trigger a warning when compiled with
2553// `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler).
2554// For msvc /W3 option will need to be used
2555// Note that for 'other' compilers this macro evaluates to nothing to prevent
2556// compilations errors.
2557#if defined(_MSC_VER)
2558#define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))
2559#elif defined(__GNUC__)
2560#define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
2561#else
2562#define GTEST_INTERNAL_DEPRECATED(message)
2563#endif
2564
2565#endif // !defined(GTEST_INTERNAL_DEPRECATED)
2566
Austin Schuh70cc9552019-01-21 19:46:48 -08002567#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
2568
2569#if GTEST_OS_LINUX
2570# include <stdlib.h>
2571# include <sys/types.h>
2572# include <sys/wait.h>
2573# include <unistd.h>
2574#endif // GTEST_OS_LINUX
2575
2576#if GTEST_HAS_EXCEPTIONS
2577# include <stdexcept>
2578#endif
2579
2580#include <ctype.h>
2581#include <float.h>
2582#include <string.h>
2583#include <iomanip>
2584#include <limits>
2585#include <map>
2586#include <set>
2587#include <string>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002588#include <type_traits>
Austin Schuh70cc9552019-01-21 19:46:48 -08002589#include <vector>
2590
2591// Copyright 2005, Google Inc.
2592// All rights reserved.
2593//
2594// Redistribution and use in source and binary forms, with or without
2595// modification, are permitted provided that the following conditions are
2596// met:
2597//
2598// * Redistributions of source code must retain the above copyright
2599// notice, this list of conditions and the following disclaimer.
2600// * Redistributions in binary form must reproduce the above
2601// copyright notice, this list of conditions and the following disclaimer
2602// in the documentation and/or other materials provided with the
2603// distribution.
2604// * Neither the name of Google Inc. nor the names of its
2605// contributors may be used to endorse or promote products derived from
2606// this software without specific prior written permission.
2607//
2608// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2609// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2610// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2611// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2612// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2613// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2614// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2615// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2616// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2617// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2618// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002619
Austin Schuh70cc9552019-01-21 19:46:48 -08002620//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002621// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -08002622//
2623// This header file defines the Message class.
2624//
2625// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
2626// leave some internal implementation details in this header file.
2627// They are clearly marked by comments like this:
2628//
2629// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
2630//
2631// Such code is NOT meant to be used by a user directly, and is subject
2632// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
2633// program!
2634
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002635// GOOGLETEST_CM0001 DO NOT DELETE
2636
Austin Schuh70cc9552019-01-21 19:46:48 -08002637#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2638#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
2639
2640#include <limits>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002641#include <memory>
Austin Schuh70cc9552019-01-21 19:46:48 -08002642
2643
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002644GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
2645/* class A needs to have dll-interface to be used by clients of class B */)
2646
Austin Schuh70cc9552019-01-21 19:46:48 -08002647// Ensures that there is at least one operator<< in the global namespace.
2648// See Message& operator<<(...) below for why.
2649void operator<<(const testing::internal::Secret&, int);
2650
2651namespace testing {
2652
2653// The Message class works like an ostream repeater.
2654//
2655// Typical usage:
2656//
2657// 1. You stream a bunch of values to a Message object.
2658// It will remember the text in a stringstream.
2659// 2. Then you stream the Message object to an ostream.
2660// This causes the text in the Message to be streamed
2661// to the ostream.
2662//
2663// For example;
2664//
2665// testing::Message foo;
2666// foo << 1 << " != " << 2;
2667// std::cout << foo;
2668//
2669// will print "1 != 2".
2670//
2671// Message is not intended to be inherited from. In particular, its
2672// destructor is not virtual.
2673//
2674// Note that stringstream behaves differently in gcc and in MSVC. You
2675// can stream a NULL char pointer to it in the former, but not in the
2676// latter (it causes an access violation if you do). The Message
2677// class hides this difference by treating a NULL char pointer as
2678// "(null)".
2679class GTEST_API_ Message {
2680 private:
2681 // The type of basic IO manipulators (endl, ends, and flush) for
2682 // narrow streams.
2683 typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
2684
2685 public:
2686 // Constructs an empty Message.
2687 Message();
2688
2689 // Copy constructor.
2690 Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
2691 *ss_ << msg.GetString();
2692 }
2693
2694 // Constructs a Message from a C-string.
2695 explicit Message(const char* str) : ss_(new ::std::stringstream) {
2696 *ss_ << str;
2697 }
2698
Austin Schuh70cc9552019-01-21 19:46:48 -08002699 // Streams a non-pointer value to this object.
2700 template <typename T>
2701 inline Message& operator <<(const T& val) {
2702 // Some libraries overload << for STL containers. These
2703 // overloads are defined in the global namespace instead of ::std.
2704 //
2705 // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
2706 // overloads are visible in either the std namespace or the global
2707 // namespace, but not other namespaces, including the testing
2708 // namespace which Google Test's Message class is in.
2709 //
2710 // To allow STL containers (and other types that has a << operator
2711 // defined in the global namespace) to be used in Google Test
2712 // assertions, testing::Message must access the custom << operator
2713 // from the global namespace. With this using declaration,
2714 // overloads of << defined in the global namespace and those
2715 // visible via Koenig lookup are both exposed in this function.
2716 using ::operator <<;
2717 *ss_ << val;
2718 return *this;
2719 }
2720
2721 // Streams a pointer value to this object.
2722 //
2723 // This function is an overload of the previous one. When you
2724 // stream a pointer to a Message, this definition will be used as it
2725 // is more specialized. (The C++ Standard, section
2726 // [temp.func.order].) If you stream a non-pointer, then the
2727 // previous definition will be used.
2728 //
2729 // The reason for this overload is that streaming a NULL pointer to
2730 // ostream is undefined behavior. Depending on the compiler, you
2731 // may get "0", "(nil)", "(null)", or an access violation. To
2732 // ensure consistent result across compilers, we always treat NULL
2733 // as "(null)".
2734 template <typename T>
2735 inline Message& operator <<(T* const& pointer) { // NOLINT
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002736 if (pointer == nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -08002737 *ss_ << "(null)";
2738 } else {
2739 *ss_ << pointer;
2740 }
2741 return *this;
2742 }
Austin Schuh70cc9552019-01-21 19:46:48 -08002743
2744 // Since the basic IO manipulators are overloaded for both narrow
2745 // and wide streams, we have to provide this specialized definition
2746 // of operator <<, even though its body is the same as the
2747 // templatized version above. Without this definition, streaming
2748 // endl or other basic IO manipulators to Message will confuse the
2749 // compiler.
2750 Message& operator <<(BasicNarrowIoManip val) {
2751 *ss_ << val;
2752 return *this;
2753 }
2754
2755 // Instead of 1/0, we want to see true/false for bool values.
2756 Message& operator <<(bool b) {
2757 return *this << (b ? "true" : "false");
2758 }
2759
2760 // These two overloads allow streaming a wide C string to a Message
2761 // using the UTF-8 encoding.
2762 Message& operator <<(const wchar_t* wide_c_str);
2763 Message& operator <<(wchar_t* wide_c_str);
2764
2765#if GTEST_HAS_STD_WSTRING
2766 // Converts the given wide string to a narrow string using the UTF-8
2767 // encoding, and streams the result to this Message object.
2768 Message& operator <<(const ::std::wstring& wstr);
2769#endif // GTEST_HAS_STD_WSTRING
2770
2771#if GTEST_HAS_GLOBAL_WSTRING
2772 // Converts the given wide string to a narrow string using the UTF-8
2773 // encoding, and streams the result to this Message object.
2774 Message& operator <<(const ::wstring& wstr);
2775#endif // GTEST_HAS_GLOBAL_WSTRING
2776
2777 // Gets the text streamed to this object so far as an std::string.
2778 // Each '\0' character in the buffer is replaced with "\\0".
2779 //
2780 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
2781 std::string GetString() const;
2782
2783 private:
Austin Schuh70cc9552019-01-21 19:46:48 -08002784 // We'll hold the text streamed to this object here.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002785 const std::unique_ptr< ::std::stringstream> ss_;
Austin Schuh70cc9552019-01-21 19:46:48 -08002786
2787 // We declare (but don't implement) this to prevent the compiler
2788 // from implementing the assignment operator.
2789 void operator=(const Message&);
2790};
2791
2792// Streams a Message to an ostream.
2793inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
2794 return os << sb.GetString();
2795}
2796
2797namespace internal {
2798
2799// Converts a streamable value to an std::string. A NULL pointer is
2800// converted to "(null)". When the input value is a ::string,
2801// ::std::string, ::wstring, or ::std::wstring object, each NUL
2802// character in it is replaced with "\\0".
2803template <typename T>
2804std::string StreamableToString(const T& streamable) {
2805 return (Message() << streamable).GetString();
2806}
2807
2808} // namespace internal
2809} // namespace testing
2810
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002811GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
2812
Austin Schuh70cc9552019-01-21 19:46:48 -08002813#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002814// Copyright 2008, Google Inc.
2815// All rights reserved.
2816//
2817// Redistribution and use in source and binary forms, with or without
2818// modification, are permitted provided that the following conditions are
2819// met:
2820//
2821// * Redistributions of source code must retain the above copyright
2822// notice, this list of conditions and the following disclaimer.
2823// * Redistributions in binary form must reproduce the above
2824// copyright notice, this list of conditions and the following disclaimer
2825// in the documentation and/or other materials provided with the
2826// distribution.
2827// * Neither the name of Google Inc. nor the names of its
2828// contributors may be used to endorse or promote products derived from
2829// this software without specific prior written permission.
2830//
2831// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2832// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2833// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2834// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2835// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2836// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2837// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2838// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2839// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2840// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2841// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2842//
2843// Google Test filepath utilities
2844//
2845// This header file declares classes and functions used internally by
2846// Google Test. They are subject to change without notice.
2847//
2848// This file is #included in gtest/internal/gtest-internal.h.
2849// Do not include this header file separately!
2850
2851// GOOGLETEST_CM0001 DO NOT DELETE
2852
2853#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
2854#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
2855
Austin Schuh70cc9552019-01-21 19:46:48 -08002856// Copyright 2005, Google Inc.
2857// All rights reserved.
2858//
2859// Redistribution and use in source and binary forms, with or without
2860// modification, are permitted provided that the following conditions are
2861// met:
2862//
2863// * Redistributions of source code must retain the above copyright
2864// notice, this list of conditions and the following disclaimer.
2865// * Redistributions in binary form must reproduce the above
2866// copyright notice, this list of conditions and the following disclaimer
2867// in the documentation and/or other materials provided with the
2868// distribution.
2869// * Neither the name of Google Inc. nor the names of its
2870// contributors may be used to endorse or promote products derived from
2871// this software without specific prior written permission.
2872//
2873// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2874// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2875// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2876// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2877// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2878// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2879// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2880// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2881// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2882// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2883// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2884//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002885// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -08002886//
2887// This header file declares the String class and functions used internally by
2888// Google Test. They are subject to change without notice. They should not used
2889// by code external to Google Test.
2890//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002891// This header file is #included by gtest-internal.h.
Austin Schuh70cc9552019-01-21 19:46:48 -08002892// It should not be #included by other files.
2893
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08002894// GOOGLETEST_CM0001 DO NOT DELETE
2895
Austin Schuh70cc9552019-01-21 19:46:48 -08002896#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2897#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2898
2899#ifdef __BORLANDC__
2900// string.h is not guaranteed to provide strcpy on C++ Builder.
2901# include <mem.h>
2902#endif
2903
2904#include <string.h>
2905#include <string>
2906
2907
2908namespace testing {
2909namespace internal {
2910
2911// String - an abstract class holding static string utilities.
2912class GTEST_API_ String {
2913 public:
2914 // Static utility methods
2915
2916 // Clones a 0-terminated C string, allocating memory using new. The
2917 // caller is responsible for deleting the return value using
2918 // delete[]. Returns the cloned string, or NULL if the input is
2919 // NULL.
2920 //
2921 // This is different from strdup() in string.h, which allocates
2922 // memory using malloc().
2923 static const char* CloneCString(const char* c_str);
2924
2925#if GTEST_OS_WINDOWS_MOBILE
2926 // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
2927 // able to pass strings to Win32 APIs on CE we need to convert them
2928 // to 'Unicode', UTF-16.
2929
2930 // Creates a UTF-16 wide string from the given ANSI string, allocating
2931 // memory using new. The caller is responsible for deleting the return
2932 // value using delete[]. Returns the wide string, or NULL if the
2933 // input is NULL.
2934 //
2935 // The wide string is created using the ANSI codepage (CP_ACP) to
2936 // match the behaviour of the ANSI versions of Win32 calls and the
2937 // C runtime.
2938 static LPCWSTR AnsiToUtf16(const char* c_str);
2939
2940 // Creates an ANSI string from the given wide string, allocating
2941 // memory using new. The caller is responsible for deleting the return
2942 // value using delete[]. Returns the ANSI string, or NULL if the
2943 // input is NULL.
2944 //
2945 // The returned string is created using the ANSI codepage (CP_ACP) to
2946 // match the behaviour of the ANSI versions of Win32 calls and the
2947 // C runtime.
2948 static const char* Utf16ToAnsi(LPCWSTR utf16_str);
2949#endif
2950
2951 // Compares two C strings. Returns true iff they have the same content.
2952 //
2953 // Unlike strcmp(), this function can handle NULL argument(s). A
2954 // NULL C string is considered different to any non-NULL C string,
2955 // including the empty string.
2956 static bool CStringEquals(const char* lhs, const char* rhs);
2957
2958 // Converts a wide C string to a String using the UTF-8 encoding.
2959 // NULL will be converted to "(null)". If an error occurred during
2960 // the conversion, "(failed to convert from wide string)" is
2961 // returned.
2962 static std::string ShowWideCString(const wchar_t* wide_c_str);
2963
2964 // Compares two wide C strings. Returns true iff they have the same
2965 // content.
2966 //
2967 // Unlike wcscmp(), this function can handle NULL argument(s). A
2968 // NULL C string is considered different to any non-NULL C string,
2969 // including the empty string.
2970 static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
2971
2972 // Compares two C strings, ignoring case. Returns true iff they
2973 // have the same content.
2974 //
2975 // Unlike strcasecmp(), this function can handle NULL argument(s).
2976 // A NULL C string is considered different to any non-NULL C string,
2977 // including the empty string.
2978 static bool CaseInsensitiveCStringEquals(const char* lhs,
2979 const char* rhs);
2980
2981 // Compares two wide C strings, ignoring case. Returns true iff they
2982 // have the same content.
2983 //
2984 // Unlike wcscasecmp(), this function can handle NULL argument(s).
2985 // A NULL C string is considered different to any non-NULL wide C string,
2986 // including the empty string.
2987 // NB: The implementations on different platforms slightly differ.
2988 // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
2989 // environment variable. On GNU platform this method uses wcscasecmp
2990 // which compares according to LC_CTYPE category of the current locale.
2991 // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
2992 // current locale.
2993 static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
2994 const wchar_t* rhs);
2995
2996 // Returns true iff the given string ends with the given suffix, ignoring
2997 // case. Any string is considered to end with an empty suffix.
2998 static bool EndsWithCaseInsensitive(
2999 const std::string& str, const std::string& suffix);
3000
3001 // Formats an int value as "%02d".
3002 static std::string FormatIntWidth2(int value); // "%02d" for width == 2
3003
3004 // Formats an int value as "%X".
3005 static std::string FormatHexInt(int value);
3006
3007 // Formats a byte as "%02X".
3008 static std::string FormatByte(unsigned char value);
3009
3010 private:
3011 String(); // Not meant to be instantiated.
3012}; // class String
3013
3014// Gets the content of the stringstream's buffer as an std::string. Each '\0'
3015// character in the buffer is replaced with "\\0".
3016GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
3017
3018} // namespace internal
3019} // namespace testing
3020
3021#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
Austin Schuh70cc9552019-01-21 19:46:48 -08003022
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003023GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
3024/* class A needs to have dll-interface to be used by clients of class B */)
Austin Schuh70cc9552019-01-21 19:46:48 -08003025
3026namespace testing {
3027namespace internal {
3028
3029// FilePath - a class for file and directory pathname manipulation which
3030// handles platform-specific conventions (like the pathname separator).
3031// Used for helper functions for naming files in a directory for xml output.
3032// Except for Set methods, all methods are const or static, which provides an
3033// "immutable value object" -- useful for peace of mind.
3034// A FilePath with a value ending in a path separator ("like/this/") represents
3035// a directory, otherwise it is assumed to represent a file. In either case,
3036// it may or may not represent an actual file or directory in the file system.
3037// Names are NOT checked for syntax correctness -- no checking for illegal
3038// characters, malformed paths, etc.
3039
3040class GTEST_API_ FilePath {
3041 public:
3042 FilePath() : pathname_("") { }
3043 FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
3044
3045 explicit FilePath(const std::string& pathname) : pathname_(pathname) {
3046 Normalize();
3047 }
3048
3049 FilePath& operator=(const FilePath& rhs) {
3050 Set(rhs);
3051 return *this;
3052 }
3053
3054 void Set(const FilePath& rhs) {
3055 pathname_ = rhs.pathname_;
3056 }
3057
3058 const std::string& string() const { return pathname_; }
3059 const char* c_str() const { return pathname_.c_str(); }
3060
3061 // Returns the current working directory, or "" if unsuccessful.
3062 static FilePath GetCurrentDir();
3063
3064 // Given directory = "dir", base_name = "test", number = 0,
3065 // extension = "xml", returns "dir/test.xml". If number is greater
3066 // than zero (e.g., 12), returns "dir/test_12.xml".
3067 // On Windows platform, uses \ as the separator rather than /.
3068 static FilePath MakeFileName(const FilePath& directory,
3069 const FilePath& base_name,
3070 int number,
3071 const char* extension);
3072
3073 // Given directory = "dir", relative_path = "test.xml",
3074 // returns "dir/test.xml".
3075 // On Windows, uses \ as the separator rather than /.
3076 static FilePath ConcatPaths(const FilePath& directory,
3077 const FilePath& relative_path);
3078
3079 // Returns a pathname for a file that does not currently exist. The pathname
3080 // will be directory/base_name.extension or
3081 // directory/base_name_<number>.extension if directory/base_name.extension
3082 // already exists. The number will be incremented until a pathname is found
3083 // that does not already exist.
3084 // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
3085 // There could be a race condition if two or more processes are calling this
3086 // function at the same time -- they could both pick the same filename.
3087 static FilePath GenerateUniqueFileName(const FilePath& directory,
3088 const FilePath& base_name,
3089 const char* extension);
3090
3091 // Returns true iff the path is "".
3092 bool IsEmpty() const { return pathname_.empty(); }
3093
3094 // If input name has a trailing separator character, removes it and returns
3095 // the name, otherwise return the name string unmodified.
3096 // On Windows platform, uses \ as the separator, other platforms use /.
3097 FilePath RemoveTrailingPathSeparator() const;
3098
3099 // Returns a copy of the FilePath with the directory part removed.
3100 // Example: FilePath("path/to/file").RemoveDirectoryName() returns
3101 // FilePath("file"). If there is no directory part ("just_a_file"), it returns
3102 // the FilePath unmodified. If there is no file part ("just_a_dir/") it
3103 // returns an empty FilePath ("").
3104 // On Windows platform, '\' is the path separator, otherwise it is '/'.
3105 FilePath RemoveDirectoryName() const;
3106
3107 // RemoveFileName returns the directory path with the filename removed.
3108 // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
3109 // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
3110 // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
3111 // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
3112 // On Windows platform, '\' is the path separator, otherwise it is '/'.
3113 FilePath RemoveFileName() const;
3114
3115 // Returns a copy of the FilePath with the case-insensitive extension removed.
3116 // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
3117 // FilePath("dir/file"). If a case-insensitive extension is not
3118 // found, returns a copy of the original FilePath.
3119 FilePath RemoveExtension(const char* extension) const;
3120
3121 // Creates directories so that path exists. Returns true if successful or if
3122 // the directories already exist; returns false if unable to create
3123 // directories for any reason. Will also return false if the FilePath does
3124 // not represent a directory (that is, it doesn't end with a path separator).
3125 bool CreateDirectoriesRecursively() const;
3126
3127 // Create the directory so that path exists. Returns true if successful or
3128 // if the directory already exists; returns false if unable to create the
3129 // directory for any reason, including if the parent directory does not
3130 // exist. Not named "CreateDirectory" because that's a macro on Windows.
3131 bool CreateFolder() const;
3132
3133 // Returns true if FilePath describes something in the file-system,
3134 // either a file, directory, or whatever, and that something exists.
3135 bool FileOrDirectoryExists() const;
3136
3137 // Returns true if pathname describes a directory in the file-system
3138 // that exists.
3139 bool DirectoryExists() const;
3140
3141 // Returns true if FilePath ends with a path separator, which indicates that
3142 // it is intended to represent a directory. Returns false otherwise.
3143 // This does NOT check that a directory (or file) actually exists.
3144 bool IsDirectory() const;
3145
3146 // Returns true if pathname describes a root directory. (Windows has one
3147 // root directory per disk drive.)
3148 bool IsRootDirectory() const;
3149
3150 // Returns true if pathname describes an absolute path.
3151 bool IsAbsolutePath() const;
3152
3153 private:
3154 // Replaces multiple consecutive separators with a single separator.
3155 // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
3156 // redundancies that might be in a pathname involving "." or "..".
3157 //
3158 // A pathname with multiple consecutive separators may occur either through
3159 // user error or as a result of some scripts or APIs that generate a pathname
3160 // with a trailing separator. On other platforms the same API or script
3161 // may NOT generate a pathname with a trailing "/". Then elsewhere that
3162 // pathname may have another "/" and pathname components added to it,
3163 // without checking for the separator already being there.
3164 // The script language and operating system may allow paths like "foo//bar"
3165 // but some of the functions in FilePath will not handle that correctly. In
3166 // particular, RemoveTrailingPathSeparator() only removes one separator, and
3167 // it is called in CreateDirectoriesRecursively() assuming that it will change
3168 // a pathname from directory syntax (trailing separator) to filename syntax.
3169 //
3170 // On Windows this method also replaces the alternate path separator '/' with
3171 // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
3172 // "bar\\foo".
3173
3174 void Normalize();
3175
3176 // Returns a pointer to the last occurence of a valid path separator in
3177 // the FilePath. On Windows, for example, both '/' and '\' are valid path
3178 // separators. Returns NULL if no path separator was found.
3179 const char* FindLastPathSeparator() const;
3180
3181 std::string pathname_;
3182}; // class FilePath
3183
3184} // namespace internal
3185} // namespace testing
3186
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003187GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
3188
Austin Schuh70cc9552019-01-21 19:46:48 -08003189#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
3190// This file was GENERATED by command:
3191// pump.py gtest-type-util.h.pump
3192// DO NOT EDIT BY HAND!!!
3193
3194// Copyright 2008 Google Inc.
3195// All Rights Reserved.
3196//
3197// Redistribution and use in source and binary forms, with or without
3198// modification, are permitted provided that the following conditions are
3199// met:
3200//
3201// * Redistributions of source code must retain the above copyright
3202// notice, this list of conditions and the following disclaimer.
3203// * Redistributions in binary form must reproduce the above
3204// copyright notice, this list of conditions and the following disclaimer
3205// in the documentation and/or other materials provided with the
3206// distribution.
3207// * Neither the name of Google Inc. nor the names of its
3208// contributors may be used to endorse or promote products derived from
3209// this software without specific prior written permission.
3210//
3211// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3212// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3213// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3214// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3215// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3216// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3217// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3218// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3219// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3220// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3221// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh70cc9552019-01-21 19:46:48 -08003222
3223// Type utilities needed for implementing typed and type-parameterized
3224// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
3225//
3226// Currently we support at most 50 types in a list, and at most 50
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003227// type-parameterized tests in one type-parameterized test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -08003228// Please contact googletestframework@googlegroups.com if you need
3229// more.
3230
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003231// GOOGLETEST_CM0001 DO NOT DELETE
3232
Austin Schuh70cc9552019-01-21 19:46:48 -08003233#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3234#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3235
3236
3237// #ifdef __GNUC__ is too general here. It is possible to use gcc without using
3238// libstdc++ (which is where cxxabi.h comes from).
3239# if GTEST_HAS_CXXABI_H_
3240# include <cxxabi.h>
3241# elif defined(__HP_aCC)
3242# include <acxx_demangle.h>
3243# endif // GTEST_HASH_CXXABI_H_
3244
3245namespace testing {
3246namespace internal {
3247
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003248// Canonicalizes a given name with respect to the Standard C++ Library.
3249// This handles removing the inline namespace within `std` that is
3250// used by various standard libraries (e.g., `std::__1`). Names outside
3251// of namespace std are returned unmodified.
3252inline std::string CanonicalizeForStdLibVersioning(std::string s) {
3253 static const char prefix[] = "std::__";
3254 if (s.compare(0, strlen(prefix), prefix) == 0) {
3255 std::string::size_type end = s.find("::", strlen(prefix));
3256 if (end != s.npos) {
3257 // Erase everything between the initial `std` and the second `::`.
3258 s.erase(strlen("std"), end - strlen("std"));
3259 }
3260 }
3261 return s;
3262}
3263
Austin Schuh70cc9552019-01-21 19:46:48 -08003264// GetTypeName<T>() returns a human-readable name of type T.
3265// NB: This function is also used in Google Mock, so don't move it inside of
3266// the typed-test-only section below.
3267template <typename T>
3268std::string GetTypeName() {
3269# if GTEST_HAS_RTTI
3270
3271 const char* const name = typeid(T).name();
3272# if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
3273 int status = 0;
3274 // gcc's implementation of typeid(T).name() mangles the type name,
3275 // so we have to demangle it.
3276# if GTEST_HAS_CXXABI_H_
3277 using abi::__cxa_demangle;
3278# endif // GTEST_HAS_CXXABI_H_
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003279 char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status);
Austin Schuh70cc9552019-01-21 19:46:48 -08003280 const std::string name_str(status == 0 ? readable_name : name);
3281 free(readable_name);
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08003282 return CanonicalizeForStdLibVersioning(name_str);
Austin Schuh70cc9552019-01-21 19:46:48 -08003283# else
3284 return name;
3285# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
3286
3287# else
3288
3289 return "<type>";
3290
3291# endif // GTEST_HAS_RTTI
3292}
3293
3294#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
3295
3296// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
3297// type. This can be used as a compile-time assertion to ensure that
3298// two types are equal.
3299
3300template <typename T1, typename T2>
3301struct AssertTypeEq;
3302
3303template <typename T>
3304struct AssertTypeEq<T, T> {
3305 typedef bool type;
3306};
3307
3308// A unique type used as the default value for the arguments of class
3309// template Types. This allows us to simulate variadic templates
3310// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
3311// support directly.
3312struct None {};
3313
3314// The following family of struct and struct templates are used to
3315// represent type lists. In particular, TypesN<T1, T2, ..., TN>
3316// represents a type list with N types (T1, T2, ..., and TN) in it.
3317// Except for Types0, every struct in the family has two member types:
3318// Head for the first type in the list, and Tail for the rest of the
3319// list.
3320
3321// The empty type list.
3322struct Types0 {};
3323
3324// Type lists of length 1, 2, 3, and so on.
3325
3326template <typename T1>
3327struct Types1 {
3328 typedef T1 Head;
3329 typedef Types0 Tail;
3330};
3331template <typename T1, typename T2>
3332struct Types2 {
3333 typedef T1 Head;
3334 typedef Types1<T2> Tail;
3335};
3336
3337template <typename T1, typename T2, typename T3>
3338struct Types3 {
3339 typedef T1 Head;
3340 typedef Types2<T2, T3> Tail;
3341};
3342
3343template <typename T1, typename T2, typename T3, typename T4>
3344struct Types4 {
3345 typedef T1 Head;
3346 typedef Types3<T2, T3, T4> Tail;
3347};
3348
3349template <typename T1, typename T2, typename T3, typename T4, typename T5>
3350struct Types5 {
3351 typedef T1 Head;
3352 typedef Types4<T2, T3, T4, T5> Tail;
3353};
3354
3355template <typename T1, typename T2, typename T3, typename T4, typename T5,
3356 typename T6>
3357struct Types6 {
3358 typedef T1 Head;
3359 typedef Types5<T2, T3, T4, T5, T6> Tail;
3360};
3361
3362template <typename T1, typename T2, typename T3, typename T4, typename T5,
3363 typename T6, typename T7>
3364struct Types7 {
3365 typedef T1 Head;
3366 typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
3367};
3368
3369template <typename T1, typename T2, typename T3, typename T4, typename T5,
3370 typename T6, typename T7, typename T8>
3371struct Types8 {
3372 typedef T1 Head;
3373 typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
3374};
3375
3376template <typename T1, typename T2, typename T3, typename T4, typename T5,
3377 typename T6, typename T7, typename T8, typename T9>
3378struct Types9 {
3379 typedef T1 Head;
3380 typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
3381};
3382
3383template <typename T1, typename T2, typename T3, typename T4, typename T5,
3384 typename T6, typename T7, typename T8, typename T9, typename T10>
3385struct Types10 {
3386 typedef T1 Head;
3387 typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
3388};
3389
3390template <typename T1, typename T2, typename T3, typename T4, typename T5,
3391 typename T6, typename T7, typename T8, typename T9, typename T10,
3392 typename T11>
3393struct Types11 {
3394 typedef T1 Head;
3395 typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
3396};
3397
3398template <typename T1, typename T2, typename T3, typename T4, typename T5,
3399 typename T6, typename T7, typename T8, typename T9, typename T10,
3400 typename T11, typename T12>
3401struct Types12 {
3402 typedef T1 Head;
3403 typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
3404};
3405
3406template <typename T1, typename T2, typename T3, typename T4, typename T5,
3407 typename T6, typename T7, typename T8, typename T9, typename T10,
3408 typename T11, typename T12, typename T13>
3409struct Types13 {
3410 typedef T1 Head;
3411 typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
3412};
3413
3414template <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>
3417struct Types14 {
3418 typedef T1 Head;
3419 typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
3420};
3421
3422template <typename T1, typename T2, typename T3, typename T4, typename T5,
3423 typename T6, typename T7, typename T8, typename T9, typename T10,
3424 typename T11, typename T12, typename T13, typename T14, typename T15>
3425struct Types15 {
3426 typedef T1 Head;
3427 typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
3428 T15> Tail;
3429};
3430
3431template <typename T1, typename T2, typename T3, typename T4, typename T5,
3432 typename T6, typename T7, typename T8, typename T9, typename T10,
3433 typename T11, typename T12, typename T13, typename T14, typename T15,
3434 typename T16>
3435struct Types16 {
3436 typedef T1 Head;
3437 typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3438 T16> Tail;
3439};
3440
3441template <typename T1, typename T2, typename T3, typename T4, typename T5,
3442 typename T6, typename T7, typename T8, typename T9, typename T10,
3443 typename T11, typename T12, typename T13, typename T14, typename T15,
3444 typename T16, typename T17>
3445struct Types17 {
3446 typedef T1 Head;
3447 typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3448 T16, T17> Tail;
3449};
3450
3451template <typename T1, typename T2, typename T3, typename T4, typename T5,
3452 typename T6, typename T7, typename T8, typename T9, typename T10,
3453 typename T11, typename T12, typename T13, typename T14, typename T15,
3454 typename T16, typename T17, typename T18>
3455struct Types18 {
3456 typedef T1 Head;
3457 typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3458 T16, T17, T18> Tail;
3459};
3460
3461template <typename T1, typename T2, typename T3, typename T4, typename T5,
3462 typename T6, typename T7, typename T8, typename T9, typename T10,
3463 typename T11, typename T12, typename T13, typename T14, typename T15,
3464 typename T16, typename T17, typename T18, typename T19>
3465struct Types19 {
3466 typedef T1 Head;
3467 typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3468 T16, T17, T18, T19> Tail;
3469};
3470
3471template <typename T1, typename T2, typename T3, typename T4, typename T5,
3472 typename T6, typename T7, typename T8, typename T9, typename T10,
3473 typename T11, typename T12, typename T13, typename T14, typename T15,
3474 typename T16, typename T17, typename T18, typename T19, typename T20>
3475struct Types20 {
3476 typedef T1 Head;
3477 typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3478 T16, T17, T18, T19, T20> Tail;
3479};
3480
3481template <typename T1, typename T2, typename T3, typename T4, typename T5,
3482 typename T6, typename T7, typename T8, typename T9, typename T10,
3483 typename T11, typename T12, typename T13, typename T14, typename T15,
3484 typename T16, typename T17, typename T18, typename T19, typename T20,
3485 typename T21>
3486struct Types21 {
3487 typedef T1 Head;
3488 typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3489 T16, T17, T18, T19, T20, T21> Tail;
3490};
3491
3492template <typename T1, typename T2, typename T3, typename T4, typename T5,
3493 typename T6, typename T7, typename T8, typename T9, typename T10,
3494 typename T11, typename T12, typename T13, typename T14, typename T15,
3495 typename T16, typename T17, typename T18, typename T19, typename T20,
3496 typename T21, typename T22>
3497struct Types22 {
3498 typedef T1 Head;
3499 typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3500 T16, T17, T18, T19, T20, T21, T22> Tail;
3501};
3502
3503template <typename T1, typename T2, typename T3, typename T4, typename T5,
3504 typename T6, typename T7, typename T8, typename T9, typename T10,
3505 typename T11, typename T12, typename T13, typename T14, typename T15,
3506 typename T16, typename T17, typename T18, typename T19, typename T20,
3507 typename T21, typename T22, typename T23>
3508struct Types23 {
3509 typedef T1 Head;
3510 typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3511 T16, T17, T18, T19, T20, T21, T22, T23> Tail;
3512};
3513
3514template <typename T1, typename T2, typename T3, typename T4, typename T5,
3515 typename T6, typename T7, typename T8, typename T9, typename T10,
3516 typename T11, typename T12, typename T13, typename T14, typename T15,
3517 typename T16, typename T17, typename T18, typename T19, typename T20,
3518 typename T21, typename T22, typename T23, typename T24>
3519struct Types24 {
3520 typedef T1 Head;
3521 typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3522 T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
3523};
3524
3525template <typename T1, typename T2, typename T3, typename T4, typename T5,
3526 typename T6, typename T7, typename T8, typename T9, typename T10,
3527 typename T11, typename T12, typename T13, typename T14, typename T15,
3528 typename T16, typename T17, typename T18, typename T19, typename T20,
3529 typename T21, typename T22, typename T23, typename T24, typename T25>
3530struct Types25 {
3531 typedef T1 Head;
3532 typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3533 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
3534};
3535
3536template <typename T1, typename T2, typename T3, typename T4, typename T5,
3537 typename T6, typename T7, typename T8, typename T9, typename T10,
3538 typename T11, typename T12, typename T13, typename T14, typename T15,
3539 typename T16, typename T17, typename T18, typename T19, typename T20,
3540 typename T21, typename T22, typename T23, typename T24, typename T25,
3541 typename T26>
3542struct Types26 {
3543 typedef T1 Head;
3544 typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3545 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
3546};
3547
3548template <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>
3554struct Types27 {
3555 typedef T1 Head;
3556 typedef Types26<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> Tail;
3558};
3559
3560template <typename T1, typename T2, typename T3, typename T4, typename T5,
3561 typename T6, typename T7, typename T8, typename T9, typename T10,
3562 typename T11, typename T12, typename T13, typename T14, typename T15,
3563 typename T16, typename T17, typename T18, typename T19, typename T20,
3564 typename T21, typename T22, typename T23, typename T24, typename T25,
3565 typename T26, typename T27, typename T28>
3566struct Types28 {
3567 typedef T1 Head;
3568 typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3569 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
3570};
3571
3572template <typename T1, typename T2, typename T3, typename T4, typename T5,
3573 typename T6, typename T7, typename T8, typename T9, typename T10,
3574 typename T11, typename T12, typename T13, typename T14, typename T15,
3575 typename T16, typename T17, typename T18, typename T19, typename T20,
3576 typename T21, typename T22, typename T23, typename T24, typename T25,
3577 typename T26, typename T27, typename T28, typename T29>
3578struct Types29 {
3579 typedef T1 Head;
3580 typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3581 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
3582 T29> Tail;
3583};
3584
3585template <typename T1, typename T2, typename T3, typename T4, typename T5,
3586 typename T6, typename T7, typename T8, typename T9, typename T10,
3587 typename T11, typename T12, typename T13, typename T14, typename T15,
3588 typename T16, typename T17, typename T18, typename T19, typename T20,
3589 typename T21, typename T22, typename T23, typename T24, typename T25,
3590 typename T26, typename T27, typename T28, typename T29, typename T30>
3591struct Types30 {
3592 typedef T1 Head;
3593 typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3594 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3595 T30> Tail;
3596};
3597
3598template <typename T1, typename T2, typename T3, typename T4, typename T5,
3599 typename T6, typename T7, typename T8, typename T9, typename T10,
3600 typename T11, typename T12, typename T13, typename T14, typename T15,
3601 typename T16, typename T17, typename T18, typename T19, typename T20,
3602 typename T21, typename T22, typename T23, typename T24, typename T25,
3603 typename T26, typename T27, typename T28, typename T29, typename T30,
3604 typename T31>
3605struct Types31 {
3606 typedef T1 Head;
3607 typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3608 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3609 T30, T31> Tail;
3610};
3611
3612template <typename T1, typename T2, typename T3, typename T4, typename T5,
3613 typename T6, typename T7, typename T8, typename T9, typename T10,
3614 typename T11, typename T12, typename T13, typename T14, typename T15,
3615 typename T16, typename T17, typename T18, typename T19, typename T20,
3616 typename T21, typename T22, typename T23, typename T24, typename T25,
3617 typename T26, typename T27, typename T28, typename T29, typename T30,
3618 typename T31, typename T32>
3619struct Types32 {
3620 typedef T1 Head;
3621 typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3622 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3623 T30, T31, T32> Tail;
3624};
3625
3626template <typename T1, typename T2, typename T3, typename T4, typename T5,
3627 typename T6, typename T7, typename T8, typename T9, typename T10,
3628 typename T11, typename T12, typename T13, typename T14, typename T15,
3629 typename T16, typename T17, typename T18, typename T19, typename T20,
3630 typename T21, typename T22, typename T23, typename T24, typename T25,
3631 typename T26, typename T27, typename T28, typename T29, typename T30,
3632 typename T31, typename T32, typename T33>
3633struct Types33 {
3634 typedef T1 Head;
3635 typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3636 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3637 T30, T31, T32, T33> Tail;
3638};
3639
3640template <typename T1, typename T2, typename T3, typename T4, typename T5,
3641 typename T6, typename T7, typename T8, typename T9, typename T10,
3642 typename T11, typename T12, typename T13, typename T14, typename T15,
3643 typename T16, typename T17, typename T18, typename T19, typename T20,
3644 typename T21, typename T22, typename T23, typename T24, typename T25,
3645 typename T26, typename T27, typename T28, typename T29, typename T30,
3646 typename T31, typename T32, typename T33, typename T34>
3647struct Types34 {
3648 typedef T1 Head;
3649 typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3650 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3651 T30, T31, T32, T33, T34> Tail;
3652};
3653
3654template <typename T1, typename T2, typename T3, typename T4, typename T5,
3655 typename T6, typename T7, typename T8, typename T9, typename T10,
3656 typename T11, typename T12, typename T13, typename T14, typename T15,
3657 typename T16, typename T17, typename T18, typename T19, typename T20,
3658 typename T21, typename T22, typename T23, typename T24, typename T25,
3659 typename T26, typename T27, typename T28, typename T29, typename T30,
3660 typename T31, typename T32, typename T33, typename T34, typename T35>
3661struct Types35 {
3662 typedef T1 Head;
3663 typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3664 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3665 T30, T31, T32, T33, T34, T35> Tail;
3666};
3667
3668template <typename T1, typename T2, typename T3, typename T4, typename T5,
3669 typename T6, typename T7, typename T8, typename T9, typename T10,
3670 typename T11, typename T12, typename T13, typename T14, typename T15,
3671 typename T16, typename T17, typename T18, typename T19, typename T20,
3672 typename T21, typename T22, typename T23, typename T24, typename T25,
3673 typename T26, typename T27, typename T28, typename T29, typename T30,
3674 typename T31, typename T32, typename T33, typename T34, typename T35,
3675 typename T36>
3676struct Types36 {
3677 typedef T1 Head;
3678 typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3679 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3680 T30, T31, T32, T33, T34, T35, T36> Tail;
3681};
3682
3683template <typename T1, typename T2, typename T3, typename T4, typename T5,
3684 typename T6, typename T7, typename T8, typename T9, typename T10,
3685 typename T11, typename T12, typename T13, typename T14, typename T15,
3686 typename T16, typename T17, typename T18, typename T19, typename T20,
3687 typename T21, typename T22, typename T23, typename T24, typename T25,
3688 typename T26, typename T27, typename T28, typename T29, typename T30,
3689 typename T31, typename T32, typename T33, typename T34, typename T35,
3690 typename T36, typename T37>
3691struct Types37 {
3692 typedef T1 Head;
3693 typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3694 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3695 T30, T31, T32, T33, T34, T35, T36, T37> Tail;
3696};
3697
3698template <typename T1, typename T2, typename T3, typename T4, typename T5,
3699 typename T6, typename T7, typename T8, typename T9, typename T10,
3700 typename T11, typename T12, typename T13, typename T14, typename T15,
3701 typename T16, typename T17, typename T18, typename T19, typename T20,
3702 typename T21, typename T22, typename T23, typename T24, typename T25,
3703 typename T26, typename T27, typename T28, typename T29, typename T30,
3704 typename T31, typename T32, typename T33, typename T34, typename T35,
3705 typename T36, typename T37, typename T38>
3706struct Types38 {
3707 typedef T1 Head;
3708 typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3709 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3710 T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
3711};
3712
3713template <typename T1, typename T2, typename T3, typename T4, typename T5,
3714 typename T6, typename T7, typename T8, typename T9, typename T10,
3715 typename T11, typename T12, typename T13, typename T14, typename T15,
3716 typename T16, typename T17, typename T18, typename T19, typename T20,
3717 typename T21, typename T22, typename T23, typename T24, typename T25,
3718 typename T26, typename T27, typename T28, typename T29, typename T30,
3719 typename T31, typename T32, typename T33, typename T34, typename T35,
3720 typename T36, typename T37, typename T38, typename T39>
3721struct Types39 {
3722 typedef T1 Head;
3723 typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3724 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3725 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
3726};
3727
3728template <typename T1, typename T2, typename T3, typename T4, typename T5,
3729 typename T6, typename T7, typename T8, typename T9, typename T10,
3730 typename T11, typename T12, typename T13, typename T14, typename T15,
3731 typename T16, typename T17, typename T18, typename T19, typename T20,
3732 typename T21, typename T22, typename T23, typename T24, typename T25,
3733 typename T26, typename T27, typename T28, typename T29, typename T30,
3734 typename T31, typename T32, typename T33, typename T34, typename T35,
3735 typename T36, typename T37, typename T38, typename T39, typename T40>
3736struct Types40 {
3737 typedef T1 Head;
3738 typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3739 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3740 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
3741};
3742
3743template <typename T1, typename T2, typename T3, typename T4, typename T5,
3744 typename T6, typename T7, typename T8, typename T9, typename T10,
3745 typename T11, typename T12, typename T13, typename T14, typename T15,
3746 typename T16, typename T17, typename T18, typename T19, typename T20,
3747 typename T21, typename T22, typename T23, typename T24, typename T25,
3748 typename T26, typename T27, typename T28, typename T29, typename T30,
3749 typename T31, typename T32, typename T33, typename T34, typename T35,
3750 typename T36, typename T37, typename T38, typename T39, typename T40,
3751 typename T41>
3752struct Types41 {
3753 typedef T1 Head;
3754 typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3755 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3756 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
3757};
3758
3759template <typename T1, typename T2, typename T3, typename T4, typename T5,
3760 typename T6, typename T7, typename T8, typename T9, typename T10,
3761 typename T11, typename T12, typename T13, typename T14, typename T15,
3762 typename T16, typename T17, typename T18, typename T19, typename T20,
3763 typename T21, typename T22, typename T23, typename T24, typename T25,
3764 typename T26, typename T27, typename T28, typename T29, typename T30,
3765 typename T31, typename T32, typename T33, typename T34, typename T35,
3766 typename T36, typename T37, typename T38, typename T39, typename T40,
3767 typename T41, typename T42>
3768struct Types42 {
3769 typedef T1 Head;
3770 typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3771 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3772 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
3773};
3774
3775template <typename T1, typename T2, typename T3, typename T4, typename T5,
3776 typename T6, typename T7, typename T8, typename T9, typename T10,
3777 typename T11, typename T12, typename T13, typename T14, typename T15,
3778 typename T16, typename T17, typename T18, typename T19, typename T20,
3779 typename T21, typename T22, typename T23, typename T24, typename T25,
3780 typename T26, typename T27, typename T28, typename T29, typename T30,
3781 typename T31, typename T32, typename T33, typename T34, typename T35,
3782 typename T36, typename T37, typename T38, typename T39, typename T40,
3783 typename T41, typename T42, typename T43>
3784struct Types43 {
3785 typedef T1 Head;
3786 typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3787 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3788 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
3789 T43> Tail;
3790};
3791
3792template <typename T1, typename T2, typename T3, typename T4, typename T5,
3793 typename T6, typename T7, typename T8, typename T9, typename T10,
3794 typename T11, typename T12, typename T13, typename T14, typename T15,
3795 typename T16, typename T17, typename T18, typename T19, typename T20,
3796 typename T21, typename T22, typename T23, typename T24, typename T25,
3797 typename T26, typename T27, typename T28, typename T29, typename T30,
3798 typename T31, typename T32, typename T33, typename T34, typename T35,
3799 typename T36, typename T37, typename T38, typename T39, typename T40,
3800 typename T41, typename T42, typename T43, typename T44>
3801struct Types44 {
3802 typedef T1 Head;
3803 typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3804 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3805 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3806 T44> Tail;
3807};
3808
3809template <typename T1, typename T2, typename T3, typename T4, typename T5,
3810 typename T6, typename T7, typename T8, typename T9, typename T10,
3811 typename T11, typename T12, typename T13, typename T14, typename T15,
3812 typename T16, typename T17, typename T18, typename T19, typename T20,
3813 typename T21, typename T22, typename T23, typename T24, typename T25,
3814 typename T26, typename T27, typename T28, typename T29, typename T30,
3815 typename T31, typename T32, typename T33, typename T34, typename T35,
3816 typename T36, typename T37, typename T38, typename T39, typename T40,
3817 typename T41, typename T42, typename T43, typename T44, typename T45>
3818struct Types45 {
3819 typedef T1 Head;
3820 typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3821 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3822 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3823 T44, T45> Tail;
3824};
3825
3826template <typename T1, typename T2, typename T3, typename T4, typename T5,
3827 typename T6, typename T7, typename T8, typename T9, typename T10,
3828 typename T11, typename T12, typename T13, typename T14, typename T15,
3829 typename T16, typename T17, typename T18, typename T19, typename T20,
3830 typename T21, typename T22, typename T23, typename T24, typename T25,
3831 typename T26, typename T27, typename T28, typename T29, typename T30,
3832 typename T31, typename T32, typename T33, typename T34, typename T35,
3833 typename T36, typename T37, typename T38, typename T39, typename T40,
3834 typename T41, typename T42, typename T43, typename T44, typename T45,
3835 typename T46>
3836struct Types46 {
3837 typedef T1 Head;
3838 typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3839 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3840 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3841 T44, T45, T46> Tail;
3842};
3843
3844template <typename T1, typename T2, typename T3, typename T4, typename T5,
3845 typename T6, typename T7, typename T8, typename T9, typename T10,
3846 typename T11, typename T12, typename T13, typename T14, typename T15,
3847 typename T16, typename T17, typename T18, typename T19, typename T20,
3848 typename T21, typename T22, typename T23, typename T24, typename T25,
3849 typename T26, typename T27, typename T28, typename T29, typename T30,
3850 typename T31, typename T32, typename T33, typename T34, typename T35,
3851 typename T36, typename T37, typename T38, typename T39, typename T40,
3852 typename T41, typename T42, typename T43, typename T44, typename T45,
3853 typename T46, typename T47>
3854struct Types47 {
3855 typedef T1 Head;
3856 typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3857 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3858 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3859 T44, T45, T46, T47> Tail;
3860};
3861
3862template <typename T1, typename T2, typename T3, typename T4, typename T5,
3863 typename T6, typename T7, typename T8, typename T9, typename T10,
3864 typename T11, typename T12, typename T13, typename T14, typename T15,
3865 typename T16, typename T17, typename T18, typename T19, typename T20,
3866 typename T21, typename T22, typename T23, typename T24, typename T25,
3867 typename T26, typename T27, typename T28, typename T29, typename T30,
3868 typename T31, typename T32, typename T33, typename T34, typename T35,
3869 typename T36, typename T37, typename T38, typename T39, typename T40,
3870 typename T41, typename T42, typename T43, typename T44, typename T45,
3871 typename T46, typename T47, typename T48>
3872struct Types48 {
3873 typedef T1 Head;
3874 typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3875 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3876 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3877 T44, T45, T46, T47, T48> Tail;
3878};
3879
3880template <typename T1, typename T2, typename T3, typename T4, typename T5,
3881 typename T6, typename T7, typename T8, typename T9, typename T10,
3882 typename T11, typename T12, typename T13, typename T14, typename T15,
3883 typename T16, typename T17, typename T18, typename T19, typename T20,
3884 typename T21, typename T22, typename T23, typename T24, typename T25,
3885 typename T26, typename T27, typename T28, typename T29, typename T30,
3886 typename T31, typename T32, typename T33, typename T34, typename T35,
3887 typename T36, typename T37, typename T38, typename T39, typename T40,
3888 typename T41, typename T42, typename T43, typename T44, typename T45,
3889 typename T46, typename T47, typename T48, typename T49>
3890struct Types49 {
3891 typedef T1 Head;
3892 typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3893 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3894 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3895 T44, T45, T46, T47, T48, T49> Tail;
3896};
3897
3898template <typename T1, typename T2, typename T3, typename T4, typename T5,
3899 typename T6, typename T7, typename T8, typename T9, typename T10,
3900 typename T11, typename T12, typename T13, typename T14, typename T15,
3901 typename T16, typename T17, typename T18, typename T19, typename T20,
3902 typename T21, typename T22, typename T23, typename T24, typename T25,
3903 typename T26, typename T27, typename T28, typename T29, typename T30,
3904 typename T31, typename T32, typename T33, typename T34, typename T35,
3905 typename T36, typename T37, typename T38, typename T39, typename T40,
3906 typename T41, typename T42, typename T43, typename T44, typename T45,
3907 typename T46, typename T47, typename T48, typename T49, typename T50>
3908struct Types50 {
3909 typedef T1 Head;
3910 typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3911 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3912 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3913 T44, T45, T46, T47, T48, T49, T50> Tail;
3914};
3915
3916
3917} // namespace internal
3918
3919// We don't want to require the users to write TypesN<...> directly,
3920// as that would require them to count the length. Types<...> is much
3921// easier to write, but generates horrible messages when there is a
3922// compiler error, as gcc insists on printing out each template
3923// argument, even if it has the default value (this means Types<int>
3924// will appear as Types<int, None, None, ..., None> in the compiler
3925// errors).
3926//
3927// Our solution is to combine the best part of the two approaches: a
3928// user would write Types<T1, ..., TN>, and Google Test will translate
3929// that to TypesN<T1, ..., TN> internally to make error messages
3930// readable. The translation is done by the 'type' member of the
3931// Types template.
3932template <typename T1 = internal::None, typename T2 = internal::None,
3933 typename T3 = internal::None, typename T4 = internal::None,
3934 typename T5 = internal::None, typename T6 = internal::None,
3935 typename T7 = internal::None, typename T8 = internal::None,
3936 typename T9 = internal::None, typename T10 = internal::None,
3937 typename T11 = internal::None, typename T12 = internal::None,
3938 typename T13 = internal::None, typename T14 = internal::None,
3939 typename T15 = internal::None, typename T16 = internal::None,
3940 typename T17 = internal::None, typename T18 = internal::None,
3941 typename T19 = internal::None, typename T20 = internal::None,
3942 typename T21 = internal::None, typename T22 = internal::None,
3943 typename T23 = internal::None, typename T24 = internal::None,
3944 typename T25 = internal::None, typename T26 = internal::None,
3945 typename T27 = internal::None, typename T28 = internal::None,
3946 typename T29 = internal::None, typename T30 = internal::None,
3947 typename T31 = internal::None, typename T32 = internal::None,
3948 typename T33 = internal::None, typename T34 = internal::None,
3949 typename T35 = internal::None, typename T36 = internal::None,
3950 typename T37 = internal::None, typename T38 = internal::None,
3951 typename T39 = internal::None, typename T40 = internal::None,
3952 typename T41 = internal::None, typename T42 = internal::None,
3953 typename T43 = internal::None, typename T44 = internal::None,
3954 typename T45 = internal::None, typename T46 = internal::None,
3955 typename T47 = internal::None, typename T48 = internal::None,
3956 typename T49 = internal::None, typename T50 = internal::None>
3957struct Types {
3958 typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
3959 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
3960 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
3961 T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
3962};
3963
3964template <>
3965struct Types<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, internal::None, internal::None, internal::None,
3973 internal::None, internal::None, internal::None, internal::None,
3974 internal::None, internal::None, internal::None, internal::None,
3975 internal::None, internal::None, internal::None, internal::None,
3976 internal::None, internal::None, internal::None, internal::None,
3977 internal::None, internal::None> {
3978 typedef internal::Types0 type;
3979};
3980template <typename T1>
3981struct Types<T1, 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 internal::None, internal::None, internal::None, internal::None,
3989 internal::None, internal::None, internal::None, internal::None,
3990 internal::None, internal::None, internal::None, internal::None,
3991 internal::None, internal::None, internal::None, internal::None,
3992 internal::None, internal::None, internal::None, internal::None,
3993 internal::None, internal::None> {
3994 typedef internal::Types1<T1> type;
3995};
3996template <typename T1, typename T2>
3997struct Types<T1, T2, 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, internal::None,
4003 internal::None, internal::None, internal::None, internal::None,
4004 internal::None, internal::None, internal::None, internal::None,
4005 internal::None, internal::None, internal::None, internal::None,
4006 internal::None, internal::None, 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> {
4010 typedef internal::Types2<T1, T2> type;
4011};
4012template <typename T1, typename T2, typename T3>
4013struct Types<T1, T2, T3, 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, internal::None,
4018 internal::None, internal::None, internal::None, internal::None,
4019 internal::None, internal::None, internal::None, internal::None,
4020 internal::None, internal::None, internal::None, internal::None,
4021 internal::None, internal::None, internal::None, internal::None,
4022 internal::None, internal::None, internal::None, internal::None,
4023 internal::None, internal::None, internal::None, internal::None,
4024 internal::None, internal::None, internal::None, internal::None> {
4025 typedef internal::Types3<T1, T2, T3> type;
4026};
4027template <typename T1, typename T2, typename T3, typename T4>
4028struct Types<T1, T2, T3, T4, 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, internal::None, internal::None,
4034 internal::None, internal::None, internal::None, internal::None,
4035 internal::None, internal::None, internal::None, internal::None,
4036 internal::None, internal::None, internal::None, internal::None,
4037 internal::None, internal::None, internal::None, internal::None,
4038 internal::None, internal::None, internal::None, internal::None,
4039 internal::None, internal::None, internal::None> {
4040 typedef internal::Types4<T1, T2, T3, T4> type;
4041};
4042template <typename T1, typename T2, typename T3, typename T4, typename T5>
4043struct Types<T1, T2, T3, T4, T5, 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, internal::None, internal::None, internal::None,
4050 internal::None, internal::None, internal::None, internal::None,
4051 internal::None, internal::None, internal::None, internal::None,
4052 internal::None, internal::None, internal::None, internal::None,
4053 internal::None, internal::None, internal::None, internal::None,
4054 internal::None, internal::None, internal::None> {
4055 typedef internal::Types5<T1, T2, T3, T4, T5> type;
4056};
4057template <typename T1, typename T2, typename T3, typename T4, typename T5,
4058 typename T6>
4059struct Types<T1, T2, T3, T4, T5, T6, 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 internal::None, internal::None, internal::None, internal::None,
4066 internal::None, internal::None, internal::None, internal::None,
4067 internal::None, internal::None, internal::None, internal::None,
4068 internal::None, internal::None, internal::None, internal::None,
4069 internal::None, internal::None, internal::None, internal::None,
4070 internal::None, internal::None> {
4071 typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
4072};
4073template <typename T1, typename T2, typename T3, typename T4, typename T5,
4074 typename T6, typename T7>
4075struct Types<T1, T2, T3, T4, T5, T6, T7, 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 internal::None, internal::None, internal::None, internal::None,
4081 internal::None, internal::None, internal::None, internal::None,
4082 internal::None, internal::None, internal::None, internal::None,
4083 internal::None, internal::None, internal::None, internal::None,
4084 internal::None, internal::None, internal::None, internal::None,
4085 internal::None, internal::None, internal::None, internal::None,
4086 internal::None> {
4087 typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
4088};
4089template <typename T1, typename T2, typename T3, typename T4, typename T5,
4090 typename T6, typename T7, typename T8>
4091struct Types<T1, T2, T3, T4, T5, T6, T7, T8, 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, internal::None,
4095 internal::None, internal::None, internal::None, internal::None,
4096 internal::None, internal::None, internal::None, internal::None,
4097 internal::None, internal::None, internal::None, internal::None,
4098 internal::None, internal::None, internal::None, internal::None,
4099 internal::None, internal::None, internal::None, internal::None,
4100 internal::None, internal::None, internal::None, internal::None,
4101 internal::None, internal::None, internal::None, internal::None> {
4102 typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
4103};
4104template <typename T1, typename T2, typename T3, typename T4, typename T5,
4105 typename T6, typename T7, typename T8, typename T9>
4106struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, 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, internal::None, internal::None,
4111 internal::None, internal::None, internal::None, internal::None,
4112 internal::None, internal::None, internal::None, internal::None,
4113 internal::None, internal::None, internal::None, internal::None,
4114 internal::None, internal::None, internal::None, internal::None,
4115 internal::None, internal::None, internal::None, internal::None,
4116 internal::None, internal::None, internal::None, internal::None> {
4117 typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
4118};
4119template <typename T1, typename T2, typename T3, typename T4, typename T5,
4120 typename T6, typename T7, typename T8, typename T9, typename T10>
4121struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, 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, internal::None, internal::None, internal::None,
4127 internal::None, internal::None, internal::None, internal::None,
4128 internal::None, internal::None, internal::None, internal::None,
4129 internal::None, internal::None, internal::None, internal::None,
4130 internal::None, internal::None, internal::None, internal::None,
4131 internal::None, internal::None, internal::None> {
4132 typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
4133};
4134template <typename T1, typename T2, typename T3, typename T4, typename T5,
4135 typename T6, typename T7, typename T8, typename T9, typename T10,
4136 typename T11>
4137struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, 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, internal::None, internal::None, internal::None,
4144 internal::None, internal::None, internal::None, internal::None,
4145 internal::None, internal::None, internal::None, internal::None,
4146 internal::None, internal::None, internal::None, internal::None,
4147 internal::None, internal::None> {
4148 typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
4149};
4150template <typename T1, typename T2, typename T3, typename T4, typename T5,
4151 typename T6, typename T7, typename T8, typename T9, typename T10,
4152 typename T11, typename T12>
4153struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, 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 internal::None, internal::None, internal::None, internal::None,
4161 internal::None, internal::None, internal::None, internal::None,
4162 internal::None, internal::None, internal::None, internal::None,
4163 internal::None> {
4164 typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
4165 T12> type;
4166};
4167template <typename T1, typename T2, typename T3, typename T4, typename T5,
4168 typename T6, typename T7, typename T8, typename T9, typename T10,
4169 typename T11, typename T12, typename T13>
4170struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
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, internal::None,
4176 internal::None, internal::None, internal::None, internal::None,
4177 internal::None, internal::None, internal::None, internal::None,
4178 internal::None, internal::None, internal::None, internal::None,
4179 internal::None, internal::None, internal::None, internal::None,
4180 internal::None> {
4181 typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4182 T13> type;
4183};
4184template <typename T1, typename T2, typename T3, typename T4, typename T5,
4185 typename T6, typename T7, typename T8, typename T9, typename T10,
4186 typename T11, typename T12, typename T13, typename T14>
4187struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
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, internal::None, internal::None,
4193 internal::None, internal::None, internal::None, internal::None,
4194 internal::None, internal::None, internal::None, internal::None,
4195 internal::None, internal::None, internal::None, internal::None,
4196 internal::None, internal::None, internal::None, internal::None> {
4197 typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4198 T13, T14> type;
4199};
4200template <typename T1, typename T2, typename T3, typename T4, typename T5,
4201 typename T6, typename T7, typename T8, typename T9, typename T10,
4202 typename T11, typename T12, typename T13, typename T14, typename T15>
4203struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
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, internal::None, internal::None, internal::None,
4210 internal::None, internal::None, internal::None, internal::None,
4211 internal::None, internal::None, internal::None, internal::None,
4212 internal::None, internal::None, internal::None> {
4213 typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4214 T13, T14, T15> type;
4215};
4216template <typename T1, typename T2, typename T3, typename T4, typename T5,
4217 typename T6, typename T7, typename T8, typename T9, typename T10,
4218 typename T11, typename T12, typename T13, typename T14, typename T15,
4219 typename T16>
4220struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4221 T16, 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, internal::None, internal::None, internal::None,
4227 internal::None, internal::None, internal::None, internal::None,
4228 internal::None, internal::None, internal::None, internal::None,
4229 internal::None, internal::None> {
4230 typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4231 T13, T14, T15, T16> type;
4232};
4233template <typename T1, typename T2, typename T3, typename T4, typename T5,
4234 typename T6, typename T7, typename T8, typename T9, typename T10,
4235 typename T11, typename T12, typename T13, typename T14, typename T15,
4236 typename T16, typename T17>
4237struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4238 T16, T17, 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 internal::None, internal::None, internal::None, internal::None,
4244 internal::None, internal::None, internal::None, internal::None,
4245 internal::None, internal::None, internal::None, internal::None,
4246 internal::None> {
4247 typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4248 T13, T14, T15, T16, T17> type;
4249};
4250template <typename T1, typename T2, typename T3, typename T4, typename T5,
4251 typename T6, typename T7, typename T8, typename T9, typename T10,
4252 typename T11, typename T12, typename T13, typename T14, typename T15,
4253 typename T16, typename T17, typename T18>
4254struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4255 T16, T17, T18, 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, internal::None,
4259 internal::None, internal::None, internal::None, internal::None,
4260 internal::None, internal::None, internal::None, internal::None,
4261 internal::None, internal::None, internal::None, internal::None,
4262 internal::None, internal::None, internal::None, internal::None,
4263 internal::None> {
4264 typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4265 T13, T14, T15, T16, T17, T18> type;
4266};
4267template <typename T1, typename T2, typename T3, typename T4, typename T5,
4268 typename T6, typename T7, typename T8, typename T9, typename T10,
4269 typename T11, typename T12, typename T13, typename T14, typename T15,
4270 typename T16, typename T17, typename T18, typename T19>
4271struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4272 T16, T17, T18, T19, 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, internal::None,
4276 internal::None, internal::None, internal::None, internal::None,
4277 internal::None, internal::None, internal::None, internal::None,
4278 internal::None, internal::None, internal::None, internal::None,
4279 internal::None, internal::None, internal::None, internal::None> {
4280 typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4281 T13, T14, T15, T16, T17, T18, T19> type;
4282};
4283template <typename T1, typename T2, typename T3, typename T4, typename T5,
4284 typename T6, typename T7, typename T8, typename T9, typename T10,
4285 typename T11, typename T12, typename T13, typename T14, typename T15,
4286 typename T16, typename T17, typename T18, typename T19, typename T20>
4287struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4288 T16, T17, T18, T19, T20, 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, internal::None, internal::None,
4293 internal::None, internal::None, internal::None, internal::None,
4294 internal::None, internal::None, internal::None, internal::None,
4295 internal::None, internal::None, internal::None> {
4296 typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4297 T13, T14, T15, T16, T17, T18, T19, T20> type;
4298};
4299template <typename T1, typename T2, typename T3, typename T4, typename T5,
4300 typename T6, typename T7, typename T8, typename T9, typename T10,
4301 typename T11, typename T12, typename T13, typename T14, typename T15,
4302 typename T16, typename T17, typename T18, typename T19, typename T20,
4303 typename T21>
4304struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4305 T16, T17, T18, T19, T20, T21, 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, internal::None, internal::None, internal::None,
4310 internal::None, internal::None, internal::None, internal::None,
4311 internal::None, internal::None, internal::None, internal::None,
4312 internal::None, internal::None, internal::None> {
4313 typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4314 T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
4315};
4316template <typename T1, typename T2, typename T3, typename T4, typename T5,
4317 typename T6, typename T7, typename T8, typename T9, typename T10,
4318 typename T11, typename T12, typename T13, typename T14, typename T15,
4319 typename T16, typename T17, typename T18, typename T19, typename T20,
4320 typename T21, typename T22>
4321struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4322 T16, T17, T18, T19, T20, T21, T22, 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, internal::None, internal::None, internal::None,
4327 internal::None, internal::None, internal::None, internal::None,
4328 internal::None, internal::None, internal::None, internal::None,
4329 internal::None, internal::None> {
4330 typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4331 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
4332};
4333template <typename T1, typename T2, typename T3, typename T4, typename T5,
4334 typename T6, typename T7, typename T8, typename T9, typename T10,
4335 typename T11, typename T12, typename T13, typename T14, typename T15,
4336 typename T16, typename T17, typename T18, typename T19, typename T20,
4337 typename T21, typename T22, typename T23>
4338struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4339 T16, T17, T18, T19, T20, T21, T22, T23, 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 internal::None, internal::None, internal::None, internal::None,
4344 internal::None, internal::None, internal::None, internal::None,
4345 internal::None, internal::None, internal::None, internal::None,
4346 internal::None> {
4347 typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4348 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
4349};
4350template <typename T1, typename T2, typename T3, typename T4, typename T5,
4351 typename T6, typename T7, typename T8, typename T9, typename T10,
4352 typename T11, typename T12, typename T13, typename T14, typename T15,
4353 typename T16, typename T17, typename T18, typename T19, typename T20,
4354 typename T21, typename T22, typename T23, typename T24>
4355struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4356 T16, T17, T18, T19, T20, T21, T22, T23, T24, 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, internal::None,
4360 internal::None, internal::None, internal::None, internal::None,
4361 internal::None, internal::None, internal::None, internal::None,
4362 internal::None, internal::None, internal::None, internal::None,
4363 internal::None> {
4364 typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4365 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
4366};
4367template <typename T1, typename T2, typename T3, typename T4, typename T5,
4368 typename T6, typename T7, typename T8, typename T9, typename T10,
4369 typename T11, typename T12, typename T13, typename T14, typename T15,
4370 typename T16, typename T17, typename T18, typename T19, typename T20,
4371 typename T21, typename T22, typename T23, typename T24, typename T25>
4372struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4373 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, 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, internal::None, internal::None,
4378 internal::None, internal::None, internal::None, internal::None,
4379 internal::None, internal::None, internal::None, internal::None> {
4380 typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4381 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
4382};
4383template <typename T1, typename T2, typename T3, typename T4, typename T5,
4384 typename T6, typename T7, typename T8, typename T9, typename T10,
4385 typename T11, typename T12, typename T13, typename T14, typename T15,
4386 typename T16, typename T17, typename T18, typename T19, typename T20,
4387 typename T21, typename T22, typename T23, typename T24, typename T25,
4388 typename T26>
4389struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4390 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, 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, internal::None, internal::None,
4396 internal::None, internal::None, internal::None> {
4397 typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4398 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
4399 T26> type;
4400};
4401template <typename T1, typename T2, typename T3, typename T4, typename T5,
4402 typename T6, typename T7, typename T8, typename T9, typename T10,
4403 typename T11, typename T12, typename T13, typename T14, typename T15,
4404 typename T16, typename T17, typename T18, typename T19, typename T20,
4405 typename T21, typename T22, typename T23, typename T24, typename T25,
4406 typename T26, typename T27>
4407struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4408 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, 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, internal::None, internal::None, internal::None,
4414 internal::None, internal::None> {
4415 typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4416 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4417 T27> type;
4418};
4419template <typename T1, typename T2, typename T3, typename T4, typename T5,
4420 typename T6, typename T7, typename T8, typename T9, typename T10,
4421 typename T11, typename T12, typename T13, typename T14, typename T15,
4422 typename T16, typename T17, typename T18, typename T19, typename T20,
4423 typename T21, typename T22, typename T23, typename T24, typename T25,
4424 typename T26, typename T27, typename T28>
4425struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4426 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
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 internal::None, internal::None, internal::None, internal::None,
4432 internal::None, internal::None> {
4433 typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4434 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4435 T27, T28> type;
4436};
4437template <typename T1, typename T2, typename T3, typename T4, typename T5,
4438 typename T6, typename T7, typename T8, typename T9, typename T10,
4439 typename T11, typename T12, typename T13, typename T14, typename T15,
4440 typename T16, typename T17, typename T18, typename T19, typename T20,
4441 typename T21, typename T22, typename T23, typename T24, typename T25,
4442 typename T26, typename T27, typename T28, typename T29>
4443struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4444 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
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, internal::None,
4449 internal::None, internal::None, internal::None, internal::None,
4450 internal::None> {
4451 typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4452 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4453 T27, T28, T29> type;
4454};
4455template <typename T1, typename T2, typename T3, typename T4, typename T5,
4456 typename T6, typename T7, typename T8, typename T9, typename T10,
4457 typename T11, typename T12, typename T13, typename T14, typename T15,
4458 typename T16, typename T17, typename T18, typename T19, typename T20,
4459 typename T21, typename T22, typename T23, typename T24, typename T25,
4460 typename T26, typename T27, typename T28, typename T29, typename T30>
4461struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4462 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
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, internal::None, internal::None,
4467 internal::None, internal::None, internal::None, internal::None> {
4468 typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4469 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4470 T27, T28, T29, T30> type;
4471};
4472template <typename T1, typename T2, typename T3, typename T4, typename T5,
4473 typename T6, typename T7, typename T8, typename T9, typename T10,
4474 typename T11, typename T12, typename T13, typename T14, typename T15,
4475 typename T16, typename T17, typename T18, typename T19, typename T20,
4476 typename T21, typename T22, typename T23, typename T24, typename T25,
4477 typename T26, typename T27, typename T28, typename T29, typename T30,
4478 typename T31>
4479struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4480 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4481 T31, 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, internal::None, internal::None,
4485 internal::None, internal::None, internal::None> {
4486 typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4487 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4488 T27, T28, T29, T30, T31> type;
4489};
4490template <typename T1, typename T2, typename T3, typename T4, typename T5,
4491 typename T6, typename T7, typename T8, typename T9, typename T10,
4492 typename T11, typename T12, typename T13, typename T14, typename T15,
4493 typename T16, typename T17, typename T18, typename T19, typename T20,
4494 typename T21, typename T22, typename T23, typename T24, typename T25,
4495 typename T26, typename T27, typename T28, typename T29, typename T30,
4496 typename T31, typename T32>
4497struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4498 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4499 T31, T32, 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, internal::None, internal::None, internal::None,
4503 internal::None, internal::None> {
4504 typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4505 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4506 T27, T28, T29, T30, T31, T32> type;
4507};
4508template <typename T1, typename T2, typename T3, typename T4, typename T5,
4509 typename T6, typename T7, typename T8, typename T9, typename T10,
4510 typename T11, typename T12, typename T13, typename T14, typename T15,
4511 typename T16, typename T17, typename T18, typename T19, typename T20,
4512 typename T21, typename T22, typename T23, typename T24, typename T25,
4513 typename T26, typename T27, typename T28, typename T29, typename T30,
4514 typename T31, typename T32, typename T33>
4515struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4516 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4517 T31, T32, T33, 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 internal::None, internal::None, internal::None, internal::None,
4521 internal::None, internal::None> {
4522 typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4523 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4524 T27, T28, T29, T30, T31, T32, T33> type;
4525};
4526template <typename T1, typename T2, typename T3, typename T4, typename T5,
4527 typename T6, typename T7, typename T8, typename T9, typename T10,
4528 typename T11, typename T12, typename T13, typename T14, typename T15,
4529 typename T16, typename T17, typename T18, typename T19, typename T20,
4530 typename T21, typename T22, typename T23, typename T24, typename T25,
4531 typename T26, typename T27, typename T28, typename T29, typename T30,
4532 typename T31, typename T32, typename T33, typename T34>
4533struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4534 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4535 T31, T32, T33, T34, 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 internal::None, internal::None, internal::None, internal::None,
4539 internal::None> {
4540 typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4541 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4542 T27, T28, T29, T30, T31, T32, T33, T34> type;
4543};
4544template <typename T1, typename T2, typename T3, typename T4, typename T5,
4545 typename T6, typename T7, typename T8, typename T9, typename T10,
4546 typename T11, typename T12, typename T13, typename T14, typename T15,
4547 typename T16, typename T17, typename T18, typename T19, typename T20,
4548 typename T21, typename T22, typename T23, typename T24, typename T25,
4549 typename T26, typename T27, typename T28, typename T29, typename T30,
4550 typename T31, typename T32, typename T33, typename T34, typename T35>
4551struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4552 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4553 T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,
4554 internal::None, internal::None, internal::None, internal::None,
4555 internal::None, internal::None, internal::None, internal::None,
4556 internal::None, internal::None, internal::None, internal::None> {
4557 typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4558 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4559 T27, T28, T29, T30, T31, T32, T33, T34, T35> type;
4560};
4561template <typename T1, typename T2, typename T3, typename T4, typename T5,
4562 typename T6, typename T7, typename T8, typename T9, typename T10,
4563 typename T11, typename T12, typename T13, typename T14, typename T15,
4564 typename T16, typename T17, typename T18, typename T19, typename T20,
4565 typename T21, typename T22, typename T23, typename T24, typename T25,
4566 typename T26, typename T27, typename T28, typename T29, typename T30,
4567 typename T31, typename T32, typename T33, typename T34, typename T35,
4568 typename T36>
4569struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4570 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4571 T31, T32, T33, T34, T35, T36, internal::None, internal::None,
4572 internal::None, internal::None, internal::None, internal::None,
4573 internal::None, internal::None, internal::None, internal::None,
4574 internal::None, internal::None, internal::None, internal::None> {
4575 typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4576 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4577 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
4578};
4579template <typename T1, typename T2, typename T3, typename T4, typename T5,
4580 typename T6, typename T7, typename T8, typename T9, typename T10,
4581 typename T11, typename T12, typename T13, typename T14, typename T15,
4582 typename T16, typename T17, typename T18, typename T19, typename T20,
4583 typename T21, typename T22, typename T23, typename T24, typename T25,
4584 typename T26, typename T27, typename T28, typename T29, typename T30,
4585 typename T31, typename T32, typename T33, typename T34, typename T35,
4586 typename T36, typename T37>
4587struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4588 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4589 T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,
4590 internal::None, internal::None, internal::None, internal::None,
4591 internal::None, internal::None, internal::None, internal::None,
4592 internal::None, internal::None, internal::None> {
4593 typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4594 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4595 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
4596};
4597template <typename T1, typename T2, typename T3, typename T4, typename T5,
4598 typename T6, typename T7, typename T8, typename T9, typename T10,
4599 typename T11, typename T12, typename T13, typename T14, typename T15,
4600 typename T16, typename T17, typename T18, typename T19, typename T20,
4601 typename T21, typename T22, typename T23, typename T24, typename T25,
4602 typename T26, typename T27, typename T28, typename T29, typename T30,
4603 typename T31, typename T32, typename T33, typename T34, typename T35,
4604 typename T36, typename T37, typename T38>
4605struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4606 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4607 T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,
4608 internal::None, internal::None, internal::None, internal::None,
4609 internal::None, internal::None, internal::None, internal::None,
4610 internal::None, internal::None> {
4611 typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4612 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4613 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
4614};
4615template <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>
4623struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4624 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4625 T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,
4626 internal::None, internal::None, internal::None, internal::None,
4627 internal::None, internal::None, internal::None, internal::None,
4628 internal::None, internal::None> {
4629 typedef internal::Types39<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> type;
4632};
4633template <typename T1, typename T2, typename T3, typename T4, typename T5,
4634 typename T6, typename T7, typename T8, typename T9, typename T10,
4635 typename T11, typename T12, typename T13, typename T14, typename T15,
4636 typename T16, typename T17, typename T18, typename T19, typename T20,
4637 typename T21, typename T22, typename T23, typename T24, typename T25,
4638 typename T26, typename T27, typename T28, typename T29, typename T30,
4639 typename T31, typename T32, typename T33, typename T34, typename T35,
4640 typename T36, typename T37, typename T38, typename T39, typename T40>
4641struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4642 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4643 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,
4644 internal::None, internal::None, internal::None, internal::None,
4645 internal::None, internal::None, internal::None, internal::None,
4646 internal::None> {
4647 typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4648 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4649 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
4650 T40> type;
4651};
4652template <typename T1, typename T2, typename T3, typename T4, typename T5,
4653 typename T6, typename T7, typename T8, typename T9, typename T10,
4654 typename T11, typename T12, typename T13, typename T14, typename T15,
4655 typename T16, typename T17, typename T18, typename T19, typename T20,
4656 typename T21, typename T22, typename T23, typename T24, typename T25,
4657 typename T26, typename T27, typename T28, typename T29, typename T30,
4658 typename T31, typename T32, typename T33, typename T34, typename T35,
4659 typename T36, typename T37, typename T38, typename T39, typename T40,
4660 typename T41>
4661struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4662 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4663 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,
4664 internal::None, internal::None, internal::None, internal::None,
4665 internal::None, internal::None, internal::None, internal::None> {
4666 typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4667 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4668 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4669 T41> type;
4670};
4671template <typename T1, typename T2, typename T3, typename T4, typename T5,
4672 typename T6, typename T7, typename T8, typename T9, typename T10,
4673 typename T11, typename T12, typename T13, typename T14, typename T15,
4674 typename T16, typename T17, typename T18, typename T19, typename T20,
4675 typename T21, typename T22, typename T23, typename T24, typename T25,
4676 typename T26, typename T27, typename T28, typename T29, typename T30,
4677 typename T31, typename T32, typename T33, typename T34, typename T35,
4678 typename T36, typename T37, typename T38, typename T39, typename T40,
4679 typename T41, typename T42>
4680struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4681 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4682 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,
4683 internal::None, internal::None, internal::None, internal::None,
4684 internal::None, internal::None, internal::None> {
4685 typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4686 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4687 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4688 T41, T42> type;
4689};
4690template <typename T1, typename T2, typename T3, typename T4, typename T5,
4691 typename T6, typename T7, typename T8, typename T9, typename T10,
4692 typename T11, typename T12, typename T13, typename T14, typename T15,
4693 typename T16, typename T17, typename T18, typename T19, typename T20,
4694 typename T21, typename T22, typename T23, typename T24, typename T25,
4695 typename T26, typename T27, typename T28, typename T29, typename T30,
4696 typename T31, typename T32, typename T33, typename T34, typename T35,
4697 typename T36, typename T37, typename T38, typename T39, typename T40,
4698 typename T41, typename T42, typename T43>
4699struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4700 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4701 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
4702 internal::None, internal::None, internal::None, internal::None,
4703 internal::None, internal::None, internal::None> {
4704 typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4705 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4706 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4707 T41, T42, T43> type;
4708};
4709template <typename T1, typename T2, typename T3, typename T4, typename T5,
4710 typename T6, typename T7, typename T8, typename T9, typename T10,
4711 typename T11, typename T12, typename T13, typename T14, typename T15,
4712 typename T16, typename T17, typename T18, typename T19, typename T20,
4713 typename T21, typename T22, typename T23, typename T24, typename T25,
4714 typename T26, typename T27, typename T28, typename T29, typename T30,
4715 typename T31, typename T32, typename T33, typename T34, typename T35,
4716 typename T36, typename T37, typename T38, typename T39, typename T40,
4717 typename T41, typename T42, typename T43, typename T44>
4718struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4719 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4720 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
4721 internal::None, internal::None, internal::None, internal::None,
4722 internal::None, internal::None> {
4723 typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4724 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4725 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4726 T41, T42, T43, T44> type;
4727};
4728template <typename T1, typename T2, typename T3, typename T4, typename T5,
4729 typename T6, typename T7, typename T8, typename T9, typename T10,
4730 typename T11, typename T12, typename T13, typename T14, typename T15,
4731 typename T16, typename T17, typename T18, typename T19, typename T20,
4732 typename T21, typename T22, typename T23, typename T24, typename T25,
4733 typename T26, typename T27, typename T28, typename T29, typename T30,
4734 typename T31, typename T32, typename T33, typename T34, typename T35,
4735 typename T36, typename T37, typename T38, typename T39, typename T40,
4736 typename T41, typename T42, typename T43, typename T44, typename T45>
4737struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4738 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4739 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4740 internal::None, internal::None, internal::None, internal::None,
4741 internal::None> {
4742 typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4743 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4744 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4745 T41, T42, T43, T44, T45> type;
4746};
4747template <typename T1, typename T2, typename T3, typename T4, typename T5,
4748 typename T6, typename T7, typename T8, typename T9, typename T10,
4749 typename T11, typename T12, typename T13, typename T14, typename T15,
4750 typename T16, typename T17, typename T18, typename T19, typename T20,
4751 typename T21, typename T22, typename T23, typename T24, typename T25,
4752 typename T26, typename T27, typename T28, typename T29, typename T30,
4753 typename T31, typename T32, typename T33, typename T34, typename T35,
4754 typename T36, typename T37, typename T38, typename T39, typename T40,
4755 typename T41, typename T42, typename T43, typename T44, typename T45,
4756 typename T46>
4757struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4758 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4759 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4760 T46, internal::None, internal::None, internal::None, internal::None> {
4761 typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4762 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4763 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4764 T41, T42, T43, T44, T45, T46> type;
4765};
4766template <typename T1, typename T2, typename T3, typename T4, typename T5,
4767 typename T6, typename T7, typename T8, typename T9, typename T10,
4768 typename T11, typename T12, typename T13, typename T14, typename T15,
4769 typename T16, typename T17, typename T18, typename T19, typename T20,
4770 typename T21, typename T22, typename T23, typename T24, typename T25,
4771 typename T26, typename T27, typename T28, typename T29, typename T30,
4772 typename T31, typename T32, typename T33, typename T34, typename T35,
4773 typename T36, typename T37, typename T38, typename T39, typename T40,
4774 typename T41, typename T42, typename T43, typename T44, typename T45,
4775 typename T46, typename T47>
4776struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4777 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4778 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4779 T46, T47, internal::None, internal::None, internal::None> {
4780 typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4781 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4782 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4783 T41, T42, T43, T44, T45, T46, T47> type;
4784};
4785template <typename T1, typename T2, typename T3, typename T4, typename T5,
4786 typename T6, typename T7, typename T8, typename T9, typename T10,
4787 typename T11, typename T12, typename T13, typename T14, typename T15,
4788 typename T16, typename T17, typename T18, typename T19, typename T20,
4789 typename T21, typename T22, typename T23, typename T24, typename T25,
4790 typename T26, typename T27, typename T28, typename T29, typename T30,
4791 typename T31, typename T32, typename T33, typename T34, typename T35,
4792 typename T36, typename T37, typename T38, typename T39, typename T40,
4793 typename T41, typename T42, typename T43, typename T44, typename T45,
4794 typename T46, typename T47, typename T48>
4795struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4796 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4797 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4798 T46, T47, T48, internal::None, internal::None> {
4799 typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4800 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4801 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4802 T41, T42, T43, T44, T45, T46, T47, T48> type;
4803};
4804template <typename T1, typename T2, typename T3, typename T4, typename T5,
4805 typename T6, typename T7, typename T8, typename T9, typename T10,
4806 typename T11, typename T12, typename T13, typename T14, typename T15,
4807 typename T16, typename T17, typename T18, typename T19, typename T20,
4808 typename T21, typename T22, typename T23, typename T24, typename T25,
4809 typename T26, typename T27, typename T28, typename T29, typename T30,
4810 typename T31, typename T32, typename T33, typename T34, typename T35,
4811 typename T36, typename T37, typename T38, typename T39, typename T40,
4812 typename T41, typename T42, typename T43, typename T44, typename T45,
4813 typename T46, typename T47, typename T48, typename T49>
4814struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4815 T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
4816 T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
4817 T46, T47, T48, T49, internal::None> {
4818 typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4819 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
4820 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
4821 T41, T42, T43, T44, T45, T46, T47, T48, T49> type;
4822};
4823
4824namespace internal {
4825
4826# define GTEST_TEMPLATE_ template <typename T> class
4827
4828// The template "selector" struct TemplateSel<Tmpl> is used to
4829// represent Tmpl, which must be a class template with one type
4830// parameter, as a type. TemplateSel<Tmpl>::Bind<T>::type is defined
4831// as the type Tmpl<T>. This allows us to actually instantiate the
4832// template "selected" by TemplateSel<Tmpl>.
4833//
4834// This trick is necessary for simulating typedef for class templates,
4835// which C++ doesn't support directly.
4836template <GTEST_TEMPLATE_ Tmpl>
4837struct TemplateSel {
4838 template <typename T>
4839 struct Bind {
4840 typedef Tmpl<T> type;
4841 };
4842};
4843
4844# define GTEST_BIND_(TmplSel, T) \
4845 TmplSel::template Bind<T>::type
4846
4847// A unique struct template used as the default value for the
4848// arguments of class template Templates. This allows us to simulate
4849// variadic templates (e.g. Templates<int>, Templates<int, double>,
4850// and etc), which C++ doesn't support directly.
4851template <typename T>
4852struct NoneT {};
4853
4854// The following family of struct and struct templates are used to
4855// represent template lists. In particular, TemplatesN<T1, T2, ...,
4856// TN> represents a list of N templates (T1, T2, ..., and TN). Except
4857// for Templates0, every struct in the family has two member types:
4858// Head for the selector of the first template in the list, and Tail
4859// for the rest of the list.
4860
4861// The empty template list.
4862struct Templates0 {};
4863
4864// Template lists of length 1, 2, 3, and so on.
4865
4866template <GTEST_TEMPLATE_ T1>
4867struct Templates1 {
4868 typedef TemplateSel<T1> Head;
4869 typedef Templates0 Tail;
4870};
4871template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
4872struct Templates2 {
4873 typedef TemplateSel<T1> Head;
4874 typedef Templates1<T2> Tail;
4875};
4876
4877template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
4878struct Templates3 {
4879 typedef TemplateSel<T1> Head;
4880 typedef Templates2<T2, T3> Tail;
4881};
4882
4883template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4884 GTEST_TEMPLATE_ T4>
4885struct Templates4 {
4886 typedef TemplateSel<T1> Head;
4887 typedef Templates3<T2, T3, T4> Tail;
4888};
4889
4890template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4891 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
4892struct Templates5 {
4893 typedef TemplateSel<T1> Head;
4894 typedef Templates4<T2, T3, T4, T5> Tail;
4895};
4896
4897template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4898 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
4899struct Templates6 {
4900 typedef TemplateSel<T1> Head;
4901 typedef Templates5<T2, T3, T4, T5, T6> Tail;
4902};
4903
4904template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4905 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4906 GTEST_TEMPLATE_ T7>
4907struct Templates7 {
4908 typedef TemplateSel<T1> Head;
4909 typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;
4910};
4911
4912template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4913 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4914 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
4915struct Templates8 {
4916 typedef TemplateSel<T1> Head;
4917 typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;
4918};
4919
4920template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4921 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4922 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
4923struct Templates9 {
4924 typedef TemplateSel<T1> Head;
4925 typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
4926};
4927
4928template <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>
4932struct Templates10 {
4933 typedef TemplateSel<T1> Head;
4934 typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
4935};
4936
4937template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4938 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4939 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4940 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
4941struct Templates11 {
4942 typedef TemplateSel<T1> Head;
4943 typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
4944};
4945
4946template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4947 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4948 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4949 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
4950struct Templates12 {
4951 typedef TemplateSel<T1> Head;
4952 typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
4953};
4954
4955template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4956 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4957 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4958 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4959 GTEST_TEMPLATE_ T13>
4960struct Templates13 {
4961 typedef TemplateSel<T1> Head;
4962 typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
4963};
4964
4965template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4966 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4967 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4968 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4969 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
4970struct Templates14 {
4971 typedef TemplateSel<T1> Head;
4972 typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
4973 T14> Tail;
4974};
4975
4976template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4977 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4978 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4979 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4980 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
4981struct Templates15 {
4982 typedef TemplateSel<T1> Head;
4983 typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4984 T15> Tail;
4985};
4986
4987template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
4988 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
4989 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
4990 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
4991 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
4992 GTEST_TEMPLATE_ T16>
4993struct Templates16 {
4994 typedef TemplateSel<T1> Head;
4995 typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4996 T15, T16> Tail;
4997};
4998
4999template <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>
5005struct Templates17 {
5006 typedef TemplateSel<T1> Head;
5007 typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5008 T15, T16, T17> Tail;
5009};
5010
5011template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5012 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5013 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5014 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5015 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5016 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
5017struct Templates18 {
5018 typedef TemplateSel<T1> Head;
5019 typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5020 T15, T16, T17, T18> Tail;
5021};
5022
5023template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5024 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5025 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5026 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5027 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5028 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5029 GTEST_TEMPLATE_ T19>
5030struct Templates19 {
5031 typedef TemplateSel<T1> Head;
5032 typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5033 T15, T16, T17, T18, T19> Tail;
5034};
5035
5036template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5037 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5038 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5039 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5040 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5041 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5042 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
5043struct Templates20 {
5044 typedef TemplateSel<T1> Head;
5045 typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5046 T15, T16, T17, T18, T19, T20> Tail;
5047};
5048
5049template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5050 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5051 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5052 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5053 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5054 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5055 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
5056struct Templates21 {
5057 typedef TemplateSel<T1> Head;
5058 typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5059 T15, T16, T17, T18, T19, T20, T21> Tail;
5060};
5061
5062template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5063 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5064 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5065 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5066 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5067 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5068 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5069 GTEST_TEMPLATE_ T22>
5070struct Templates22 {
5071 typedef TemplateSel<T1> Head;
5072 typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5073 T15, T16, T17, T18, T19, T20, T21, T22> Tail;
5074};
5075
5076template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5077 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5078 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5079 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5080 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5081 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5082 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5083 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
5084struct Templates23 {
5085 typedef TemplateSel<T1> Head;
5086 typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5087 T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;
5088};
5089
5090template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5091 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5092 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5093 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5094 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5095 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5096 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5097 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
5098struct Templates24 {
5099 typedef TemplateSel<T1> Head;
5100 typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5101 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
5102};
5103
5104template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5105 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5106 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5107 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5108 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5109 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5110 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5111 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5112 GTEST_TEMPLATE_ T25>
5113struct Templates25 {
5114 typedef TemplateSel<T1> Head;
5115 typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5116 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
5117};
5118
5119template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5120 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5121 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5122 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5123 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5124 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5125 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5126 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5127 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
5128struct Templates26 {
5129 typedef TemplateSel<T1> Head;
5130 typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5131 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
5132};
5133
5134template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5135 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5136 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5137 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5138 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5139 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5140 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5141 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5142 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
5143struct Templates27 {
5144 typedef TemplateSel<T1> Head;
5145 typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5146 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
5147};
5148
5149template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5150 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5151 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5152 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5153 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5154 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5155 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5156 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5157 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5158 GTEST_TEMPLATE_ T28>
5159struct Templates28 {
5160 typedef TemplateSel<T1> Head;
5161 typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5162 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
5163 T28> Tail;
5164};
5165
5166template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5167 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5168 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5169 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5170 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5171 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5172 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5173 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5174 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5175 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
5176struct Templates29 {
5177 typedef TemplateSel<T1> Head;
5178 typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5179 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5180 T29> Tail;
5181};
5182
5183template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5184 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5185 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5186 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5187 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5188 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5189 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5190 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5191 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5192 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
5193struct Templates30 {
5194 typedef TemplateSel<T1> Head;
5195 typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5196 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5197 T29, T30> Tail;
5198};
5199
5200template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5201 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5202 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5203 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5204 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5205 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5206 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5207 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5208 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5209 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5210 GTEST_TEMPLATE_ T31>
5211struct Templates31 {
5212 typedef TemplateSel<T1> Head;
5213 typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5214 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5215 T29, T30, T31> Tail;
5216};
5217
5218template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5219 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5220 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5221 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5222 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5223 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5224 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5225 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5226 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5227 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5228 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
5229struct Templates32 {
5230 typedef TemplateSel<T1> Head;
5231 typedef Templates31<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> Tail;
5234};
5235
5236template <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>
5247struct Templates33 {
5248 typedef TemplateSel<T1> Head;
5249 typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5250 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5251 T29, T30, T31, T32, T33> Tail;
5252};
5253
5254template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5255 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5256 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5257 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5258 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5259 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5260 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5261 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5262 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5263 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5264 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5265 GTEST_TEMPLATE_ T34>
5266struct Templates34 {
5267 typedef TemplateSel<T1> Head;
5268 typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5269 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5270 T29, T30, T31, T32, T33, T34> Tail;
5271};
5272
5273template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5274 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5275 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5276 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5277 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5278 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5279 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5280 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5281 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5282 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5283 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5284 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
5285struct Templates35 {
5286 typedef TemplateSel<T1> Head;
5287 typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5288 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5289 T29, T30, T31, T32, T33, T34, T35> Tail;
5290};
5291
5292template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5293 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5294 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5295 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5296 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5297 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5298 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5299 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5300 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5301 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5302 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5303 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
5304struct Templates36 {
5305 typedef TemplateSel<T1> Head;
5306 typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5307 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5308 T29, T30, T31, T32, T33, T34, T35, T36> Tail;
5309};
5310
5311template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5312 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5313 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5314 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5315 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5316 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5317 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5318 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5319 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5320 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5321 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5322 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5323 GTEST_TEMPLATE_ T37>
5324struct Templates37 {
5325 typedef TemplateSel<T1> Head;
5326 typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5327 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5328 T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;
5329};
5330
5331template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5332 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5333 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5334 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5335 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5336 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5337 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5338 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5339 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5340 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5341 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5342 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5343 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
5344struct Templates38 {
5345 typedef TemplateSel<T1> Head;
5346 typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5347 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5348 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
5349};
5350
5351template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5352 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5353 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5354 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5355 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5356 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5357 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5358 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5359 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5360 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5361 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5362 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5363 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
5364struct Templates39 {
5365 typedef TemplateSel<T1> Head;
5366 typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5367 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5368 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
5369};
5370
5371template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5372 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5373 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5374 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5375 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5376 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5377 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5378 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5379 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5380 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5381 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5382 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5383 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5384 GTEST_TEMPLATE_ T40>
5385struct Templates40 {
5386 typedef TemplateSel<T1> Head;
5387 typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5388 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5389 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
5390};
5391
5392template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5393 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5394 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5395 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5396 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5397 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5398 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5399 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5400 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5401 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5402 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5403 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5404 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5405 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
5406struct Templates41 {
5407 typedef TemplateSel<T1> Head;
5408 typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5409 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5410 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
5411};
5412
5413template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5414 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5415 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5416 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5417 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5418 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5419 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5420 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5421 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5422 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5423 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5424 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5425 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5426 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
5427struct Templates42 {
5428 typedef TemplateSel<T1> Head;
5429 typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5430 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5431 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
5432 T42> Tail;
5433};
5434
5435template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5436 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5437 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5438 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5439 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5440 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5441 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5442 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5443 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5444 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5445 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5446 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5447 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5448 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5449 GTEST_TEMPLATE_ T43>
5450struct Templates43 {
5451 typedef TemplateSel<T1> Head;
5452 typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5453 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5454 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5455 T43> Tail;
5456};
5457
5458template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5459 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5460 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5461 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5462 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5463 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5464 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5465 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5466 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5467 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5468 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5469 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5470 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5471 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5472 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
5473struct Templates44 {
5474 typedef TemplateSel<T1> Head;
5475 typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5476 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5477 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5478 T43, T44> Tail;
5479};
5480
5481template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5482 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5483 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5484 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5485 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5486 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5487 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5488 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5489 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5490 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5491 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5492 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5493 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5494 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5495 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
5496struct Templates45 {
5497 typedef TemplateSel<T1> Head;
5498 typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5499 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5500 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5501 T43, T44, T45> Tail;
5502};
5503
5504template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5505 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5506 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5507 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5508 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5509 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5510 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5511 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5512 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5513 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5514 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5515 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5516 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5517 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5518 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5519 GTEST_TEMPLATE_ T46>
5520struct Templates46 {
5521 typedef TemplateSel<T1> Head;
5522 typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5523 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5524 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5525 T43, T44, T45, T46> Tail;
5526};
5527
5528template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5529 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5530 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5531 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5532 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5533 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5534 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5535 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5536 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5537 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5538 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5539 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5540 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5541 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5542 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5543 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
5544struct Templates47 {
5545 typedef TemplateSel<T1> Head;
5546 typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5547 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5548 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5549 T43, T44, T45, T46, T47> Tail;
5550};
5551
5552template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5553 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5554 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5555 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5556 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5557 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5558 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5559 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5560 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5561 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5562 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5563 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5564 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5565 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5566 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5567 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
5568struct Templates48 {
5569 typedef TemplateSel<T1> Head;
5570 typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5571 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5572 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5573 T43, T44, T45, T46, T47, T48> Tail;
5574};
5575
5576template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5577 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5578 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5579 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5580 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5581 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5582 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5583 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5584 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5585 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5586 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5587 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5588 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5589 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5590 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5591 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
5592 GTEST_TEMPLATE_ T49>
5593struct Templates49 {
5594 typedef TemplateSel<T1> Head;
5595 typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5596 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5597 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5598 T43, T44, T45, T46, T47, T48, T49> Tail;
5599};
5600
5601template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5602 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5603 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5604 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5605 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5606 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5607 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5608 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5609 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
5610 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
5611 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
5612 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
5613 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
5614 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
5615 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
5616 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
5617 GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>
5618struct Templates50 {
5619 typedef TemplateSel<T1> Head;
5620 typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5621 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
5622 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
5623 T43, T44, T45, T46, T47, T48, T49, T50> Tail;
5624};
5625
5626
5627// We don't want to require the users to write TemplatesN<...> directly,
5628// as that would require them to count the length. Templates<...> is much
5629// easier to write, but generates horrible messages when there is a
5630// compiler error, as gcc insists on printing out each template
5631// argument, even if it has the default value (this means Templates<list>
5632// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
5633// errors).
5634//
5635// Our solution is to combine the best part of the two approaches: a
5636// user would write Templates<T1, ..., TN>, and Google Test will translate
5637// that to TemplatesN<T1, ..., TN> internally to make error messages
5638// readable. The translation is done by the 'type' member of the
5639// Templates template.
5640template <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,
5641 GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,
5642 GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,
5643 GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,
5644 GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,
5645 GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,
5646 GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,
5647 GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,
5648 GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,
5649 GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,
5650 GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,
5651 GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,
5652 GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,
5653 GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,
5654 GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,
5655 GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,
5656 GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,
5657 GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,
5658 GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,
5659 GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,
5660 GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,
5661 GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,
5662 GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,
5663 GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,
5664 GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>
5665struct Templates {
5666 typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5667 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
5668 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
5669 T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
5670};
5671
5672template <>
5673struct Templates<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 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5678 NoneT> {
5679 typedef Templates0 type;
5680};
5681template <GTEST_TEMPLATE_ T1>
5682struct Templates<T1, 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, NoneT,
5686 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5687 NoneT> {
5688 typedef Templates1<T1> type;
5689};
5690template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
5691struct Templates<T1, T2, 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, NoneT,
5695 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5696 NoneT> {
5697 typedef Templates2<T1, T2> type;
5698};
5699template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
5700struct Templates<T1, T2, T3, NoneT, NoneT, 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, NoneT, NoneT> {
5705 typedef Templates3<T1, T2, T3> type;
5706};
5707template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5708 GTEST_TEMPLATE_ T4>
5709struct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5710 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, 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 typedef Templates4<T1, T2, T3, T4> type;
5715};
5716template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5717 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
5718struct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5719 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5720 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5721 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5722 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5723 typedef Templates5<T1, T2, T3, T4, T5> type;
5724};
5725template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5726 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
5727struct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,
5728 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5729 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5730 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5731 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5732 typedef Templates6<T1, T2, T3, T4, T5, T6> type;
5733};
5734template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5735 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5736 GTEST_TEMPLATE_ T7>
5737struct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,
5738 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5739 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5740 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5741 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5742 typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;
5743};
5744template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5745 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5746 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
5747struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,
5748 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5749 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5750 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5751 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5752 typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;
5753};
5754template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5755 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5756 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
5757struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,
5758 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5759 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5760 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5761 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5762 typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
5763};
5764template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5765 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5766 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5767 GTEST_TEMPLATE_ T10>
5768struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,
5769 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5770 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5771 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5772 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5773 typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
5774};
5775template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5776 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5777 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5778 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
5779struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, 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, NoneT, NoneT, NoneT, NoneT,
5783 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5784 typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
5785};
5786template <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>
5790struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,
5791 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5792 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> {
5795 typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;
5796};
5797template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5798 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5799 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5800 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5801 GTEST_TEMPLATE_ T13>
5802struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,
5803 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5804 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5805 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5806 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5807 typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
5808 T13> type;
5809};
5810template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5811 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5812 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5813 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5814 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
5815struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5816 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5817 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5818 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5819 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
5820 typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5821 T14> type;
5822};
5823template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5824 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5825 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5826 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5827 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
5828struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5829 T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5830 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5831 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5832 NoneT, NoneT, NoneT, NoneT, NoneT> {
5833 typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5834 T14, T15> type;
5835};
5836template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5837 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5838 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5839 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5840 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5841 GTEST_TEMPLATE_ T16>
5842struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5843 T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5844 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5845 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5846 NoneT, NoneT, NoneT, NoneT, NoneT> {
5847 typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5848 T14, T15, T16> type;
5849};
5850template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5851 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5852 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5853 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5854 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5855 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
5856struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5857 T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5858 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5859 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5860 NoneT, NoneT, NoneT, NoneT, NoneT> {
5861 typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5862 T14, T15, T16, T17> type;
5863};
5864template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5865 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5866 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5867 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5868 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5869 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
5870struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5871 T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5872 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5873 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5874 NoneT, NoneT, NoneT, NoneT> {
5875 typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5876 T14, T15, T16, T17, T18> type;
5877};
5878template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5879 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5880 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5881 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5882 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5883 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5884 GTEST_TEMPLATE_ T19>
5885struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5886 T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5887 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5888 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5889 NoneT, NoneT, NoneT, NoneT> {
5890 typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5891 T14, T15, T16, T17, T18, T19> type;
5892};
5893template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5894 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5895 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5896 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5897 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5898 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5899 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
5900struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5901 T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5902 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5903 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5904 NoneT, NoneT, NoneT, NoneT> {
5905 typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5906 T14, T15, T16, T17, T18, T19, T20> type;
5907};
5908template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5909 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5910 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5911 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5912 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5913 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5914 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
5915struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5916 T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,
5917 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5918 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5919 NoneT, NoneT, NoneT, NoneT> {
5920 typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5921 T14, T15, T16, T17, T18, T19, T20, T21> type;
5922};
5923template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5924 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5925 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5926 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5927 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5928 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5929 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5930 GTEST_TEMPLATE_ T22>
5931struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5932 T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,
5933 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5934 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5935 NoneT, NoneT, NoneT> {
5936 typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5937 T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
5938};
5939template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5940 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5941 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5942 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5943 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5944 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5945 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5946 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
5947struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5948 T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,
5949 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5950 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5951 NoneT, NoneT, NoneT> {
5952 typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5953 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
5954};
5955template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5956 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5957 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5958 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5959 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5960 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5961 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5962 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
5963struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5964 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,
5965 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5966 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5967 NoneT, NoneT, NoneT> {
5968 typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5969 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
5970};
5971template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5972 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5973 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5974 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5975 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5976 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5977 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5978 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5979 GTEST_TEMPLATE_ T25>
5980struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5981 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,
5982 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5983 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
5984 NoneT, NoneT> {
5985 typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
5986 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
5987};
5988template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
5989 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
5990 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
5991 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
5992 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
5993 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
5994 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
5995 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
5996 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
5997struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
5998 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,
5999 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6000 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6001 NoneT, NoneT> {
6002 typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6003 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;
6004};
6005template <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>
6014struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6015 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,
6016 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6017 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6018 NoneT, NoneT> {
6019 typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6020 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
6021 T27> type;
6022};
6023template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6024 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6025 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6026 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6027 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6028 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6029 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6030 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6031 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6032 GTEST_TEMPLATE_ T28>
6033struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6034 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
6035 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6036 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6037 NoneT, NoneT> {
6038 typedef Templates28<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> type;
6041};
6042template <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>
6052struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6053 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6054 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6055 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6056 NoneT> {
6057 typedef Templates29<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> type;
6060};
6061template <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>
6071struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6072 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6073 T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6074 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6075 typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6076 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6077 T28, T29, T30> type;
6078};
6079template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6080 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6081 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6082 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6083 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6084 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6085 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6086 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6087 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6088 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6089 GTEST_TEMPLATE_ T31>
6090struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6091 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6092 T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6093 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6094 typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6095 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6096 T28, T29, T30, T31> type;
6097};
6098template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6099 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6100 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6101 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6102 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6103 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6104 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6105 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6106 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6107 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6108 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
6109struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6110 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6111 T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6112 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6113 typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6114 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6115 T28, T29, T30, T31, T32> type;
6116};
6117template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6118 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6119 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6120 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6121 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6122 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6123 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6124 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6125 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6126 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6127 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
6128struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6129 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6130 T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6131 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6132 typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6133 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6134 T28, T29, T30, T31, T32, T33> type;
6135};
6136template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6137 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6138 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6139 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6140 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6141 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6142 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6143 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6144 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6145 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6146 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6147 GTEST_TEMPLATE_ T34>
6148struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6149 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6150 T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6151 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6152 typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6153 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6154 T28, T29, T30, T31, T32, T33, T34> type;
6155};
6156template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6157 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6158 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6159 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6160 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6161 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6162 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6163 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6164 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6165 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6166 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6167 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
6168struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6169 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6170 T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
6171 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6172 typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6173 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6174 T28, T29, T30, T31, T32, T33, T34, T35> type;
6175};
6176template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6177 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6178 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6179 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6180 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6181 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6182 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6183 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6184 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6185 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6186 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6187 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
6188struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6189 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6190 T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,
6191 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6192 typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6193 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6194 T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
6195};
6196template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6197 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6198 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6199 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6200 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6201 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6202 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6203 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6204 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6205 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6206 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6207 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6208 GTEST_TEMPLATE_ T37>
6209struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6210 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6211 T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,
6212 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6213 typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6214 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6215 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
6216};
6217template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6218 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6219 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6220 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6221 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6222 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6223 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6224 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6225 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6226 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6227 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6228 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6229 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
6230struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6231 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6232 T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,
6233 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6234 typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6235 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6236 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
6237};
6238template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6239 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6240 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6241 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6242 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6243 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6244 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6245 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6246 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6247 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6248 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6249 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6250 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
6251struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6252 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6253 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,
6254 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6255 typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6256 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6257 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
6258};
6259template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6260 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6261 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6262 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6263 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6264 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6265 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6266 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6267 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6268 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6269 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6270 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6271 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6272 GTEST_TEMPLATE_ T40>
6273struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6274 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6275 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,
6276 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6277 typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6278 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6279 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;
6280};
6281template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6282 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6283 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6284 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6285 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6286 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6287 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6288 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6289 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6290 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6291 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6292 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6293 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6294 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
6295struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6296 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6297 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,
6298 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6299 typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6300 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6301 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
6302 T41> type;
6303};
6304template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6305 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6306 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6307 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6308 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6309 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6310 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6311 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6312 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6313 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6314 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6315 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6316 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6317 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
6318struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6319 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6320 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,
6321 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6322 typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6323 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6324 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6325 T42> type;
6326};
6327template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6328 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6329 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6330 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6331 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6332 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6333 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6334 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6335 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6336 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6337 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6338 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6339 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6340 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6341 GTEST_TEMPLATE_ T43>
6342struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6343 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6344 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
6345 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6346 typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6347 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6348 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6349 T42, T43> type;
6350};
6351template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6352 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6353 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6354 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6355 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6356 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6357 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6358 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6359 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6360 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6361 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6362 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6363 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6364 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6365 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
6366struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6367 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6368 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6369 NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
6370 typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6371 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6372 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6373 T42, T43, T44> type;
6374};
6375template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6376 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6377 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6378 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6379 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6380 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6381 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6382 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6383 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6384 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6385 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6386 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6387 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6388 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6389 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
6390struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6391 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6392 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6393 T45, NoneT, NoneT, NoneT, NoneT, NoneT> {
6394 typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6395 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6396 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6397 T42, T43, T44, T45> type;
6398};
6399template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6400 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6401 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6402 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6403 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6404 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6405 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6406 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6407 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6408 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6409 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6410 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6411 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6412 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6413 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6414 GTEST_TEMPLATE_ T46>
6415struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6416 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6417 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6418 T45, T46, NoneT, NoneT, NoneT, NoneT> {
6419 typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6420 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6421 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6422 T42, T43, T44, T45, T46> type;
6423};
6424template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6425 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6426 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6427 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6428 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6429 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6430 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6431 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6432 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6433 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6434 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6435 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6436 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6437 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6438 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6439 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
6440struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6441 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6442 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6443 T45, T46, T47, NoneT, NoneT, NoneT> {
6444 typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6445 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6446 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6447 T42, T43, T44, T45, T46, T47> type;
6448};
6449template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6450 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6451 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6452 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6453 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6454 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6455 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6456 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6457 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6458 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6459 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6460 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6461 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6462 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6463 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6464 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
6465struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6466 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6467 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6468 T45, T46, T47, T48, NoneT, NoneT> {
6469 typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6470 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6471 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6472 T42, T43, T44, T45, T46, T47, T48> type;
6473};
6474template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
6475 GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
6476 GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
6477 GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
6478 GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
6479 GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
6480 GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
6481 GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
6482 GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
6483 GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
6484 GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
6485 GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
6486 GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
6487 GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
6488 GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
6489 GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
6490 GTEST_TEMPLATE_ T49>
6491struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
6492 T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
6493 T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
6494 T45, T46, T47, T48, T49, NoneT> {
6495 typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6496 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
6497 T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
6498 T42, T43, T44, T45, T46, T47, T48, T49> type;
6499};
6500
6501// The TypeList template makes it possible to use either a single type
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006502// or a Types<...> list in TYPED_TEST_SUITE() and
6503// INSTANTIATE_TYPED_TEST_SUITE_P().
Austin Schuh70cc9552019-01-21 19:46:48 -08006504
6505template <typename T>
6506struct TypeList {
6507 typedef Types1<T> type;
6508};
6509
6510template <typename T1, typename T2, typename T3, typename T4, typename T5,
6511 typename T6, typename T7, typename T8, typename T9, typename T10,
6512 typename T11, typename T12, typename T13, typename T14, typename T15,
6513 typename T16, typename T17, typename T18, typename T19, typename T20,
6514 typename T21, typename T22, typename T23, typename T24, typename T25,
6515 typename T26, typename T27, typename T28, typename T29, typename T30,
6516 typename T31, typename T32, typename T33, typename T34, typename T35,
6517 typename T36, typename T37, typename T38, typename T39, typename T40,
6518 typename T41, typename T42, typename T43, typename T44, typename T45,
6519 typename T46, typename T47, typename T48, typename T49, typename T50>
6520struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
6521 T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
6522 T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
6523 T44, T45, T46, T47, T48, T49, T50> > {
6524 typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
6525 T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
6526 T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
6527 T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;
6528};
6529
6530#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
6531
6532} // namespace internal
6533} // namespace testing
6534
6535#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
6536
6537// Due to C++ preprocessor weirdness, we need double indirection to
6538// concatenate two tokens when one of them is __LINE__. Writing
6539//
6540// foo ## __LINE__
6541//
6542// will result in the token foo__LINE__, instead of foo followed by
6543// the current line number. For more details, see
6544// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
6545#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
6546#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
6547
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006548// Stringifies its argument.
6549#define GTEST_STRINGIFY_(name) #name
6550
Austin Schuh70cc9552019-01-21 19:46:48 -08006551class ProtocolMessage;
6552namespace proto2 { class Message; }
6553
6554namespace testing {
6555
6556// Forward declarations.
6557
6558class AssertionResult; // Result of an assertion.
6559class Message; // Represents a failure message.
6560class Test; // Represents a test.
6561class TestInfo; // Information about a test.
6562class TestPartResult; // Result of a test part.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006563class UnitTest; // A collection of test suites.
Austin Schuh70cc9552019-01-21 19:46:48 -08006564
6565template <typename T>
6566::std::string PrintToString(const T& value);
6567
6568namespace internal {
6569
6570struct TraceInfo; // Information about a trace point.
Austin Schuh70cc9552019-01-21 19:46:48 -08006571class TestInfoImpl; // Opaque implementation of TestInfo
6572class UnitTestImpl; // Opaque implementation of UnitTest
6573
6574// The text used in failure messages to indicate the start of the
6575// stack trace.
6576GTEST_API_ extern const char kStackTraceMarker[];
6577
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006578// An IgnoredValue object can be implicitly constructed from ANY value.
6579class IgnoredValue {
6580 struct Sink {};
6581 public:
6582 // This constructor template allows any value to be implicitly
6583 // converted to IgnoredValue. The object has no data member and
6584 // doesn't try to remember anything about the argument. We
6585 // deliberately omit the 'explicit' keyword in order to allow the
6586 // conversion to be implicit.
6587 // Disable the conversion if T already has a magical conversion operator.
6588 // Otherwise we get ambiguity.
6589 template <typename T,
6590 typename std::enable_if<!std::is_convertible<T, Sink>::value,
6591 int>::type = 0>
6592 IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
6593};
6594
6595// The only type that should be convertible to Secret* is nullptr.
6596// The other null pointer constants are not of a type that is convertible to
6597// Secret*. Only the literal with the right value is.
6598template <typename T>
6599using TypeIsValidNullptrConstant = std::integral_constant<
6600 bool, std::is_same<typename std::decay<T>::type, std::nullptr_t>::value ||
6601 !std::is_convertible<T, Secret*>::value>;
6602
Austin Schuh70cc9552019-01-21 19:46:48 -08006603// Two overloaded helpers for checking at compile time whether an
6604// expression is a null pointer literal (i.e. NULL or any 0-valued
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006605// compile-time integral constant). These helpers have no
6606// implementations, as we only need their signatures.
Austin Schuh70cc9552019-01-21 19:46:48 -08006607//
6608// Given IsNullLiteralHelper(x), the compiler will pick the first
6609// version if x can be implicitly converted to Secret*, and pick the
6610// second version otherwise. Since Secret is a secret and incomplete
6611// type, the only expression a user can write that has type Secret* is
6612// a null pointer literal. Therefore, we know that x is a null
6613// pointer literal if and only if the first version is picked by the
6614// compiler.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006615std::true_type IsNullLiteralHelper(Secret*, std::true_type);
6616std::false_type IsNullLiteralHelper(IgnoredValue, std::false_type);
6617std::false_type IsNullLiteralHelper(IgnoredValue, std::true_type);
Austin Schuh70cc9552019-01-21 19:46:48 -08006618
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006619// A compile-time bool constant that is true if and only if x is a null pointer
6620// literal (i.e. nullptr, NULL or any 0-valued compile-time integral constant).
6621#define GTEST_IS_NULL_LITERAL_(x) \
6622 decltype(::testing::internal::IsNullLiteralHelper( \
6623 x, \
6624 ::testing::internal::TypeIsValidNullptrConstant<decltype(x)>()))::value
Austin Schuh70cc9552019-01-21 19:46:48 -08006625
6626// Appends the user-supplied message to the Google-Test-generated message.
6627GTEST_API_ std::string AppendUserMessage(
6628 const std::string& gtest_msg, const Message& user_msg);
6629
6630#if GTEST_HAS_EXCEPTIONS
6631
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006632GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \
6633/* an exported class was derived from a class that was not exported */)
6634
Austin Schuh70cc9552019-01-21 19:46:48 -08006635// This exception is thrown by (and only by) a failed Google Test
6636// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
6637// are enabled). We derive it from std::runtime_error, which is for
6638// errors presumably detectable only at run time. Since
6639// std::runtime_error inherits from std::exception, many testing
6640// frameworks know how to extract and print the message inside it.
6641class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
6642 public:
6643 explicit GoogleTestFailureException(const TestPartResult& failure);
6644};
6645
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006646GTEST_DISABLE_MSC_WARNINGS_POP_() // 4275
6647
Austin Schuh70cc9552019-01-21 19:46:48 -08006648#endif // GTEST_HAS_EXCEPTIONS
6649
Austin Schuh70cc9552019-01-21 19:46:48 -08006650namespace edit_distance {
6651// Returns the optimal edits to go from 'left' to 'right'.
6652// All edits cost the same, with replace having lower priority than
6653// add/remove.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006654// Simple implementation of the Wagner-Fischer algorithm.
Austin Schuh70cc9552019-01-21 19:46:48 -08006655// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
6656enum EditType { kMatch, kAdd, kRemove, kReplace };
6657GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
6658 const std::vector<size_t>& left, const std::vector<size_t>& right);
6659
6660// Same as above, but the input is represented as strings.
6661GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
6662 const std::vector<std::string>& left,
6663 const std::vector<std::string>& right);
6664
6665// Create a diff of the input strings in Unified diff format.
6666GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
6667 const std::vector<std::string>& right,
6668 size_t context = 2);
6669
6670} // namespace edit_distance
6671
6672// Calculate the diff between 'left' and 'right' and return it in unified diff
6673// format.
6674// If not null, stores in 'total_line_count' the total number of lines found
6675// in left + right.
6676GTEST_API_ std::string DiffStrings(const std::string& left,
6677 const std::string& right,
6678 size_t* total_line_count);
6679
6680// Constructs and returns the message for an equality assertion
6681// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
6682//
6683// The first four parameters are the expressions used in the assertion
6684// and their values, as strings. For example, for ASSERT_EQ(foo, bar)
6685// where foo is 5 and bar is 6, we have:
6686//
6687// expected_expression: "foo"
6688// actual_expression: "bar"
6689// expected_value: "5"
6690// actual_value: "6"
6691//
6692// The ignoring_case parameter is true iff the assertion is a
6693// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
6694// be inserted into the message.
6695GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
6696 const char* actual_expression,
6697 const std::string& expected_value,
6698 const std::string& actual_value,
6699 bool ignoring_case);
6700
6701// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
6702GTEST_API_ std::string GetBoolAssertionFailureMessage(
6703 const AssertionResult& assertion_result,
6704 const char* expression_text,
6705 const char* actual_predicate_value,
6706 const char* expected_predicate_value);
6707
6708// This template class represents an IEEE floating-point number
6709// (either single-precision or double-precision, depending on the
6710// template parameters).
6711//
6712// The purpose of this class is to do more sophisticated number
6713// comparison. (Due to round-off error, etc, it's very unlikely that
6714// two floating-points will be equal exactly. Hence a naive
6715// comparison by the == operation often doesn't work.)
6716//
6717// Format of IEEE floating-point:
6718//
6719// The most-significant bit being the leftmost, an IEEE
6720// floating-point looks like
6721//
6722// sign_bit exponent_bits fraction_bits
6723//
6724// Here, sign_bit is a single bit that designates the sign of the
6725// number.
6726//
6727// For float, there are 8 exponent bits and 23 fraction bits.
6728//
6729// For double, there are 11 exponent bits and 52 fraction bits.
6730//
6731// More details can be found at
6732// http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
6733//
6734// Template parameter:
6735//
6736// RawType: the raw floating-point type (either float or double)
6737template <typename RawType>
6738class FloatingPoint {
6739 public:
6740 // Defines the unsigned integer type that has the same size as the
6741 // floating point number.
6742 typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
6743
6744 // Constants.
6745
6746 // # of bits in a number.
6747 static const size_t kBitCount = 8*sizeof(RawType);
6748
6749 // # of fraction bits in a number.
6750 static const size_t kFractionBitCount =
6751 std::numeric_limits<RawType>::digits - 1;
6752
6753 // # of exponent bits in a number.
6754 static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
6755
6756 // The mask for the sign bit.
6757 static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
6758
6759 // The mask for the fraction bits.
6760 static const Bits kFractionBitMask =
6761 ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
6762
6763 // The mask for the exponent bits.
6764 static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
6765
6766 // How many ULP's (Units in the Last Place) we want to tolerate when
6767 // comparing two numbers. The larger the value, the more error we
6768 // allow. A 0 value means that two numbers must be exactly the same
6769 // to be considered equal.
6770 //
6771 // The maximum error of a single floating-point operation is 0.5
6772 // units in the last place. On Intel CPU's, all floating-point
6773 // calculations are done with 80-bit precision, while double has 64
6774 // bits. Therefore, 4 should be enough for ordinary use.
6775 //
6776 // See the following article for more details on ULP:
6777 // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
6778 static const size_t kMaxUlps = 4;
6779
6780 // Constructs a FloatingPoint from a raw floating-point number.
6781 //
6782 // On an Intel CPU, passing a non-normalized NAN (Not a Number)
6783 // around may change its bits, although the new value is guaranteed
6784 // to be also a NAN. Therefore, don't expect this constructor to
6785 // preserve the bits in x when x is a NAN.
6786 explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
6787
6788 // Static methods
6789
6790 // Reinterprets a bit pattern as a floating-point number.
6791 //
6792 // This function is needed to test the AlmostEquals() method.
6793 static RawType ReinterpretBits(const Bits bits) {
6794 FloatingPoint fp(0);
6795 fp.u_.bits_ = bits;
6796 return fp.u_.value_;
6797 }
6798
6799 // Returns the floating-point number that represent positive infinity.
6800 static RawType Infinity() {
6801 return ReinterpretBits(kExponentBitMask);
6802 }
6803
6804 // Returns the maximum representable finite floating-point number.
6805 static RawType Max();
6806
6807 // Non-static methods
6808
6809 // Returns the bits that represents this number.
6810 const Bits &bits() const { return u_.bits_; }
6811
6812 // Returns the exponent bits of this number.
6813 Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
6814
6815 // Returns the fraction bits of this number.
6816 Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
6817
6818 // Returns the sign bit of this number.
6819 Bits sign_bit() const { return kSignBitMask & u_.bits_; }
6820
6821 // Returns true iff this is NAN (not a number).
6822 bool is_nan() const {
6823 // It's a NAN if the exponent bits are all ones and the fraction
6824 // bits are not entirely zeros.
6825 return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
6826 }
6827
6828 // Returns true iff this number is at most kMaxUlps ULP's away from
6829 // rhs. In particular, this function:
6830 //
6831 // - returns false if either number is (or both are) NAN.
6832 // - treats really large numbers as almost equal to infinity.
6833 // - thinks +0.0 and -0.0 are 0 DLP's apart.
6834 bool AlmostEquals(const FloatingPoint& rhs) const {
6835 // The IEEE standard says that any comparison operation involving
6836 // a NAN must return false.
6837 if (is_nan() || rhs.is_nan()) return false;
6838
6839 return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
6840 <= kMaxUlps;
6841 }
6842
6843 private:
6844 // The data type used to store the actual floating-point number.
6845 union FloatingPointUnion {
6846 RawType value_; // The raw floating-point number.
6847 Bits bits_; // The bits that represent the number.
6848 };
6849
6850 // Converts an integer from the sign-and-magnitude representation to
6851 // the biased representation. More precisely, let N be 2 to the
6852 // power of (kBitCount - 1), an integer x is represented by the
6853 // unsigned number x + N.
6854 //
6855 // For instance,
6856 //
6857 // -N + 1 (the most negative number representable using
6858 // sign-and-magnitude) is represented by 1;
6859 // 0 is represented by N; and
6860 // N - 1 (the biggest number representable using
6861 // sign-and-magnitude) is represented by 2N - 1.
6862 //
6863 // Read http://en.wikipedia.org/wiki/Signed_number_representations
6864 // for more details on signed number representations.
6865 static Bits SignAndMagnitudeToBiased(const Bits &sam) {
6866 if (kSignBitMask & sam) {
6867 // sam represents a negative number.
6868 return ~sam + 1;
6869 } else {
6870 // sam represents a positive number.
6871 return kSignBitMask | sam;
6872 }
6873 }
6874
6875 // Given two numbers in the sign-and-magnitude representation,
6876 // returns the distance between them as an unsigned number.
6877 static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
6878 const Bits &sam2) {
6879 const Bits biased1 = SignAndMagnitudeToBiased(sam1);
6880 const Bits biased2 = SignAndMagnitudeToBiased(sam2);
6881 return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
6882 }
6883
6884 FloatingPointUnion u_;
6885};
6886
6887// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
6888// macro defined by <windows.h>.
6889template <>
6890inline float FloatingPoint<float>::Max() { return FLT_MAX; }
6891template <>
6892inline double FloatingPoint<double>::Max() { return DBL_MAX; }
6893
6894// Typedefs the instances of the FloatingPoint template class that we
6895// care to use.
6896typedef FloatingPoint<float> Float;
6897typedef FloatingPoint<double> Double;
6898
6899// In order to catch the mistake of putting tests that use different
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006900// test fixture classes in the same test suite, we need to assign
Austin Schuh70cc9552019-01-21 19:46:48 -08006901// unique IDs to fixture classes and compare them. The TypeId type is
6902// used to hold such IDs. The user should treat TypeId as an opaque
6903// type: the only operation allowed on TypeId values is to compare
6904// them for equality using the == operator.
6905typedef const void* TypeId;
6906
6907template <typename T>
6908class TypeIdHelper {
6909 public:
6910 // dummy_ must not have a const type. Otherwise an overly eager
6911 // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
6912 // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
6913 static bool dummy_;
6914};
6915
6916template <typename T>
6917bool TypeIdHelper<T>::dummy_ = false;
6918
6919// GetTypeId<T>() returns the ID of type T. Different values will be
6920// returned for different types. Calling the function twice with the
6921// same type argument is guaranteed to return the same ID.
6922template <typename T>
6923TypeId GetTypeId() {
6924 // The compiler is required to allocate a different
6925 // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
6926 // the template. Therefore, the address of dummy_ is guaranteed to
6927 // be unique.
6928 return &(TypeIdHelper<T>::dummy_);
6929}
6930
6931// Returns the type ID of ::testing::Test. Always call this instead
6932// of GetTypeId< ::testing::Test>() to get the type ID of
6933// ::testing::Test, as the latter may give the wrong result due to a
6934// suspected linker bug when compiling Google Test as a Mac OS X
6935// framework.
6936GTEST_API_ TypeId GetTestTypeId();
6937
6938// Defines the abstract factory interface that creates instances
6939// of a Test object.
6940class TestFactoryBase {
6941 public:
6942 virtual ~TestFactoryBase() {}
6943
6944 // Creates a test instance to run. The instance is both created and destroyed
6945 // within TestInfoImpl::Run()
6946 virtual Test* CreateTest() = 0;
6947
6948 protected:
6949 TestFactoryBase() {}
6950
6951 private:
6952 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
6953};
6954
6955// This class provides implementation of TeastFactoryBase interface.
6956// It is used in TEST and TEST_F macros.
6957template <class TestClass>
6958class TestFactoryImpl : public TestFactoryBase {
6959 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006960 Test* CreateTest() override { return new TestClass; }
Austin Schuh70cc9552019-01-21 19:46:48 -08006961};
6962
6963#if GTEST_OS_WINDOWS
6964
6965// Predicate-formatters for implementing the HRESULT checking macros
6966// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
6967// We pass a long instead of HRESULT to avoid causing an
6968// include dependency for the HRESULT type.
6969GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
6970 long hr); // NOLINT
6971GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
6972 long hr); // NOLINT
6973
6974#endif // GTEST_OS_WINDOWS
6975
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006976// Types of SetUpTestSuite() and TearDownTestSuite() functions.
6977using SetUpTestSuiteFunc = void (*)();
6978using TearDownTestSuiteFunc = void (*)();
Austin Schuh70cc9552019-01-21 19:46:48 -08006979
6980struct CodeLocation {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006981 CodeLocation(const std::string& a_file, int a_line)
6982 : file(a_file), line(a_line) {}
Austin Schuh70cc9552019-01-21 19:46:48 -08006983
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006984 std::string file;
Austin Schuh70cc9552019-01-21 19:46:48 -08006985 int line;
6986};
6987
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08006988// Helper to identify which setup function for TestCase / TestSuite to call.
6989// Only one function is allowed, either TestCase or TestSute but not both.
6990
6991// Utility functions to help SuiteApiResolver
6992using SetUpTearDownSuiteFuncType = void (*)();
6993
6994inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(
6995 SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) {
6996 return a == def ? nullptr : a;
6997}
6998
6999template <typename T>
7000// Note that SuiteApiResolver inherits from T because
7001// SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way
7002// SuiteApiResolver can access them.
7003struct SuiteApiResolver : T {
7004 // testing::Test is only forward declared at this point. So we make it a
7005 // dependend class for the compiler to be OK with it.
7006 using Test =
7007 typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;
7008
7009 static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite() {
7010 SetUpTearDownSuiteFuncType test_case_fp =
7011 GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase);
7012 SetUpTearDownSuiteFuncType test_suite_fp =
7013 GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite);
7014
7015 GTEST_CHECK_(!test_case_fp || !test_suite_fp)
7016 << "Test can not provide both SetUpTestSuite and SetUpTestCase, please "
7017 "make sure there is only one present ";
7018
7019 return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
7020 }
7021
7022 static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite() {
7023 SetUpTearDownSuiteFuncType test_case_fp =
7024 GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase);
7025 SetUpTearDownSuiteFuncType test_suite_fp =
7026 GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite);
7027
7028 GTEST_CHECK_(!test_case_fp || !test_suite_fp)
7029 << "Test can not provide both TearDownTestSuite and TearDownTestCase,"
7030 " please make sure there is only one present ";
7031
7032 return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
7033 }
7034};
7035
Austin Schuh70cc9552019-01-21 19:46:48 -08007036// Creates a new TestInfo object and registers it with Google Test;
7037// returns the created object.
7038//
7039// Arguments:
7040//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007041// test_suite_name: name of the test suite
Austin Schuh70cc9552019-01-21 19:46:48 -08007042// name: name of the test
7043// type_param the name of the test's type parameter, or NULL if
7044// this is not a typed or a type-parameterized test.
7045// value_param text representation of the test's value parameter,
7046// or NULL if this is not a type-parameterized test.
7047// code_location: code location where the test is defined
7048// fixture_class_id: ID of the test fixture class
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007049// set_up_tc: pointer to the function that sets up the test suite
7050// tear_down_tc: pointer to the function that tears down the test suite
Austin Schuh70cc9552019-01-21 19:46:48 -08007051// factory: pointer to the factory that creates a test object.
7052// The newly created TestInfo instance will assume
7053// ownership of the factory object.
7054GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007055 const char* test_suite_name, const char* name, const char* type_param,
7056 const char* value_param, CodeLocation code_location,
7057 TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
7058 TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
Austin Schuh70cc9552019-01-21 19:46:48 -08007059
7060// If *pstr starts with the given prefix, modifies *pstr to be right
7061// past the prefix and returns true; otherwise leaves *pstr unchanged
7062// and returns false. None of pstr, *pstr, and prefix can be NULL.
7063GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
7064
7065#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
7066
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007067GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
7068/* class A needs to have dll-interface to be used by clients of class B */)
7069
7070// State of the definition of a type-parameterized test suite.
7071class GTEST_API_ TypedTestSuitePState {
Austin Schuh70cc9552019-01-21 19:46:48 -08007072 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007073 TypedTestSuitePState() : registered_(false) {}
Austin Schuh70cc9552019-01-21 19:46:48 -08007074
7075 // Adds the given test name to defined_test_names_ and return true
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007076 // if the test suite hasn't been registered; otherwise aborts the
Austin Schuh70cc9552019-01-21 19:46:48 -08007077 // program.
7078 bool AddTestName(const char* file, int line, const char* case_name,
7079 const char* test_name) {
7080 if (registered_) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007081 fprintf(stderr,
7082 "%s Test %s must be defined before "
7083 "REGISTER_TYPED_TEST_SUITE_P(%s, ...).\n",
Austin Schuh70cc9552019-01-21 19:46:48 -08007084 FormatFileLocation(file, line).c_str(), test_name, case_name);
7085 fflush(stderr);
7086 posix::Abort();
7087 }
7088 registered_tests_.insert(
7089 ::std::make_pair(test_name, CodeLocation(file, line)));
7090 return true;
7091 }
7092
7093 bool TestExists(const std::string& test_name) const {
7094 return registered_tests_.count(test_name) > 0;
7095 }
7096
7097 const CodeLocation& GetCodeLocation(const std::string& test_name) const {
7098 RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
7099 GTEST_CHECK_(it != registered_tests_.end());
7100 return it->second;
7101 }
7102
7103 // Verifies that registered_tests match the test names in
7104 // defined_test_names_; returns registered_tests if successful, or
7105 // aborts the program otherwise.
7106 const char* VerifyRegisteredTestNames(
7107 const char* file, int line, const char* registered_tests);
7108
7109 private:
7110 typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
7111
7112 bool registered_;
7113 RegisteredTestsMap registered_tests_;
7114};
7115
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007116// Legacy API is deprecated but still available
7117#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
7118using TypedTestCasePState = TypedTestSuitePState;
7119#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
7120
7121GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
7122
Austin Schuh70cc9552019-01-21 19:46:48 -08007123// Skips to the first non-space char after the first comma in 'str';
7124// returns NULL if no comma is found in 'str'.
7125inline const char* SkipComma(const char* str) {
7126 const char* comma = strchr(str, ',');
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007127 if (comma == nullptr) {
7128 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -08007129 }
7130 while (IsSpace(*(++comma))) {}
7131 return comma;
7132}
7133
7134// Returns the prefix of 'str' before the first comma in it; returns
7135// the entire string if it contains no comma.
7136inline std::string GetPrefixUntilComma(const char* str) {
7137 const char* comma = strchr(str, ',');
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007138 return comma == nullptr ? str : std::string(str, comma);
Austin Schuh70cc9552019-01-21 19:46:48 -08007139}
7140
7141// Splits a given string on a given delimiter, populating a given
7142// vector with the fields.
7143void SplitString(const ::std::string& str, char delimiter,
7144 ::std::vector< ::std::string>* dest);
7145
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007146// The default argument to the template below for the case when the user does
7147// not provide a name generator.
7148struct DefaultNameGenerator {
7149 template <typename T>
7150 static std::string GetName(int i) {
7151 return StreamableToString(i);
7152 }
7153};
7154
7155template <typename Provided = DefaultNameGenerator>
7156struct NameGeneratorSelector {
7157 typedef Provided type;
7158};
7159
7160template <typename NameGenerator>
7161void GenerateNamesRecursively(Types0, std::vector<std::string>*, int) {}
7162
7163template <typename NameGenerator, typename Types>
7164void GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) {
7165 result->push_back(NameGenerator::template GetName<typename Types::Head>(i));
7166 GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result,
7167 i + 1);
7168}
7169
7170template <typename NameGenerator, typename Types>
7171std::vector<std::string> GenerateNames() {
7172 std::vector<std::string> result;
7173 GenerateNamesRecursively<NameGenerator>(Types(), &result, 0);
7174 return result;
7175}
7176
Austin Schuh70cc9552019-01-21 19:46:48 -08007177// TypeParameterizedTest<Fixture, TestSel, Types>::Register()
7178// registers a list of type-parameterized tests with Google Test. The
7179// return value is insignificant - we just need to return something
7180// such that we can call this function in a namespace scope.
7181//
7182// Implementation note: The GTEST_TEMPLATE_ macro declares a template
7183// template parameter. It's defined in gtest-type-util.h.
7184template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
7185class TypeParameterizedTest {
7186 public:
7187 // 'index' is the index of the test in the type list 'Types'
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007188 // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
Austin Schuh70cc9552019-01-21 19:46:48 -08007189 // Types). Valid values for 'index' are [0, N - 1] where N is the
7190 // length of Types.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007191 static bool Register(const char* prefix, const CodeLocation& code_location,
7192 const char* case_name, const char* test_names, int index,
7193 const std::vector<std::string>& type_names =
7194 GenerateNames<DefaultNameGenerator, Types>()) {
Austin Schuh70cc9552019-01-21 19:46:48 -08007195 typedef typename Types::Head Type;
7196 typedef Fixture<Type> FixtureClass;
7197 typedef typename GTEST_BIND_(TestSel, Type) TestClass;
7198
7199 // First, registers the first type-parameterized test in the type
7200 // list.
7201 MakeAndRegisterTestInfo(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007202 (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
7203 "/" + type_names[index])
7204 .c_str(),
Austin Schuh70cc9552019-01-21 19:46:48 -08007205 StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
7206 GetTypeName<Type>().c_str(),
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007207 nullptr, // No value parameter.
7208 code_location, GetTypeId<FixtureClass>(),
7209 SuiteApiResolver<TestClass>::GetSetUpCaseOrSuite(),
7210 SuiteApiResolver<TestClass>::GetTearDownCaseOrSuite(),
Austin Schuh70cc9552019-01-21 19:46:48 -08007211 new TestFactoryImpl<TestClass>);
7212
7213 // Next, recurses (at compile time) with the tail of the type list.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007214 return TypeParameterizedTest<Fixture, TestSel,
7215 typename Types::Tail>::Register(prefix,
7216 code_location,
7217 case_name,
7218 test_names,
7219 index + 1,
7220 type_names);
Austin Schuh70cc9552019-01-21 19:46:48 -08007221 }
7222};
7223
7224// The base case for the compile time recursion.
7225template <GTEST_TEMPLATE_ Fixture, class TestSel>
7226class TypeParameterizedTest<Fixture, TestSel, Types0> {
7227 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007228 static bool Register(const char* /*prefix*/, const CodeLocation&,
Austin Schuh70cc9552019-01-21 19:46:48 -08007229 const char* /*case_name*/, const char* /*test_names*/,
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007230 int /*index*/,
7231 const std::vector<std::string>& =
7232 std::vector<std::string>() /*type_names*/) {
Austin Schuh70cc9552019-01-21 19:46:48 -08007233 return true;
7234 }
7235};
7236
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007237// TypeParameterizedTestSuite<Fixture, Tests, Types>::Register()
Austin Schuh70cc9552019-01-21 19:46:48 -08007238// registers *all combinations* of 'Tests' and 'Types' with Google
7239// Test. The return value is insignificant - we just need to return
7240// something such that we can call this function in a namespace scope.
7241template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007242class TypeParameterizedTestSuite {
Austin Schuh70cc9552019-01-21 19:46:48 -08007243 public:
7244 static bool Register(const char* prefix, CodeLocation code_location,
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007245 const TypedTestSuitePState* state, const char* case_name,
7246 const char* test_names,
7247 const std::vector<std::string>& type_names =
7248 GenerateNames<DefaultNameGenerator, Types>()) {
Austin Schuh70cc9552019-01-21 19:46:48 -08007249 std::string test_name = StripTrailingSpaces(
7250 GetPrefixUntilComma(test_names));
7251 if (!state->TestExists(test_name)) {
7252 fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
7253 case_name, test_name.c_str(),
7254 FormatFileLocation(code_location.file.c_str(),
7255 code_location.line).c_str());
7256 fflush(stderr);
7257 posix::Abort();
7258 }
7259 const CodeLocation& test_location = state->GetCodeLocation(test_name);
7260
7261 typedef typename Tests::Head Head;
7262
7263 // First, register the first test in 'Test' for each type in 'Types'.
7264 TypeParameterizedTest<Fixture, Head, Types>::Register(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007265 prefix, test_location, case_name, test_names, 0, type_names);
Austin Schuh70cc9552019-01-21 19:46:48 -08007266
7267 // Next, recurses (at compile time) with the tail of the test list.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007268 return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
7269 Types>::Register(prefix, code_location,
7270 state, case_name,
7271 SkipComma(test_names),
7272 type_names);
Austin Schuh70cc9552019-01-21 19:46:48 -08007273 }
7274};
7275
7276// The base case for the compile time recursion.
7277template <GTEST_TEMPLATE_ Fixture, typename Types>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007278class TypeParameterizedTestSuite<Fixture, Templates0, Types> {
Austin Schuh70cc9552019-01-21 19:46:48 -08007279 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007280 static bool Register(const char* /*prefix*/, const CodeLocation&,
7281 const TypedTestSuitePState* /*state*/,
7282 const char* /*case_name*/, const char* /*test_names*/,
7283 const std::vector<std::string>& =
7284 std::vector<std::string>() /*type_names*/) {
Austin Schuh70cc9552019-01-21 19:46:48 -08007285 return true;
7286 }
7287};
7288
7289#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
7290
7291// Returns the current OS stack trace as an std::string.
7292//
7293// The maximum number of stack frames to be included is specified by
7294// the gtest_stack_trace_depth flag. The skip_count parameter
7295// specifies the number of top frames to be skipped, which doesn't
7296// count against the number of frames to be included.
7297//
7298// For example, if Foo() calls Bar(), which in turn calls
7299// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
7300// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
7301GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
7302 UnitTest* unit_test, int skip_count);
7303
7304// Helpers for suppressing warnings on unreachable code or constant
7305// condition.
7306
7307// Always returns true.
7308GTEST_API_ bool AlwaysTrue();
7309
7310// Always returns false.
7311inline bool AlwaysFalse() { return !AlwaysTrue(); }
7312
7313// Helper for suppressing false warning from Clang on a const char*
7314// variable declared in a conditional expression always being NULL in
7315// the else branch.
7316struct GTEST_API_ ConstCharPtr {
7317 ConstCharPtr(const char* str) : value(str) {}
7318 operator bool() const { return true; }
7319 const char* value;
7320};
7321
7322// A simple Linear Congruential Generator for generating random
7323// numbers with a uniform distribution. Unlike rand() and srand(), it
7324// doesn't use global state (and therefore can't interfere with user
7325// code). Unlike rand_r(), it's portable. An LCG isn't very random,
7326// but it's good enough for our purposes.
7327class GTEST_API_ Random {
7328 public:
7329 static const UInt32 kMaxRange = 1u << 31;
7330
7331 explicit Random(UInt32 seed) : state_(seed) {}
7332
7333 void Reseed(UInt32 seed) { state_ = seed; }
7334
7335 // Generates a random number from [0, range). Crashes if 'range' is
7336 // 0 or greater than kMaxRange.
7337 UInt32 Generate(UInt32 range);
7338
7339 private:
7340 UInt32 state_;
7341 GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
7342};
7343
7344// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
7345// compiler error iff T1 and T2 are different types.
7346template <typename T1, typename T2>
7347struct CompileAssertTypesEqual;
7348
7349template <typename T>
7350struct CompileAssertTypesEqual<T, T> {
7351};
7352
7353// Removes the reference from a type if it is a reference type,
7354// otherwise leaves it unchanged. This is the same as
7355// tr1::remove_reference, which is not widely available yet.
7356template <typename T>
7357struct RemoveReference { typedef T type; }; // NOLINT
7358template <typename T>
7359struct RemoveReference<T&> { typedef T type; }; // NOLINT
7360
7361// A handy wrapper around RemoveReference that works when the argument
7362// T depends on template parameters.
7363#define GTEST_REMOVE_REFERENCE_(T) \
7364 typename ::testing::internal::RemoveReference<T>::type
7365
7366// Removes const from a type if it is a const type, otherwise leaves
7367// it unchanged. This is the same as tr1::remove_const, which is not
7368// widely available yet.
7369template <typename T>
7370struct RemoveConst { typedef T type; }; // NOLINT
7371template <typename T>
7372struct RemoveConst<const T> { typedef T type; }; // NOLINT
7373
7374// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
7375// definition to fail to remove the const in 'const int[3]' and 'const
7376// char[3][4]'. The following specialization works around the bug.
7377template <typename T, size_t N>
7378struct RemoveConst<const T[N]> {
7379 typedef typename RemoveConst<T>::type type[N];
7380};
7381
Austin Schuh70cc9552019-01-21 19:46:48 -08007382// A handy wrapper around RemoveConst that works when the argument
7383// T depends on template parameters.
7384#define GTEST_REMOVE_CONST_(T) \
7385 typename ::testing::internal::RemoveConst<T>::type
7386
7387// Turns const U&, U&, const U, and U all into U.
7388#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
7389 GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
7390
Austin Schuh70cc9552019-01-21 19:46:48 -08007391// IsAProtocolMessage<T>::value is a compile-time bool constant that's
7392// true iff T is type ProtocolMessage, proto2::Message, or a subclass
7393// of those.
7394template <typename T>
7395struct IsAProtocolMessage
7396 : public bool_constant<
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007397 std::is_convertible<const T*, const ::ProtocolMessage*>::value ||
7398 std::is_convertible<const T*, const ::proto2::Message*>::value> {
Austin Schuh70cc9552019-01-21 19:46:48 -08007399};
7400
7401// When the compiler sees expression IsContainerTest<C>(0), if C is an
7402// STL-style container class, the first overload of IsContainerTest
7403// will be viable (since both C::iterator* and C::const_iterator* are
7404// valid types and NULL can be implicitly converted to them). It will
7405// be picked over the second overload as 'int' is a perfect match for
7406// the type of argument 0. If C::iterator or C::const_iterator is not
7407// a valid type, the first overload is not viable, and the second
7408// overload will be picked. Therefore, we can determine whether C is
7409// a container class by checking the type of IsContainerTest<C>(0).
7410// The value of the expression is insignificant.
7411//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007412// In C++11 mode we check the existence of a const_iterator and that an
7413// iterator is properly implemented for the container.
7414//
7415// For pre-C++11 that we look for both C::iterator and C::const_iterator.
7416// The reason is that C++ injects the name of a class as a member of the
Austin Schuh70cc9552019-01-21 19:46:48 -08007417// class itself (e.g. you can refer to class iterator as either
7418// 'iterator' or 'iterator::iterator'). If we look for C::iterator
7419// only, for example, we would mistakenly think that a class named
7420// iterator is an STL container.
7421//
7422// Also note that the simpler approach of overloading
7423// IsContainerTest(typename C::const_iterator*) and
7424// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
7425typedef int IsContainer;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007426template <class C,
7427 class Iterator = decltype(::std::declval<const C&>().begin()),
7428 class = decltype(::std::declval<const C&>().end()),
7429 class = decltype(++::std::declval<Iterator&>()),
7430 class = decltype(*::std::declval<Iterator>()),
7431 class = typename C::const_iterator>
7432IsContainer IsContainerTest(int /* dummy */) {
Austin Schuh70cc9552019-01-21 19:46:48 -08007433 return 0;
7434}
7435
7436typedef char IsNotContainer;
7437template <class C>
7438IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
7439
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007440// Trait to detect whether a type T is a hash table.
7441// The heuristic used is that the type contains an inner type `hasher` and does
7442// not contain an inner type `reverse_iterator`.
7443// If the container is iterable in reverse, then order might actually matter.
7444template <typename T>
7445struct IsHashTable {
7446 private:
7447 template <typename U>
7448 static char test(typename U::hasher*, typename U::reverse_iterator*);
7449 template <typename U>
7450 static int test(typename U::hasher*, ...);
7451 template <typename U>
7452 static char test(...);
7453
7454 public:
7455 static const bool value = sizeof(test<T>(nullptr, nullptr)) == sizeof(int);
7456};
7457
7458template <typename T>
7459const bool IsHashTable<T>::value;
7460
7461template <typename C,
7462 bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)>
7463struct IsRecursiveContainerImpl;
7464
7465template <typename C>
7466struct IsRecursiveContainerImpl<C, false> : public false_type {};
7467
7468// Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to
7469// obey the same inconsistencies as the IsContainerTest, namely check if
7470// something is a container is relying on only const_iterator in C++11 and
7471// is relying on both const_iterator and iterator otherwise
7472template <typename C>
7473struct IsRecursiveContainerImpl<C, true> {
7474 using value_type = decltype(*std::declval<typename C::const_iterator>());
7475 using type =
7476 is_same<typename std::remove_const<
7477 typename std::remove_reference<value_type>::type>::type,
7478 C>;
7479};
7480
7481// IsRecursiveContainer<Type> is a unary compile-time predicate that
7482// evaluates whether C is a recursive container type. A recursive container
7483// type is a container type whose value_type is equal to the container type
7484// itself. An example for a recursive container type is
7485// boost::filesystem::path, whose iterator has a value_type that is equal to
7486// boost::filesystem::path.
7487template <typename C>
7488struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
7489
Austin Schuh70cc9552019-01-21 19:46:48 -08007490// EnableIf<condition>::type is void when 'Cond' is true, and
7491// undefined when 'Cond' is false. To use SFINAE to make a function
7492// overload only apply when a particular expression is true, add
7493// "typename EnableIf<expression>::type* = 0" as the last parameter.
7494template<bool> struct EnableIf;
7495template<> struct EnableIf<true> { typedef void type; }; // NOLINT
7496
7497// Utilities for native arrays.
7498
7499// ArrayEq() compares two k-dimensional native arrays using the
7500// elements' operator==, where k can be any integer >= 0. When k is
7501// 0, ArrayEq() degenerates into comparing a single pair of values.
7502
7503template <typename T, typename U>
7504bool ArrayEq(const T* lhs, size_t size, const U* rhs);
7505
7506// This generic version is used when k is 0.
7507template <typename T, typename U>
7508inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
7509
7510// This overload is used when k >= 1.
7511template <typename T, typename U, size_t N>
7512inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
7513 return internal::ArrayEq(lhs, N, rhs);
7514}
7515
7516// This helper reduces code bloat. If we instead put its logic inside
7517// the previous ArrayEq() function, arrays with different sizes would
7518// lead to different copies of the template code.
7519template <typename T, typename U>
7520bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
7521 for (size_t i = 0; i != size; i++) {
7522 if (!internal::ArrayEq(lhs[i], rhs[i]))
7523 return false;
7524 }
7525 return true;
7526}
7527
7528// Finds the first element in the iterator range [begin, end) that
7529// equals elem. Element may be a native array type itself.
7530template <typename Iter, typename Element>
7531Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
7532 for (Iter it = begin; it != end; ++it) {
7533 if (internal::ArrayEq(*it, elem))
7534 return it;
7535 }
7536 return end;
7537}
7538
7539// CopyArray() copies a k-dimensional native array using the elements'
7540// operator=, where k can be any integer >= 0. When k is 0,
7541// CopyArray() degenerates into copying a single value.
7542
7543template <typename T, typename U>
7544void CopyArray(const T* from, size_t size, U* to);
7545
7546// This generic version is used when k is 0.
7547template <typename T, typename U>
7548inline void CopyArray(const T& from, U* to) { *to = from; }
7549
7550// This overload is used when k >= 1.
7551template <typename T, typename U, size_t N>
7552inline void CopyArray(const T(&from)[N], U(*to)[N]) {
7553 internal::CopyArray(from, N, *to);
7554}
7555
7556// This helper reduces code bloat. If we instead put its logic inside
7557// the previous CopyArray() function, arrays with different sizes
7558// would lead to different copies of the template code.
7559template <typename T, typename U>
7560void CopyArray(const T* from, size_t size, U* to) {
7561 for (size_t i = 0; i != size; i++) {
7562 internal::CopyArray(from[i], to + i);
7563 }
7564}
7565
7566// The relation between an NativeArray object (see below) and the
7567// native array it represents.
7568// We use 2 different structs to allow non-copyable types to be used, as long
7569// as RelationToSourceReference() is passed.
7570struct RelationToSourceReference {};
7571struct RelationToSourceCopy {};
7572
7573// Adapts a native array to a read-only STL-style container. Instead
7574// of the complete STL container concept, this adaptor only implements
7575// members useful for Google Mock's container matchers. New members
7576// should be added as needed. To simplify the implementation, we only
7577// support Element being a raw type (i.e. having no top-level const or
7578// reference modifier). It's the client's responsibility to satisfy
7579// this requirement. Element can be an array type itself (hence
7580// multi-dimensional arrays are supported).
7581template <typename Element>
7582class NativeArray {
7583 public:
7584 // STL-style container typedefs.
7585 typedef Element value_type;
7586 typedef Element* iterator;
7587 typedef const Element* const_iterator;
7588
7589 // Constructs from a native array. References the source.
7590 NativeArray(const Element* array, size_t count, RelationToSourceReference) {
7591 InitRef(array, count);
7592 }
7593
7594 // Constructs from a native array. Copies the source.
7595 NativeArray(const Element* array, size_t count, RelationToSourceCopy) {
7596 InitCopy(array, count);
7597 }
7598
7599 // Copy constructor.
7600 NativeArray(const NativeArray& rhs) {
7601 (this->*rhs.clone_)(rhs.array_, rhs.size_);
7602 }
7603
7604 ~NativeArray() {
7605 if (clone_ != &NativeArray::InitRef)
7606 delete[] array_;
7607 }
7608
7609 // STL-style container methods.
7610 size_t size() const { return size_; }
7611 const_iterator begin() const { return array_; }
7612 const_iterator end() const { return array_ + size_; }
7613 bool operator==(const NativeArray& rhs) const {
7614 return size() == rhs.size() &&
7615 ArrayEq(begin(), size(), rhs.begin());
7616 }
7617
7618 private:
7619 enum {
7620 kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007621 Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value
Austin Schuh70cc9552019-01-21 19:46:48 -08007622 };
7623
7624 // Initializes this object with a copy of the input.
7625 void InitCopy(const Element* array, size_t a_size) {
7626 Element* const copy = new Element[a_size];
7627 CopyArray(array, a_size, copy);
7628 array_ = copy;
7629 size_ = a_size;
7630 clone_ = &NativeArray::InitCopy;
7631 }
7632
7633 // Initializes this object with a reference of the input.
7634 void InitRef(const Element* array, size_t a_size) {
7635 array_ = array;
7636 size_ = a_size;
7637 clone_ = &NativeArray::InitRef;
7638 }
7639
7640 const Element* array_;
7641 size_t size_;
7642 void (NativeArray::*clone_)(const Element*, size_t);
7643
7644 GTEST_DISALLOW_ASSIGN_(NativeArray);
7645};
7646
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007647// Backport of std::index_sequence.
7648template <size_t... Is>
7649struct IndexSequence {
7650 using type = IndexSequence;
7651};
7652
7653// Double the IndexSequence, and one if plus_one is true.
7654template <bool plus_one, typename T, size_t sizeofT>
7655struct DoubleSequence;
7656template <size_t... I, size_t sizeofT>
7657struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
7658 using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
7659};
7660template <size_t... I, size_t sizeofT>
7661struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
7662 using type = IndexSequence<I..., (sizeofT + I)...>;
7663};
7664
7665// Backport of std::make_index_sequence.
7666// It uses O(ln(N)) instantiation depth.
7667template <size_t N>
7668struct MakeIndexSequence
7669 : DoubleSequence<N % 2 == 1, typename MakeIndexSequence<N / 2>::type,
7670 N / 2>::type {};
7671
7672template <>
7673struct MakeIndexSequence<0> : IndexSequence<> {};
7674
7675// FIXME: This implementation of ElemFromList is O(1) in instantiation depth,
7676// but it is O(N^2) in total instantiations. Not sure if this is the best
7677// tradeoff, as it will make it somewhat slow to compile.
7678template <typename T, size_t, size_t>
7679struct ElemFromListImpl {};
7680
7681template <typename T, size_t I>
7682struct ElemFromListImpl<T, I, I> {
7683 using type = T;
7684};
7685
7686// Get the Nth element from T...
7687// It uses O(1) instantiation depth.
7688template <size_t N, typename I, typename... T>
7689struct ElemFromList;
7690
7691template <size_t N, size_t... I, typename... T>
7692struct ElemFromList<N, IndexSequence<I...>, T...>
7693 : ElemFromListImpl<T, N, I>... {};
7694
7695template <typename... T>
7696class FlatTuple;
7697
7698template <typename Derived, size_t I>
7699struct FlatTupleElemBase;
7700
7701template <typename... T, size_t I>
7702struct FlatTupleElemBase<FlatTuple<T...>, I> {
7703 using value_type =
7704 typename ElemFromList<I, typename MakeIndexSequence<sizeof...(T)>::type,
7705 T...>::type;
7706 FlatTupleElemBase() = default;
7707 explicit FlatTupleElemBase(value_type t) : value(std::move(t)) {}
7708 value_type value;
7709};
7710
7711template <typename Derived, typename Idx>
7712struct FlatTupleBase;
7713
7714template <size_t... Idx, typename... T>
7715struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
7716 : FlatTupleElemBase<FlatTuple<T...>, Idx>... {
7717 using Indices = IndexSequence<Idx...>;
7718 FlatTupleBase() = default;
7719 explicit FlatTupleBase(T... t)
7720 : FlatTupleElemBase<FlatTuple<T...>, Idx>(std::move(t))... {}
7721};
7722
7723// Analog to std::tuple but with different tradeoffs.
7724// This class minimizes the template instantiation depth, thus allowing more
7725// elements that std::tuple would. std::tuple has been seen to require an
7726// instantiation depth of more than 10x the number of elements in some
7727// implementations.
7728// FlatTuple and ElemFromList are not recursive and have a fixed depth
7729// regardless of T...
7730// MakeIndexSequence, on the other hand, it is recursive but with an
7731// instantiation depth of O(ln(N)).
7732template <typename... T>
7733class FlatTuple
7734 : private FlatTupleBase<FlatTuple<T...>,
7735 typename MakeIndexSequence<sizeof...(T)>::type> {
7736 using Indices = typename FlatTuple::FlatTupleBase::Indices;
7737
7738 public:
7739 FlatTuple() = default;
7740 explicit FlatTuple(T... t) : FlatTuple::FlatTupleBase(std::move(t)...) {}
7741
7742 template <size_t I>
7743 const typename ElemFromList<I, Indices, T...>::type& Get() const {
7744 return static_cast<const FlatTupleElemBase<FlatTuple, I>*>(this)->value;
7745 }
7746
7747 template <size_t I>
7748 typename ElemFromList<I, Indices, T...>::type& Get() {
7749 return static_cast<FlatTupleElemBase<FlatTuple, I>*>(this)->value;
7750 }
7751};
7752
7753// Utility functions to be called with static_assert to induce deprecation
7754// warnings.
7755GTEST_INTERNAL_DEPRECATED(
7756 "INSTANTIATE_TEST_CASE_P is deprecated, please use "
7757 "INSTANTIATE_TEST_SUITE_P")
7758constexpr bool InstantiateTestCase_P_IsDeprecated() { return true; }
7759
7760GTEST_INTERNAL_DEPRECATED(
7761 "TYPED_TEST_CASE_P is deprecated, please use "
7762 "TYPED_TEST_SUITE_P")
7763constexpr bool TypedTestCase_P_IsDeprecated() { return true; }
7764
7765GTEST_INTERNAL_DEPRECATED(
7766 "TYPED_TEST_CASE is deprecated, please use "
7767 "TYPED_TEST_SUITE")
7768constexpr bool TypedTestCaseIsDeprecated() { return true; }
7769
7770GTEST_INTERNAL_DEPRECATED(
7771 "REGISTER_TYPED_TEST_CASE_P is deprecated, please use "
7772 "REGISTER_TYPED_TEST_SUITE_P")
7773constexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; }
7774
7775GTEST_INTERNAL_DEPRECATED(
7776 "INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use "
7777 "INSTANTIATE_TYPED_TEST_SUITE_P")
7778constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
7779
Austin Schuh70cc9552019-01-21 19:46:48 -08007780} // namespace internal
7781} // namespace testing
7782
7783#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
7784 ::testing::internal::AssertHelper(result_type, file, line, message) \
7785 = ::testing::Message()
7786
7787#define GTEST_MESSAGE_(message, result_type) \
7788 GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
7789
7790#define GTEST_FATAL_FAILURE_(message) \
7791 return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
7792
7793#define GTEST_NONFATAL_FAILURE_(message) \
7794 GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
7795
7796#define GTEST_SUCCESS_(message) \
7797 GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
7798
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007799#define GTEST_SKIP_(message) \
7800 return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
7801
7802// Suppress MSVC warning 4072 (unreachable code) for the code following
Austin Schuh70cc9552019-01-21 19:46:48 -08007803// statement if it returns or throws (or doesn't return or throw in some
7804// situations).
7805#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
7806 if (::testing::internal::AlwaysTrue()) { statement; }
7807
7808#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
7809 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7810 if (::testing::internal::ConstCharPtr gtest_msg = "") { \
7811 bool gtest_caught_expected = false; \
7812 try { \
7813 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7814 } \
7815 catch (expected_exception const&) { \
7816 gtest_caught_expected = true; \
7817 } \
7818 catch (...) { \
7819 gtest_msg.value = \
7820 "Expected: " #statement " throws an exception of type " \
7821 #expected_exception ".\n Actual: it throws a different type."; \
7822 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
7823 } \
7824 if (!gtest_caught_expected) { \
7825 gtest_msg.value = \
7826 "Expected: " #statement " throws an exception of type " \
7827 #expected_exception ".\n Actual: it throws nothing."; \
7828 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
7829 } \
7830 } else \
7831 GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
7832 fail(gtest_msg.value)
7833
7834#define GTEST_TEST_NO_THROW_(statement, fail) \
7835 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7836 if (::testing::internal::AlwaysTrue()) { \
7837 try { \
7838 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7839 } \
7840 catch (...) { \
7841 goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
7842 } \
7843 } else \
7844 GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
7845 fail("Expected: " #statement " doesn't throw an exception.\n" \
7846 " Actual: it throws.")
7847
7848#define GTEST_TEST_ANY_THROW_(statement, fail) \
7849 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7850 if (::testing::internal::AlwaysTrue()) { \
7851 bool gtest_caught_any = false; \
7852 try { \
7853 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7854 } \
7855 catch (...) { \
7856 gtest_caught_any = true; \
7857 } \
7858 if (!gtest_caught_any) { \
7859 goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
7860 } \
7861 } else \
7862 GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
7863 fail("Expected: " #statement " throws an exception.\n" \
7864 " Actual: it doesn't.")
7865
7866
7867// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
7868// either a boolean expression or an AssertionResult. text is a textual
7869// represenation of expression as it was passed into the EXPECT_TRUE.
7870#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
7871 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7872 if (const ::testing::AssertionResult gtest_ar_ = \
7873 ::testing::AssertionResult(expression)) \
7874 ; \
7875 else \
7876 fail(::testing::internal::GetBoolAssertionFailureMessage(\
7877 gtest_ar_, text, #actual, #expected).c_str())
7878
7879#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
7880 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
7881 if (::testing::internal::AlwaysTrue()) { \
7882 ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
7883 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
7884 if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
7885 goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
7886 } \
7887 } else \
7888 GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
7889 fail("Expected: " #statement " doesn't generate new fatal " \
7890 "failures in the current thread.\n" \
7891 " Actual: it does.")
7892
7893// Expands to the name of the class that implements the given test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007894#define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
7895 test_suite_name##_##test_name##_Test
Austin Schuh70cc9552019-01-21 19:46:48 -08007896
7897// Helper macro for defining tests.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007898#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
7899 class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
7900 : public parent_class { \
7901 public: \
7902 GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
7903 \
7904 private: \
7905 virtual void TestBody(); \
7906 static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
7907 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
7908 test_name)); \
7909 }; \
7910 \
7911 ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
7912 test_name)::test_info_ = \
7913 ::testing::internal::MakeAndRegisterTestInfo( \
7914 #test_suite_name, #test_name, nullptr, nullptr, \
7915 ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
7916 ::testing::internal::SuiteApiResolver< \
7917 parent_class>::GetSetUpCaseOrSuite(), \
7918 ::testing::internal::SuiteApiResolver< \
7919 parent_class>::GetTearDownCaseOrSuite(), \
7920 new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
7921 test_suite_name, test_name)>); \
7922 void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
Austin Schuh70cc9552019-01-21 19:46:48 -08007923
7924#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
Austin Schuh70cc9552019-01-21 19:46:48 -08007925// Copyright 2005, Google Inc.
7926// All rights reserved.
7927//
7928// Redistribution and use in source and binary forms, with or without
7929// modification, are permitted provided that the following conditions are
7930// met:
7931//
7932// * Redistributions of source code must retain the above copyright
7933// notice, this list of conditions and the following disclaimer.
7934// * Redistributions in binary form must reproduce the above
7935// copyright notice, this list of conditions and the following disclaimer
7936// in the documentation and/or other materials provided with the
7937// distribution.
7938// * Neither the name of Google Inc. nor the names of its
7939// contributors may be used to endorse or promote products derived from
7940// this software without specific prior written permission.
7941//
7942// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7943// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7944// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7945// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7946// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7947// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7948// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7949// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7950// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7951// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7952// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007953
Austin Schuh70cc9552019-01-21 19:46:48 -08007954//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007955// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -08007956//
7957// This header file defines the public API for death tests. It is
7958// #included by gtest.h so a user doesn't need to include this
7959// directly.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007960// GOOGLETEST_CM0001 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -08007961
7962#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
7963#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
7964
7965// Copyright 2005, Google Inc.
7966// All rights reserved.
7967//
7968// Redistribution and use in source and binary forms, with or without
7969// modification, are permitted provided that the following conditions are
7970// met:
7971//
7972// * Redistributions of source code must retain the above copyright
7973// notice, this list of conditions and the following disclaimer.
7974// * Redistributions in binary form must reproduce the above
7975// copyright notice, this list of conditions and the following disclaimer
7976// in the documentation and/or other materials provided with the
7977// distribution.
7978// * Neither the name of Google Inc. nor the names of its
7979// contributors may be used to endorse or promote products derived from
7980// this software without specific prior written permission.
7981//
7982// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7983// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7984// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7985// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7986// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7987// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7988// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7989// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
7990// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7991// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7992// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7993//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007994// The Google C++ Testing and Mocking Framework (Google Test)
Austin Schuh70cc9552019-01-21 19:46:48 -08007995//
7996// This header file defines internal utilities needed for implementing
7997// death tests. They are subject to change without notice.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08007998// GOOGLETEST_CM0001 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -08007999
8000#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
8001#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
8002
Austin Schuh70cc9552019-01-21 19:46:48 -08008003// Copyright 2007, Google Inc.
8004// All rights reserved.
8005//
8006// Redistribution and use in source and binary forms, with or without
8007// modification, are permitted provided that the following conditions are
8008// met:
8009//
8010// * Redistributions of source code must retain the above copyright
8011// notice, this list of conditions and the following disclaimer.
8012// * Redistributions in binary form must reproduce the above
8013// copyright notice, this list of conditions and the following disclaimer
8014// in the documentation and/or other materials provided with the
8015// distribution.
8016// * Neither the name of Google Inc. nor the names of its
8017// contributors may be used to endorse or promote products derived from
8018// this software without specific prior written permission.
8019//
8020// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
8021// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8022// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8023// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8024// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8025// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8026// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
8027// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
8028// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8029// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
8030// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh70cc9552019-01-21 19:46:48 -08008031
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008032// The Google C++ Testing and Mocking Framework (Google Test)
8033//
8034// This file implements just enough of the matcher interface to allow
8035// EXPECT_DEATH and friends to accept a matcher argument.
8036
8037// IWYU pragma: private, include "testing/base/public/gunit.h"
8038// IWYU pragma: friend third_party/googletest/googlemock/.*
8039// IWYU pragma: friend third_party/googletest/googletest/.*
8040
8041#ifndef GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
8042#define GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
8043
8044#include <memory>
8045#include <ostream>
8046#include <string>
8047
8048// Copyright 2007, Google Inc.
8049// All rights reserved.
8050//
8051// Redistribution and use in source and binary forms, with or without
8052// modification, are permitted provided that the following conditions are
8053// met:
8054//
8055// * Redistributions of source code must retain the above copyright
8056// notice, this list of conditions and the following disclaimer.
8057// * Redistributions in binary form must reproduce the above
8058// copyright notice, this list of conditions and the following disclaimer
8059// in the documentation and/or other materials provided with the
8060// distribution.
8061// * Neither the name of Google Inc. nor the names of its
8062// contributors may be used to endorse or promote products derived from
8063// this software without specific prior written permission.
8064//
8065// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
8066// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8067// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8068// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8069// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8070// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
8071// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
8072// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
8073// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8074// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
8075// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8076
8077
8078// Google Test - The Google C++ Testing and Mocking Framework
Austin Schuh70cc9552019-01-21 19:46:48 -08008079//
8080// This file implements a universal value printer that can print a
8081// value of any type T:
8082//
8083// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
8084//
8085// A user can teach this function how to print a class type T by
8086// defining either operator<<() or PrintTo() in the namespace that
8087// defines T. More specifically, the FIRST defined function in the
8088// following list will be used (assuming T is defined in namespace
8089// foo):
8090//
8091// 1. foo::PrintTo(const T&, ostream*)
8092// 2. operator<<(ostream&, const T&) defined in either foo or the
8093// global namespace.
8094//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008095// However if T is an STL-style container then it is printed element-wise
8096// unless foo::PrintTo(const T&, ostream*) is defined. Note that
8097// operator<<() is ignored for container types.
8098//
Austin Schuh70cc9552019-01-21 19:46:48 -08008099// If none of the above is defined, it will print the debug string of
8100// the value if it is a protocol buffer, or print the raw bytes in the
8101// value otherwise.
8102//
8103// To aid debugging: when T is a reference type, the address of the
8104// value is also printed; when T is a (const) char pointer, both the
8105// pointer value and the NUL-terminated string it points to are
8106// printed.
8107//
8108// We also provide some convenient wrappers:
8109//
8110// // Prints a value to a string. For a (const or not) char
8111// // pointer, the NUL-terminated string (but not the pointer) is
8112// // printed.
8113// std::string ::testing::PrintToString(const T& value);
8114//
8115// // Prints a value tersely: for a reference type, the referenced
8116// // value (but not the address) is printed; for a (const or not) char
8117// // pointer, the NUL-terminated string (but not the pointer) is
8118// // printed.
8119// void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
8120//
8121// // Prints value using the type inferred by the compiler. The difference
8122// // from UniversalTersePrint() is that this function prints both the
8123// // pointer and the NUL-terminated string for a (const or not) char pointer.
8124// void ::testing::internal::UniversalPrint(const T& value, ostream*);
8125//
8126// // Prints the fields of a tuple tersely to a string vector, one
8127// // element for each field. Tuple support must be enabled in
8128// // gtest-port.h.
8129// std::vector<string> UniversalTersePrintTupleFieldsToStrings(
8130// const Tuple& value);
8131//
8132// Known limitation:
8133//
8134// The print primitives print the elements of an STL-style container
8135// using the compiler-inferred type of *iter where iter is a
8136// const_iterator of the container. When const_iterator is an input
8137// iterator but not a forward iterator, this inferred type may not
8138// match value_type, and the print output may be incorrect. In
8139// practice, this is rarely a problem as for most containers
8140// const_iterator is a forward iterator. We'll fix this if there's an
8141// actual need for it. Note that this fix cannot rely on value_type
8142// being defined as many user-defined container types don't have
8143// value_type.
8144
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008145// GOOGLETEST_CM0001 DO NOT DELETE
8146
Austin Schuh70cc9552019-01-21 19:46:48 -08008147#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8148#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
8149
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008150#include <functional>
Austin Schuh70cc9552019-01-21 19:46:48 -08008151#include <ostream> // NOLINT
8152#include <sstream>
8153#include <string>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008154#include <tuple>
8155#include <type_traits>
Austin Schuh70cc9552019-01-21 19:46:48 -08008156#include <utility>
8157#include <vector>
8158
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008159#if GTEST_HAS_ABSL
8160#include "absl/strings/string_view.h"
8161#include "absl/types/optional.h"
8162#include "absl/types/variant.h"
8163#endif // GTEST_HAS_ABSL
Austin Schuh70cc9552019-01-21 19:46:48 -08008164
8165namespace testing {
8166
8167// Definitions in the 'internal' and 'internal2' name spaces are
8168// subject to change without notice. DO NOT USE THEM IN USER CODE!
8169namespace internal2 {
8170
8171// Prints the given number of bytes in the given object to the given
8172// ostream.
8173GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
8174 size_t count,
8175 ::std::ostream* os);
8176
8177// For selecting which printer to use when a given type has neither <<
8178// nor PrintTo().
8179enum TypeKind {
8180 kProtobuf, // a protobuf type
8181 kConvertibleToInteger, // a type implicitly convertible to BiggestInt
8182 // (e.g. a named or unnamed enum type)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008183#if GTEST_HAS_ABSL
8184 kConvertibleToStringView, // a type implicitly convertible to
8185 // absl::string_view
8186#endif
8187 kOtherType // anything else
Austin Schuh70cc9552019-01-21 19:46:48 -08008188};
8189
8190// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
8191// by the universal printer to print a value of type T when neither
8192// operator<< nor PrintTo() is defined for T, where kTypeKind is the
8193// "kind" of T as defined by enum TypeKind.
8194template <typename T, TypeKind kTypeKind>
8195class TypeWithoutFormatter {
8196 public:
8197 // This default version is called when kTypeKind is kOtherType.
8198 static void PrintValue(const T& value, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008199 PrintBytesInObjectTo(static_cast<const unsigned char*>(
8200 reinterpret_cast<const void*>(&value)),
Austin Schuh70cc9552019-01-21 19:46:48 -08008201 sizeof(value), os);
8202 }
8203};
8204
8205// We print a protobuf using its ShortDebugString() when the string
8206// doesn't exceed this many characters; otherwise we print it using
8207// DebugString() for better readability.
8208const size_t kProtobufOneLinerMaxLength = 50;
8209
8210template <typename T>
8211class TypeWithoutFormatter<T, kProtobuf> {
8212 public:
8213 static void PrintValue(const T& value, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008214 std::string pretty_str = value.ShortDebugString();
8215 if (pretty_str.length() > kProtobufOneLinerMaxLength) {
8216 pretty_str = "\n" + value.DebugString();
8217 }
Austin Schuh70cc9552019-01-21 19:46:48 -08008218 *os << ("<" + pretty_str + ">");
8219 }
8220};
8221
8222template <typename T>
8223class TypeWithoutFormatter<T, kConvertibleToInteger> {
8224 public:
8225 // Since T has no << operator or PrintTo() but can be implicitly
8226 // converted to BiggestInt, we print it as a BiggestInt.
8227 //
8228 // Most likely T is an enum type (either named or unnamed), in which
8229 // case printing it as an integer is the desired behavior. In case
8230 // T is not an enum, printing it as an integer is the best we can do
8231 // given that it has no user-defined printer.
8232 static void PrintValue(const T& value, ::std::ostream* os) {
8233 const internal::BiggestInt kBigInt = value;
8234 *os << kBigInt;
8235 }
8236};
8237
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008238#if GTEST_HAS_ABSL
8239template <typename T>
8240class TypeWithoutFormatter<T, kConvertibleToStringView> {
8241 public:
8242 // Since T has neither operator<< nor PrintTo() but can be implicitly
8243 // converted to absl::string_view, we print it as a absl::string_view.
8244 //
8245 // Note: the implementation is further below, as it depends on
8246 // internal::PrintTo symbol which is defined later in the file.
8247 static void PrintValue(const T& value, ::std::ostream* os);
8248};
8249#endif
8250
Austin Schuh70cc9552019-01-21 19:46:48 -08008251// Prints the given value to the given ostream. If the value is a
8252// protocol message, its debug string is printed; if it's an enum or
8253// of a type implicitly convertible to BiggestInt, it's printed as an
8254// integer; otherwise the bytes in the value are printed. This is
8255// what UniversalPrinter<T>::Print() does when it knows nothing about
8256// type T and T has neither << operator nor PrintTo().
8257//
8258// A user can override this behavior for a class type Foo by defining
8259// a << operator in the namespace where Foo is defined.
8260//
8261// We put this operator in namespace 'internal2' instead of 'internal'
8262// to simplify the implementation, as much code in 'internal' needs to
8263// use << in STL, which would conflict with our own << were it defined
8264// in 'internal'.
8265//
8266// Note that this operator<< takes a generic std::basic_ostream<Char,
8267// CharTraits> type instead of the more restricted std::ostream. If
8268// we define it to take an std::ostream instead, we'll get an
8269// "ambiguous overloads" compiler error when trying to print a type
8270// Foo that supports streaming to std::basic_ostream<Char,
8271// CharTraits>, as the compiler cannot tell whether
8272// operator<<(std::ostream&, const T&) or
8273// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
8274// specific.
8275template <typename Char, typename CharTraits, typename T>
8276::std::basic_ostream<Char, CharTraits>& operator<<(
8277 ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008278 TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
8279 ? kProtobuf
8280 : std::is_convertible<
8281 const T&, internal::BiggestInt>::value
8282 ? kConvertibleToInteger
8283 :
8284#if GTEST_HAS_ABSL
8285 std::is_convertible<
8286 const T&, absl::string_view>::value
8287 ? kConvertibleToStringView
8288 :
8289#endif
8290 kOtherType)>::PrintValue(x, &os);
Austin Schuh70cc9552019-01-21 19:46:48 -08008291 return os;
8292}
8293
8294} // namespace internal2
8295} // namespace testing
8296
8297// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
8298// magic needed for implementing UniversalPrinter won't work.
8299namespace testing_internal {
8300
8301// Used to print a value that is not an STL-style container when the
8302// user doesn't define PrintTo() for it.
8303template <typename T>
8304void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
8305 // With the following statement, during unqualified name lookup,
8306 // testing::internal2::operator<< appears as if it was declared in
8307 // the nearest enclosing namespace that contains both
8308 // ::testing_internal and ::testing::internal2, i.e. the global
8309 // namespace. For more details, refer to the C++ Standard section
8310 // 7.3.4-1 [namespace.udir]. This allows us to fall back onto
8311 // testing::internal2::operator<< in case T doesn't come with a <<
8312 // operator.
8313 //
8314 // We cannot write 'using ::testing::internal2::operator<<;', which
8315 // gcc 3.3 fails to compile due to a compiler bug.
8316 using namespace ::testing::internal2; // NOLINT
8317
8318 // Assuming T is defined in namespace foo, in the next statement,
8319 // the compiler will consider all of:
8320 //
8321 // 1. foo::operator<< (thanks to Koenig look-up),
8322 // 2. ::operator<< (as the current namespace is enclosed in ::),
8323 // 3. testing::internal2::operator<< (thanks to the using statement above).
8324 //
8325 // The operator<< whose type matches T best will be picked.
8326 //
8327 // We deliberately allow #2 to be a candidate, as sometimes it's
8328 // impossible to define #1 (e.g. when foo is ::std, defining
8329 // anything in it is undefined behavior unless you are a compiler
8330 // vendor.).
8331 *os << value;
8332}
8333
8334} // namespace testing_internal
8335
8336namespace testing {
8337namespace internal {
8338
8339// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
8340// value of type ToPrint that is an operand of a comparison assertion
8341// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in
8342// the comparison, and is used to help determine the best way to
8343// format the value. In particular, when the value is a C string
8344// (char pointer) and the other operand is an STL string object, we
8345// want to format the C string as a string, since we know it is
8346// compared by value with the string object. If the value is a char
8347// pointer but the other operand is not an STL string object, we don't
8348// know whether the pointer is supposed to point to a NUL-terminated
8349// string, and thus want to print it as a pointer to be safe.
8350//
8351// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
8352
8353// The default case.
8354template <typename ToPrint, typename OtherOperand>
8355class FormatForComparison {
8356 public:
8357 static ::std::string Format(const ToPrint& value) {
8358 return ::testing::PrintToString(value);
8359 }
8360};
8361
8362// Array.
8363template <typename ToPrint, size_t N, typename OtherOperand>
8364class FormatForComparison<ToPrint[N], OtherOperand> {
8365 public:
8366 static ::std::string Format(const ToPrint* value) {
8367 return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
8368 }
8369};
8370
8371// By default, print C string as pointers to be safe, as we don't know
8372// whether they actually point to a NUL-terminated string.
8373
8374#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \
8375 template <typename OtherOperand> \
8376 class FormatForComparison<CharType*, OtherOperand> { \
8377 public: \
8378 static ::std::string Format(CharType* value) { \
8379 return ::testing::PrintToString(static_cast<const void*>(value)); \
8380 } \
8381 }
8382
8383GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
8384GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
8385GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
8386GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
8387
8388#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
8389
8390// If a C string is compared with an STL string object, we know it's meant
8391// to point to a NUL-terminated string, and thus can print it as a string.
8392
8393#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
8394 template <> \
8395 class FormatForComparison<CharType*, OtherStringType> { \
8396 public: \
8397 static ::std::string Format(CharType* value) { \
8398 return ::testing::PrintToString(value); \
8399 } \
8400 }
8401
8402GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
8403GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
8404
8405#if GTEST_HAS_GLOBAL_STRING
8406GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);
8407GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);
8408#endif
8409
8410#if GTEST_HAS_GLOBAL_WSTRING
8411GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);
8412GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);
8413#endif
8414
8415#if GTEST_HAS_STD_WSTRING
8416GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
8417GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
8418#endif
8419
8420#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
8421
8422// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
8423// operand to be used in a failure message. The type (but not value)
8424// of the other operand may affect the format. This allows us to
8425// print a char* as a raw pointer when it is compared against another
8426// char* or void*, and print it as a C string when it is compared
8427// against an std::string object, for example.
8428//
8429// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
8430template <typename T1, typename T2>
8431std::string FormatForComparisonFailureMessage(
8432 const T1& value, const T2& /* other_operand */) {
8433 return FormatForComparison<T1, T2>::Format(value);
8434}
8435
8436// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
8437// value to the given ostream. The caller must ensure that
8438// 'ostream_ptr' is not NULL, or the behavior is undefined.
8439//
8440// We define UniversalPrinter as a class template (as opposed to a
8441// function template), as we need to partially specialize it for
8442// reference types, which cannot be done with function templates.
8443template <typename T>
8444class UniversalPrinter;
8445
8446template <typename T>
8447void UniversalPrint(const T& value, ::std::ostream* os);
8448
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008449enum DefaultPrinterType {
8450 kPrintContainer,
8451 kPrintPointer,
8452 kPrintFunctionPointer,
8453 kPrintOther,
8454};
8455template <DefaultPrinterType type> struct WrapPrinterType {};
8456
Austin Schuh70cc9552019-01-21 19:46:48 -08008457// Used to print an STL-style container when the user doesn't define
8458// a PrintTo() for it.
8459template <typename C>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008460void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
Austin Schuh70cc9552019-01-21 19:46:48 -08008461 const C& container, ::std::ostream* os) {
8462 const size_t kMaxCount = 32; // The maximum number of elements to print.
8463 *os << '{';
8464 size_t count = 0;
8465 for (typename C::const_iterator it = container.begin();
8466 it != container.end(); ++it, ++count) {
8467 if (count > 0) {
8468 *os << ',';
8469 if (count == kMaxCount) { // Enough has been printed.
8470 *os << " ...";
8471 break;
8472 }
8473 }
8474 *os << ' ';
8475 // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
8476 // handle *it being a native array.
8477 internal::UniversalPrint(*it, os);
8478 }
8479
8480 if (count > 0) {
8481 *os << ' ';
8482 }
8483 *os << '}';
8484}
8485
8486// Used to print a pointer that is neither a char pointer nor a member
8487// pointer, when the user doesn't define PrintTo() for it. (A member
8488// variable pointer or member function pointer doesn't really point to
8489// a location in the address space. Their representation is
8490// implementation-defined. Therefore they will be printed as raw
8491// bytes.)
8492template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008493void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
Austin Schuh70cc9552019-01-21 19:46:48 -08008494 T* p, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008495 if (p == nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -08008496 *os << "NULL";
8497 } else {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008498 // T is not a function type. We just call << to print p,
8499 // relying on ADL to pick up user-defined << for their pointer
8500 // types, if any.
8501 *os << p;
8502 }
8503}
8504template <typename T>
8505void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,
8506 T* p, ::std::ostream* os) {
8507 if (p == nullptr) {
8508 *os << "NULL";
8509 } else {
8510 // T is a function type, so '*os << p' doesn't do what we want
8511 // (it just prints p as bool). We want to print p as a const
8512 // void*.
8513 *os << reinterpret_cast<const void*>(p);
Austin Schuh70cc9552019-01-21 19:46:48 -08008514 }
8515}
8516
8517// Used to print a non-container, non-pointer value when the user
8518// doesn't define PrintTo() for it.
8519template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008520void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
Austin Schuh70cc9552019-01-21 19:46:48 -08008521 const T& value, ::std::ostream* os) {
8522 ::testing_internal::DefaultPrintNonContainerTo(value, os);
8523}
8524
8525// Prints the given value using the << operator if it has one;
8526// otherwise prints the bytes in it. This is what
8527// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
8528// or overloaded for type T.
8529//
8530// A user can override this behavior for a class type Foo by defining
8531// an overload of PrintTo() in the namespace where Foo is defined. We
8532// give the user this option as sometimes defining a << operator for
8533// Foo is not desirable (e.g. the coding style may prevent doing it,
8534// or there is already a << operator but it doesn't do what the user
8535// wants).
8536template <typename T>
8537void PrintTo(const T& value, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008538 // DefaultPrintTo() is overloaded. The type of its first argument
8539 // determines which version will be picked.
Austin Schuh70cc9552019-01-21 19:46:48 -08008540 //
8541 // Note that we check for container types here, prior to we check
8542 // for protocol message types in our operator<<. The rationale is:
8543 //
8544 // For protocol messages, we want to give people a chance to
8545 // override Google Mock's format by defining a PrintTo() or
8546 // operator<<. For STL containers, other formats can be
8547 // incompatible with Google Mock's format for the container
8548 // elements; therefore we check for container types here to ensure
8549 // that our format is used.
8550 //
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008551 // Note that MSVC and clang-cl do allow an implicit conversion from
8552 // pointer-to-function to pointer-to-object, but clang-cl warns on it.
8553 // So don't use ImplicitlyConvertible if it can be helped since it will
8554 // cause this warning, and use a separate overload of DefaultPrintTo for
8555 // function pointers so that the `*os << p` in the object pointer overload
8556 // doesn't cause that warning either.
8557 DefaultPrintTo(
8558 WrapPrinterType <
8559 (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
8560 !IsRecursiveContainer<T>::value
8561 ? kPrintContainer
8562 : !std::is_pointer<T>::value
8563 ? kPrintOther
8564 : std::is_function<typename std::remove_pointer<T>::type>::value
8565 ? kPrintFunctionPointer
8566 : kPrintPointer > (),
8567 value, os);
Austin Schuh70cc9552019-01-21 19:46:48 -08008568}
8569
8570// The following list of PrintTo() overloads tells
8571// UniversalPrinter<T>::Print() how to print standard types (built-in
8572// types, strings, plain arrays, and pointers).
8573
8574// Overloads for various char types.
8575GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
8576GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
8577inline void PrintTo(char c, ::std::ostream* os) {
8578 // When printing a plain char, we always treat it as unsigned. This
8579 // way, the output won't be affected by whether the compiler thinks
8580 // char is signed or not.
8581 PrintTo(static_cast<unsigned char>(c), os);
8582}
8583
8584// Overloads for other simple built-in types.
8585inline void PrintTo(bool x, ::std::ostream* os) {
8586 *os << (x ? "true" : "false");
8587}
8588
8589// Overload for wchar_t type.
8590// Prints a wchar_t as a symbol if it is printable or as its internal
8591// code otherwise and also as its decimal code (except for L'\0').
8592// The L'\0' char is printed as "L'\\0'". The decimal code is printed
8593// as signed integer when wchar_t is implemented by the compiler
8594// as a signed type and is printed as an unsigned integer when wchar_t
8595// is implemented as an unsigned type.
8596GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
8597
8598// Overloads for C strings.
8599GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
8600inline void PrintTo(char* s, ::std::ostream* os) {
8601 PrintTo(ImplicitCast_<const char*>(s), os);
8602}
8603
8604// signed/unsigned char is often used for representing binary data, so
8605// we print pointers to it as void* to be safe.
8606inline void PrintTo(const signed char* s, ::std::ostream* os) {
8607 PrintTo(ImplicitCast_<const void*>(s), os);
8608}
8609inline void PrintTo(signed char* s, ::std::ostream* os) {
8610 PrintTo(ImplicitCast_<const void*>(s), os);
8611}
8612inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
8613 PrintTo(ImplicitCast_<const void*>(s), os);
8614}
8615inline void PrintTo(unsigned char* s, ::std::ostream* os) {
8616 PrintTo(ImplicitCast_<const void*>(s), os);
8617}
8618
8619// MSVC can be configured to define wchar_t as a typedef of unsigned
8620// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
8621// type. When wchar_t is a typedef, defining an overload for const
8622// wchar_t* would cause unsigned short* be printed as a wide string,
8623// possibly causing invalid memory accesses.
8624#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
8625// Overloads for wide C strings
8626GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
8627inline void PrintTo(wchar_t* s, ::std::ostream* os) {
8628 PrintTo(ImplicitCast_<const wchar_t*>(s), os);
8629}
8630#endif
8631
8632// Overload for C arrays. Multi-dimensional arrays are printed
8633// properly.
8634
8635// Prints the given number of elements in an array, without printing
8636// the curly braces.
8637template <typename T>
8638void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
8639 UniversalPrint(a[0], os);
8640 for (size_t i = 1; i != count; i++) {
8641 *os << ", ";
8642 UniversalPrint(a[i], os);
8643 }
8644}
8645
8646// Overloads for ::string and ::std::string.
8647#if GTEST_HAS_GLOBAL_STRING
8648GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
8649inline void PrintTo(const ::string& s, ::std::ostream* os) {
8650 PrintStringTo(s, os);
8651}
8652#endif // GTEST_HAS_GLOBAL_STRING
8653
8654GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
8655inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
8656 PrintStringTo(s, os);
8657}
8658
8659// Overloads for ::wstring and ::std::wstring.
8660#if GTEST_HAS_GLOBAL_WSTRING
8661GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
8662inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
8663 PrintWideStringTo(s, os);
8664}
8665#endif // GTEST_HAS_GLOBAL_WSTRING
8666
8667#if GTEST_HAS_STD_WSTRING
8668GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
8669inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
8670 PrintWideStringTo(s, os);
8671}
8672#endif // GTEST_HAS_STD_WSTRING
8673
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008674#if GTEST_HAS_ABSL
8675// Overload for absl::string_view.
8676inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
8677 PrintTo(::std::string(sp), os);
8678}
8679#endif // GTEST_HAS_ABSL
8680
8681inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
8682
8683template <typename T>
8684void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
8685 UniversalPrinter<T&>::Print(ref.get(), os);
8686}
8687
Austin Schuh70cc9552019-01-21 19:46:48 -08008688// Helper function for printing a tuple. T must be instantiated with
8689// a tuple type.
8690template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008691void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
8692 ::std::ostream*) {}
Austin Schuh70cc9552019-01-21 19:46:48 -08008693
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008694template <typename T, size_t I>
8695void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
8696 ::std::ostream* os) {
8697 PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
8698 GTEST_INTENTIONAL_CONST_COND_PUSH_()
8699 if (I > 1) {
8700 GTEST_INTENTIONAL_CONST_COND_POP_()
8701 *os << ", ";
8702 }
8703 UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
8704 std::get<I - 1>(t), os);
Austin Schuh70cc9552019-01-21 19:46:48 -08008705}
8706
Austin Schuh70cc9552019-01-21 19:46:48 -08008707template <typename... Types>
8708void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008709 *os << "(";
8710 PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
8711 *os << ")";
Austin Schuh70cc9552019-01-21 19:46:48 -08008712}
Austin Schuh70cc9552019-01-21 19:46:48 -08008713
8714// Overload for std::pair.
8715template <typename T1, typename T2>
8716void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
8717 *os << '(';
8718 // We cannot use UniversalPrint(value.first, os) here, as T1 may be
8719 // a reference type. The same for printing value.second.
8720 UniversalPrinter<T1>::Print(value.first, os);
8721 *os << ", ";
8722 UniversalPrinter<T2>::Print(value.second, os);
8723 *os << ')';
8724}
8725
8726// Implements printing a non-reference type T by letting the compiler
8727// pick the right overload of PrintTo() for T.
8728template <typename T>
8729class UniversalPrinter {
8730 public:
8731 // MSVC warns about adding const to a function type, so we want to
8732 // disable the warning.
8733 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
8734
8735 // Note: we deliberately don't call this PrintTo(), as that name
8736 // conflicts with ::testing::internal::PrintTo in the body of the
8737 // function.
8738 static void Print(const T& value, ::std::ostream* os) {
8739 // By default, ::testing::internal::PrintTo() is used for printing
8740 // the value.
8741 //
8742 // Thanks to Koenig look-up, if T is a class and has its own
8743 // PrintTo() function defined in its namespace, that function will
8744 // be visible here. Since it is more specific than the generic ones
8745 // in ::testing::internal, it will be picked by the compiler in the
8746 // following statement - exactly what we want.
8747 PrintTo(value, os);
8748 }
8749
8750 GTEST_DISABLE_MSC_WARNINGS_POP_()
8751};
8752
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008753#if GTEST_HAS_ABSL
8754
8755// Printer for absl::optional
8756
8757template <typename T>
8758class UniversalPrinter<::absl::optional<T>> {
8759 public:
8760 static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
8761 *os << '(';
8762 if (!value) {
8763 *os << "nullopt";
8764 } else {
8765 UniversalPrint(*value, os);
8766 }
8767 *os << ')';
8768 }
8769};
8770
8771// Printer for absl::variant
8772
8773template <typename... T>
8774class UniversalPrinter<::absl::variant<T...>> {
8775 public:
8776 static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {
8777 *os << '(';
8778 absl::visit(Visitor{os}, value);
8779 *os << ')';
8780 }
8781
8782 private:
8783 struct Visitor {
8784 template <typename U>
8785 void operator()(const U& u) const {
8786 *os << "'" << GetTypeName<U>() << "' with value ";
8787 UniversalPrint(u, os);
8788 }
8789 ::std::ostream* os;
8790 };
8791};
8792
8793#endif // GTEST_HAS_ABSL
8794
Austin Schuh70cc9552019-01-21 19:46:48 -08008795// UniversalPrintArray(begin, len, os) prints an array of 'len'
8796// elements, starting at address 'begin'.
8797template <typename T>
8798void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
8799 if (len == 0) {
8800 *os << "{}";
8801 } else {
8802 *os << "{ ";
8803 const size_t kThreshold = 18;
8804 const size_t kChunkSize = 8;
8805 // If the array has more than kThreshold elements, we'll have to
8806 // omit some details by printing only the first and the last
8807 // kChunkSize elements.
Austin Schuh70cc9552019-01-21 19:46:48 -08008808 if (len <= kThreshold) {
8809 PrintRawArrayTo(begin, len, os);
8810 } else {
8811 PrintRawArrayTo(begin, kChunkSize, os);
8812 *os << ", ..., ";
8813 PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
8814 }
8815 *os << " }";
8816 }
8817}
8818// This overload prints a (const) char array compactly.
8819GTEST_API_ void UniversalPrintArray(
8820 const char* begin, size_t len, ::std::ostream* os);
8821
8822// This overload prints a (const) wchar_t array compactly.
8823GTEST_API_ void UniversalPrintArray(
8824 const wchar_t* begin, size_t len, ::std::ostream* os);
8825
8826// Implements printing an array type T[N].
8827template <typename T, size_t N>
8828class UniversalPrinter<T[N]> {
8829 public:
8830 // Prints the given array, omitting some elements when there are too
8831 // many.
8832 static void Print(const T (&a)[N], ::std::ostream* os) {
8833 UniversalPrintArray(a, N, os);
8834 }
8835};
8836
8837// Implements printing a reference type T&.
8838template <typename T>
8839class UniversalPrinter<T&> {
8840 public:
8841 // MSVC warns about adding const to a function type, so we want to
8842 // disable the warning.
8843 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
8844
8845 static void Print(const T& value, ::std::ostream* os) {
8846 // Prints the address of the value. We use reinterpret_cast here
8847 // as static_cast doesn't compile when T is a function type.
8848 *os << "@" << reinterpret_cast<const void*>(&value) << " ";
8849
8850 // Then prints the value itself.
8851 UniversalPrint(value, os);
8852 }
8853
8854 GTEST_DISABLE_MSC_WARNINGS_POP_()
8855};
8856
8857// Prints a value tersely: for a reference type, the referenced value
8858// (but not the address) is printed; for a (const) char pointer, the
8859// NUL-terminated string (but not the pointer) is printed.
8860
8861template <typename T>
8862class UniversalTersePrinter {
8863 public:
8864 static void Print(const T& value, ::std::ostream* os) {
8865 UniversalPrint(value, os);
8866 }
8867};
8868template <typename T>
8869class UniversalTersePrinter<T&> {
8870 public:
8871 static void Print(const T& value, ::std::ostream* os) {
8872 UniversalPrint(value, os);
8873 }
8874};
8875template <typename T, size_t N>
8876class UniversalTersePrinter<T[N]> {
8877 public:
8878 static void Print(const T (&value)[N], ::std::ostream* os) {
8879 UniversalPrinter<T[N]>::Print(value, os);
8880 }
8881};
8882template <>
8883class UniversalTersePrinter<const char*> {
8884 public:
8885 static void Print(const char* str, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008886 if (str == nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -08008887 *os << "NULL";
8888 } else {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008889 UniversalPrint(std::string(str), os);
Austin Schuh70cc9552019-01-21 19:46:48 -08008890 }
8891 }
8892};
8893template <>
8894class UniversalTersePrinter<char*> {
8895 public:
8896 static void Print(char* str, ::std::ostream* os) {
8897 UniversalTersePrinter<const char*>::Print(str, os);
8898 }
8899};
8900
8901#if GTEST_HAS_STD_WSTRING
8902template <>
8903class UniversalTersePrinter<const wchar_t*> {
8904 public:
8905 static void Print(const wchar_t* str, ::std::ostream* os) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008906 if (str == nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -08008907 *os << "NULL";
8908 } else {
8909 UniversalPrint(::std::wstring(str), os);
8910 }
8911 }
8912};
8913#endif
8914
8915template <>
8916class UniversalTersePrinter<wchar_t*> {
8917 public:
8918 static void Print(wchar_t* str, ::std::ostream* os) {
8919 UniversalTersePrinter<const wchar_t*>::Print(str, os);
8920 }
8921};
8922
8923template <typename T>
8924void UniversalTersePrint(const T& value, ::std::ostream* os) {
8925 UniversalTersePrinter<T>::Print(value, os);
8926}
8927
8928// Prints a value using the type inferred by the compiler. The
8929// difference between this and UniversalTersePrint() is that for a
8930// (const) char pointer, this prints both the pointer and the
8931// NUL-terminated string.
8932template <typename T>
8933void UniversalPrint(const T& value, ::std::ostream* os) {
8934 // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
8935 // UniversalPrinter with T directly.
8936 typedef T T1;
8937 UniversalPrinter<T1>::Print(value, os);
8938}
8939
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008940typedef ::std::vector< ::std::string> Strings;
Austin Schuh70cc9552019-01-21 19:46:48 -08008941
8942 // Tersely prints the first N fields of a tuple to a string vector,
8943 // one element for each field.
Austin Schuh70cc9552019-01-21 19:46:48 -08008944template <typename Tuple>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008945void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
8946 Strings*) {}
8947template <typename Tuple, size_t I>
8948void TersePrintPrefixToStrings(const Tuple& t,
8949 std::integral_constant<size_t, I>,
8950 Strings* strings) {
8951 TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
8952 strings);
8953 ::std::stringstream ss;
8954 UniversalTersePrint(std::get<I - 1>(t), &ss);
8955 strings->push_back(ss.str());
Austin Schuh70cc9552019-01-21 19:46:48 -08008956}
8957
8958// Prints the fields of a tuple tersely to a string vector, one
8959// element for each field. See the comment before
8960// UniversalTersePrint() for how we define "tersely".
8961template <typename Tuple>
8962Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
8963 Strings result;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008964 TersePrintPrefixToStrings(
8965 value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
8966 &result);
Austin Schuh70cc9552019-01-21 19:46:48 -08008967 return result;
8968}
Austin Schuh70cc9552019-01-21 19:46:48 -08008969
8970} // namespace internal
8971
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08008972#if GTEST_HAS_ABSL
8973namespace internal2 {
8974template <typename T>
8975void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(
8976 const T& value, ::std::ostream* os) {
8977 internal::PrintTo(absl::string_view(value), os);
8978}
8979} // namespace internal2
8980#endif
8981
Austin Schuh70cc9552019-01-21 19:46:48 -08008982template <typename T>
8983::std::string PrintToString(const T& value) {
8984 ::std::stringstream ss;
8985 internal::UniversalTersePrinter<T>::Print(value, &ss);
8986 return ss.str();
8987}
8988
8989} // namespace testing
8990
8991// Include any custom printer added by the local installation.
8992// We must include this header at the end to make sure it can use the
8993// declarations from this file.
8994// Copyright 2015, Google Inc.
8995// All rights reserved.
8996//
8997// Redistribution and use in source and binary forms, with or without
8998// modification, are permitted provided that the following conditions are
8999// met:
9000//
9001// * Redistributions of source code must retain the above copyright
9002// notice, this list of conditions and the following disclaimer.
9003// * Redistributions in binary form must reproduce the above
9004// copyright notice, this list of conditions and the following disclaimer
9005// in the documentation and/or other materials provided with the
9006// distribution.
9007// * Neither the name of Google Inc. nor the names of its
9008// contributors may be used to endorse or promote products derived from
9009// this software without specific prior written permission.
9010//
9011// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9012// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
9013// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
9014// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9015// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9016// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9017// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
9018// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
9019// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
9020// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
9021// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9022//
9023// This file provides an injection point for custom printers in a local
9024// installation of gTest.
9025// It will be included from gtest-printers.h and the overrides in this file
9026// will be visible to everyone.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08009027//
9028// Injection point for custom user configurations. See README for details
Austin Schuh70cc9552019-01-21 19:46:48 -08009029//
9030// ** Custom implementation starts here **
9031
9032#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
9033#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
9034
9035#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
9036
9037#endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
9038
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08009039GTEST_DISABLE_MSC_WARNINGS_PUSH_(
9040 4251 5046 /* class A needs to have dll-interface to be used by clients of
9041 class B */
9042 /* Symbol involving type with internal linkage not defined */)
Austin Schuh70cc9552019-01-21 19:46:48 -08009043
9044namespace testing {
9045
Austin Schuh1d1e6ea2020-12-23 21:56:30 -08009046// To implement a matcher Foo for type T, define:
9047// 1. a class FooMatcherImpl that implements the
9048// MatcherInterface<T> interface, and
9049// 2. a factory function that creates a Matcher<T> object from a
9050// FooMatcherImpl*.
9051//
9052// The two-level delegation design makes it possible to allow a user
9053// to write "v" instead of "Eq(v)" where a Matcher is expected, which
9054// is impossible if we pass matchers by pointers. It also eases
9055// ownership management as Matcher objects can now be copied like
9056// plain values.
9057
9058// MatchResultListener is an abstract class. Its << operator can be
9059// used by a matcher to explain why a value matches or doesn't match.
9060//
9061class MatchResultListener {
9062 public:
9063 // Creates a listener object with the given underlying ostream. The
9064 // listener does not own the ostream, and does not dereference it
9065 // in the constructor or destructor.
9066 explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
9067 virtual ~MatchResultListener() = 0; // Makes this class abstract.
9068
9069 // Streams x to the underlying ostream; does nothing if the ostream
9070 // is NULL.
9071 template <typename T>
9072 MatchResultListener& operator<<(const T& x) {
9073 if (stream_ != nullptr) *stream_ << x;
9074 return *this;
9075 }
9076
9077 // Returns the underlying ostream.
9078 ::std::ostream* stream() { return stream_; }
9079
9080 // Returns true iff the listener is interested in an explanation of
9081 // the match result. A matcher's MatchAndExplain() method can use
9082 // this information to avoid generating the explanation when no one
9083 // intends to hear it.
9084 bool IsInterested() const { return stream_ != nullptr; }
9085
9086 private:
9087 ::std::ostream* const stream_;
9088
9089 GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
9090};
9091
9092inline MatchResultListener::~MatchResultListener() {
9093}
9094
9095// An instance of a subclass of this knows how to describe itself as a
9096// matcher.
9097class MatcherDescriberInterface {
9098 public:
9099 virtual ~MatcherDescriberInterface() {}
9100
9101 // Describes this matcher to an ostream. The function should print
9102 // a verb phrase that describes the property a value matching this
9103 // matcher should have. The subject of the verb phrase is the value
9104 // being matched. For example, the DescribeTo() method of the Gt(7)
9105 // matcher prints "is greater than 7".
9106 virtual void DescribeTo(::std::ostream* os) const = 0;
9107
9108 // Describes the negation of this matcher to an ostream. For
9109 // example, if the description of this matcher is "is greater than
9110 // 7", the negated description could be "is not greater than 7".
9111 // You are not required to override this when implementing
9112 // MatcherInterface, but it is highly advised so that your matcher
9113 // can produce good error messages.
9114 virtual void DescribeNegationTo(::std::ostream* os) const {
9115 *os << "not (";
9116 DescribeTo(os);
9117 *os << ")";
9118 }
9119};
9120
9121// The implementation of a matcher.
9122template <typename T>
9123class MatcherInterface : public MatcherDescriberInterface {
9124 public:
9125 // Returns true iff the matcher matches x; also explains the match
9126 // result to 'listener' if necessary (see the next paragraph), in
9127 // the form of a non-restrictive relative clause ("which ...",
9128 // "whose ...", etc) that describes x. For example, the
9129 // MatchAndExplain() method of the Pointee(...) matcher should
9130 // generate an explanation like "which points to ...".
9131 //
9132 // Implementations of MatchAndExplain() should add an explanation of
9133 // the match result *if and only if* they can provide additional
9134 // information that's not already present (or not obvious) in the
9135 // print-out of x and the matcher's description. Whether the match
9136 // succeeds is not a factor in deciding whether an explanation is
9137 // needed, as sometimes the caller needs to print a failure message
9138 // when the match succeeds (e.g. when the matcher is used inside
9139 // Not()).
9140 //
9141 // For example, a "has at least 10 elements" matcher should explain
9142 // what the actual element count is, regardless of the match result,
9143 // as it is useful information to the reader; on the other hand, an
9144 // "is empty" matcher probably only needs to explain what the actual
9145 // size is when the match fails, as it's redundant to say that the
9146 // size is 0 when the value is already known to be empty.
9147 //
9148 // You should override this method when defining a new matcher.
9149 //
9150 // It's the responsibility of the caller (Google Test) to guarantee
9151 // that 'listener' is not NULL. This helps to simplify a matcher's
9152 // implementation when it doesn't care about the performance, as it
9153 // can talk to 'listener' without checking its validity first.
9154 // However, in order to implement dummy listeners efficiently,
9155 // listener->stream() may be NULL.
9156 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
9157
9158 // Inherits these methods from MatcherDescriberInterface:
9159 // virtual void DescribeTo(::std::ostream* os) const = 0;
9160 // virtual void DescribeNegationTo(::std::ostream* os) const;
9161};
9162
9163namespace internal {
9164
9165// Converts a MatcherInterface<T> to a MatcherInterface<const T&>.
9166template <typename T>
9167class MatcherInterfaceAdapter : public MatcherInterface<const T&> {
9168 public:
9169 explicit MatcherInterfaceAdapter(const MatcherInterface<T>* impl)
9170 : impl_(impl) {}
9171 ~MatcherInterfaceAdapter() override { delete impl_; }
9172
9173 void DescribeTo(::std::ostream* os) const override { impl_->DescribeTo(os); }
9174
9175 void DescribeNegationTo(::std::ostream* os) const override {
9176 impl_->DescribeNegationTo(os);
9177 }
9178
9179 bool MatchAndExplain(const T& x,
9180 MatchResultListener* listener) const override {
9181 return impl_->MatchAndExplain(x, listener);
9182 }
9183
9184 private:
9185 const MatcherInterface<T>* const impl_;
9186
9187 GTEST_DISALLOW_COPY_AND_ASSIGN_(MatcherInterfaceAdapter);
9188};
9189
9190struct AnyEq {
9191 template <typename A, typename B>
9192 bool operator()(const A& a, const B& b) const { return a == b; }
9193};
9194struct AnyNe {
9195 template <typename A, typename B>
9196 bool operator()(const A& a, const B& b) const { return a != b; }
9197};
9198struct AnyLt {
9199 template <typename A, typename B>
9200 bool operator()(const A& a, const B& b) const { return a < b; }
9201};
9202struct AnyGt {
9203 template <typename A, typename B>
9204 bool operator()(const A& a, const B& b) const { return a > b; }
9205};
9206struct AnyLe {
9207 template <typename A, typename B>
9208 bool operator()(const A& a, const B& b) const { return a <= b; }
9209};
9210struct AnyGe {
9211 template <typename A, typename B>
9212 bool operator()(const A& a, const B& b) const { return a >= b; }
9213};
9214
9215// A match result listener that ignores the explanation.
9216class DummyMatchResultListener : public MatchResultListener {
9217 public:
9218 DummyMatchResultListener() : MatchResultListener(nullptr) {}
9219
9220 private:
9221 GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
9222};
9223
9224// A match result listener that forwards the explanation to a given
9225// ostream. The difference between this and MatchResultListener is
9226// that the former is concrete.
9227class StreamMatchResultListener : public MatchResultListener {
9228 public:
9229 explicit StreamMatchResultListener(::std::ostream* os)
9230 : MatchResultListener(os) {}
9231
9232 private:
9233 GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
9234};
9235
9236// An internal class for implementing Matcher<T>, which will derive
9237// from it. We put functionalities common to all Matcher<T>
9238// specializations here to avoid code duplication.
9239template <typename T>
9240class MatcherBase {
9241 public:
9242 // Returns true iff the matcher matches x; also explains the match
9243 // result to 'listener'.
9244 bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
9245 return impl_->MatchAndExplain(x, listener);
9246 }
9247
9248 // Returns true iff this matcher matches x.
9249 bool Matches(const T& x) const {
9250 DummyMatchResultListener dummy;
9251 return MatchAndExplain(x, &dummy);
9252 }
9253
9254 // Describes this matcher to an ostream.
9255 void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
9256
9257 // Describes the negation of this matcher to an ostream.
9258 void DescribeNegationTo(::std::ostream* os) const {
9259 impl_->DescribeNegationTo(os);
9260 }
9261
9262 // Explains why x matches, or doesn't match, the matcher.
9263 void ExplainMatchResultTo(const T& x, ::std::ostream* os) const {
9264 StreamMatchResultListener listener(os);
9265 MatchAndExplain(x, &listener);
9266 }
9267
9268 // Returns the describer for this matcher object; retains ownership
9269 // of the describer, which is only guaranteed to be alive when
9270 // this matcher object is alive.
9271 const MatcherDescriberInterface* GetDescriber() const {
9272 return impl_.get();
9273 }
9274
9275 protected:
9276 MatcherBase() {}
9277
9278 // Constructs a matcher from its implementation.
9279 explicit MatcherBase(const MatcherInterface<const T&>* impl) : impl_(impl) {}
9280
9281 template <typename U>
9282 explicit MatcherBase(
9283 const MatcherInterface<U>* impl,
9284 typename internal::EnableIf<
9285 !internal::IsSame<U, const U&>::value>::type* = nullptr)
9286 : impl_(new internal::MatcherInterfaceAdapter<U>(impl)) {}
9287
9288 MatcherBase(const MatcherBase&) = default;
9289 MatcherBase& operator=(const MatcherBase&) = default;
9290 MatcherBase(MatcherBase&&) = default;
9291 MatcherBase& operator=(MatcherBase&&) = default;
9292
9293 virtual ~MatcherBase() {}
9294
9295 private:
9296 std::shared_ptr<const MatcherInterface<const T&>> impl_;
9297};
9298
9299} // namespace internal
9300
9301// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
9302// object that can check whether a value of type T matches. The
9303// implementation of Matcher<T> is just a std::shared_ptr to const
9304// MatcherInterface<T>. Don't inherit from Matcher!
9305template <typename T>
9306class Matcher : public internal::MatcherBase<T> {
9307 public:
9308 // Constructs a null matcher. Needed for storing Matcher objects in STL
9309 // containers. A default-constructed matcher is not yet initialized. You
9310 // cannot use it until a valid value has been assigned to it.
9311 explicit Matcher() {} // NOLINT
9312
9313 // Constructs a matcher from its implementation.
9314 explicit Matcher(const MatcherInterface<const T&>* impl)
9315 : internal::MatcherBase<T>(impl) {}
9316
9317 template <typename U>
9318 explicit Matcher(const MatcherInterface<U>* impl,
9319 typename internal::EnableIf<
9320 !internal::IsSame<U, const U&>::value>::type* = nullptr)
9321 : internal::MatcherBase<T>(impl) {}
9322
9323 // Implicit constructor here allows people to write
9324 // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
9325 Matcher(T value); // NOLINT
9326};
9327
9328// The following two specializations allow the user to write str
9329// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string
9330// matcher is expected.
9331template <>
9332class GTEST_API_ Matcher<const std::string&>
9333 : public internal::MatcherBase<const std::string&> {
9334 public:
9335 Matcher() {}
9336
9337 explicit Matcher(const MatcherInterface<const std::string&>* impl)
9338 : internal::MatcherBase<const std::string&>(impl) {}
9339
9340 // Allows the user to write str instead of Eq(str) sometimes, where
9341 // str is a std::string object.
9342 Matcher(const std::string& s); // NOLINT
9343
9344#if GTEST_HAS_GLOBAL_STRING
9345 // Allows the user to write str instead of Eq(str) sometimes, where
9346 // str is a ::string object.
9347 Matcher(const ::string& s); // NOLINT
9348#endif // GTEST_HAS_GLOBAL_STRING
9349
9350 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9351 Matcher(const char* s); // NOLINT
9352};
9353
9354template <>
9355class GTEST_API_ Matcher<std::string>
9356 : public internal::MatcherBase<std::string> {
9357 public:
9358 Matcher() {}
9359
9360 explicit Matcher(const MatcherInterface<const std::string&>* impl)
9361 : internal::MatcherBase<std::string>(impl) {}
9362 explicit Matcher(const MatcherInterface<std::string>* impl)
9363 : internal::MatcherBase<std::string>(impl) {}
9364
9365 // Allows the user to write str instead of Eq(str) sometimes, where
9366 // str is a string object.
9367 Matcher(const std::string& s); // NOLINT
9368
9369#if GTEST_HAS_GLOBAL_STRING
9370 // Allows the user to write str instead of Eq(str) sometimes, where
9371 // str is a ::string object.
9372 Matcher(const ::string& s); // NOLINT
9373#endif // GTEST_HAS_GLOBAL_STRING
9374
9375 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9376 Matcher(const char* s); // NOLINT
9377};
9378
9379#if GTEST_HAS_GLOBAL_STRING
9380// The following two specializations allow the user to write str
9381// instead of Eq(str) and "foo" instead of Eq("foo") when a ::string
9382// matcher is expected.
9383template <>
9384class GTEST_API_ Matcher<const ::string&>
9385 : public internal::MatcherBase<const ::string&> {
9386 public:
9387 Matcher() {}
9388
9389 explicit Matcher(const MatcherInterface<const ::string&>* impl)
9390 : internal::MatcherBase<const ::string&>(impl) {}
9391
9392 // Allows the user to write str instead of Eq(str) sometimes, where
9393 // str is a std::string object.
9394 Matcher(const std::string& s); // NOLINT
9395
9396 // Allows the user to write str instead of Eq(str) sometimes, where
9397 // str is a ::string object.
9398 Matcher(const ::string& s); // NOLINT
9399
9400 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9401 Matcher(const char* s); // NOLINT
9402};
9403
9404template <>
9405class GTEST_API_ Matcher< ::string>
9406 : public internal::MatcherBase< ::string> {
9407 public:
9408 Matcher() {}
9409
9410 explicit Matcher(const MatcherInterface<const ::string&>* impl)
9411 : internal::MatcherBase< ::string>(impl) {}
9412 explicit Matcher(const MatcherInterface< ::string>* impl)
9413 : internal::MatcherBase< ::string>(impl) {}
9414
9415 // Allows the user to write str instead of Eq(str) sometimes, where
9416 // str is a std::string object.
9417 Matcher(const std::string& s); // NOLINT
9418
9419 // Allows the user to write str instead of Eq(str) sometimes, where
9420 // str is a ::string object.
9421 Matcher(const ::string& s); // NOLINT
9422
9423 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9424 Matcher(const char* s); // NOLINT
9425};
9426#endif // GTEST_HAS_GLOBAL_STRING
9427
9428#if GTEST_HAS_ABSL
9429// The following two specializations allow the user to write str
9430// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
9431// matcher is expected.
9432template <>
9433class GTEST_API_ Matcher<const absl::string_view&>
9434 : public internal::MatcherBase<const absl::string_view&> {
9435 public:
9436 Matcher() {}
9437
9438 explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
9439 : internal::MatcherBase<const absl::string_view&>(impl) {}
9440
9441 // Allows the user to write str instead of Eq(str) sometimes, where
9442 // str is a std::string object.
9443 Matcher(const std::string& s); // NOLINT
9444
9445#if GTEST_HAS_GLOBAL_STRING
9446 // Allows the user to write str instead of Eq(str) sometimes, where
9447 // str is a ::string object.
9448 Matcher(const ::string& s); // NOLINT
9449#endif // GTEST_HAS_GLOBAL_STRING
9450
9451 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9452 Matcher(const char* s); // NOLINT
9453
9454 // Allows the user to pass absl::string_views directly.
9455 Matcher(absl::string_view s); // NOLINT
9456};
9457
9458template <>
9459class GTEST_API_ Matcher<absl::string_view>
9460 : public internal::MatcherBase<absl::string_view> {
9461 public:
9462 Matcher() {}
9463
9464 explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
9465 : internal::MatcherBase<absl::string_view>(impl) {}
9466 explicit Matcher(const MatcherInterface<absl::string_view>* impl)
9467 : internal::MatcherBase<absl::string_view>(impl) {}
9468
9469 // Allows the user to write str instead of Eq(str) sometimes, where
9470 // str is a std::string object.
9471 Matcher(const std::string& s); // NOLINT
9472
9473#if GTEST_HAS_GLOBAL_STRING
9474 // Allows the user to write str instead of Eq(str) sometimes, where
9475 // str is a ::string object.
9476 Matcher(const ::string& s); // NOLINT
9477#endif // GTEST_HAS_GLOBAL_STRING
9478
9479 // Allows the user to write "foo" instead of Eq("foo") sometimes.
9480 Matcher(const char* s); // NOLINT
9481
9482 // Allows the user to pass absl::string_views directly.
9483 Matcher(absl::string_view s); // NOLINT
9484};
9485#endif // GTEST_HAS_ABSL
9486
9487// Prints a matcher in a human-readable format.
9488template <typename T>
9489std::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) {
9490 matcher.DescribeTo(&os);
9491 return os;
9492}
9493
9494// The PolymorphicMatcher class template makes it easy to implement a
9495// polymorphic matcher (i.e. a matcher that can match values of more
9496// than one type, e.g. Eq(n) and NotNull()).
9497//
9498// To define a polymorphic matcher, a user should provide an Impl
9499// class that has a DescribeTo() method and a DescribeNegationTo()
9500// method, and define a member function (or member function template)
9501//
9502// bool MatchAndExplain(const Value& value,
9503// MatchResultListener* listener) const;
9504//
9505// See the definition of NotNull() for a complete example.
9506template <class Impl>
9507class PolymorphicMatcher {
9508 public:
9509 explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
9510
9511 // Returns a mutable reference to the underlying matcher
9512 // implementation object.
9513 Impl& mutable_impl() { return impl_; }
9514
9515 // Returns an immutable reference to the underlying matcher
9516 // implementation object.
9517 const Impl& impl() const { return impl_; }
9518
9519 template <typename T>
9520 operator Matcher<T>() const {
9521 return Matcher<T>(new MonomorphicImpl<const T&>(impl_));
9522 }
9523
9524 private:
9525 template <typename T>
9526 class MonomorphicImpl : public MatcherInterface<T> {
9527 public:
9528 explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
9529
9530 virtual void DescribeTo(::std::ostream* os) const { impl_.DescribeTo(os); }
9531
9532 virtual void DescribeNegationTo(::std::ostream* os) const {
9533 impl_.DescribeNegationTo(os);
9534 }
9535
9536 virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
9537 return impl_.MatchAndExplain(x, listener);
9538 }
9539
9540 private:
9541 const Impl impl_;
9542 };
9543
9544 Impl impl_;
9545};
9546
9547// Creates a matcher from its implementation.
9548// DEPRECATED: Especially in the generic code, prefer:
9549// Matcher<T>(new MyMatcherImpl<const T&>(...));
9550//
9551// MakeMatcher may create a Matcher that accepts its argument by value, which
9552// leads to unnecessary copies & lack of support for non-copyable types.
9553template <typename T>
9554inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
9555 return Matcher<T>(impl);
9556}
9557
9558// Creates a polymorphic matcher from its implementation. This is
9559// easier to use than the PolymorphicMatcher<Impl> constructor as it
9560// doesn't require you to explicitly write the template argument, e.g.
9561//
9562// MakePolymorphicMatcher(foo);
9563// vs
9564// PolymorphicMatcher<TypeOfFoo>(foo);
9565template <class Impl>
9566inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
9567 return PolymorphicMatcher<Impl>(impl);
9568}
9569
9570namespace internal {
9571// Implements a matcher that compares a given value with a
9572// pre-supplied value using one of the ==, <=, <, etc, operators. The
9573// two values being compared don't have to have the same type.
9574//
9575// The matcher defined here is polymorphic (for example, Eq(5) can be
9576// used to match an int, a short, a double, etc). Therefore we use
9577// a template type conversion operator in the implementation.
9578//
9579// The following template definition assumes that the Rhs parameter is
9580// a "bare" type (i.e. neither 'const T' nor 'T&').
9581template <typename D, typename Rhs, typename Op>
9582class ComparisonBase {
9583 public:
9584 explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {}
9585 template <typename Lhs>
9586 operator Matcher<Lhs>() const {
9587 return Matcher<Lhs>(new Impl<const Lhs&>(rhs_));
9588 }
9589
9590 private:
9591 template <typename T>
9592 static const T& Unwrap(const T& v) { return v; }
9593 template <typename T>
9594 static const T& Unwrap(std::reference_wrapper<T> v) { return v; }
9595
9596 template <typename Lhs, typename = Rhs>
9597 class Impl : public MatcherInterface<Lhs> {
9598 public:
9599 explicit Impl(const Rhs& rhs) : rhs_(rhs) {}
9600 bool MatchAndExplain(Lhs lhs,
9601 MatchResultListener* /* listener */) const override {
9602 return Op()(lhs, Unwrap(rhs_));
9603 }
9604 void DescribeTo(::std::ostream* os) const override {
9605 *os << D::Desc() << " ";
9606 UniversalPrint(Unwrap(rhs_), os);
9607 }
9608 void DescribeNegationTo(::std::ostream* os) const override {
9609 *os << D::NegatedDesc() << " ";
9610 UniversalPrint(Unwrap(rhs_), os);
9611 }
9612
9613 private:
9614 Rhs rhs_;
9615 };
9616 Rhs rhs_;
9617};
9618
9619template <typename Rhs>
9620class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
9621 public:
9622 explicit EqMatcher(const Rhs& rhs)
9623 : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }
9624 static const char* Desc() { return "is equal to"; }
9625 static const char* NegatedDesc() { return "isn't equal to"; }
9626};
9627template <typename Rhs>
9628class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
9629 public:
9630 explicit NeMatcher(const Rhs& rhs)
9631 : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }
9632 static const char* Desc() { return "isn't equal to"; }
9633 static const char* NegatedDesc() { return "is equal to"; }
9634};
9635template <typename Rhs>
9636class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
9637 public:
9638 explicit LtMatcher(const Rhs& rhs)
9639 : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }
9640 static const char* Desc() { return "is <"; }
9641 static const char* NegatedDesc() { return "isn't <"; }
9642};
9643template <typename Rhs>
9644class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
9645 public:
9646 explicit GtMatcher(const Rhs& rhs)
9647 : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }
9648 static const char* Desc() { return "is >"; }
9649 static const char* NegatedDesc() { return "isn't >"; }
9650};
9651template <typename Rhs>
9652class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
9653 public:
9654 explicit LeMatcher(const Rhs& rhs)
9655 : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }
9656 static const char* Desc() { return "is <="; }
9657 static const char* NegatedDesc() { return "isn't <="; }
9658};
9659template <typename Rhs>
9660class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
9661 public:
9662 explicit GeMatcher(const Rhs& rhs)
9663 : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }
9664 static const char* Desc() { return "is >="; }
9665 static const char* NegatedDesc() { return "isn't >="; }
9666};
9667
9668// Implements polymorphic matchers MatchesRegex(regex) and
9669// ContainsRegex(regex), which can be used as a Matcher<T> as long as
9670// T can be converted to a string.
9671class MatchesRegexMatcher {
9672 public:
9673 MatchesRegexMatcher(const RE* regex, bool full_match)
9674 : regex_(regex), full_match_(full_match) {}
9675
9676#if GTEST_HAS_ABSL
9677 bool MatchAndExplain(const absl::string_view& s,
9678 MatchResultListener* listener) const {
9679 return MatchAndExplain(string(s), listener);
9680 }
9681#endif // GTEST_HAS_ABSL
9682
9683 // Accepts pointer types, particularly:
9684 // const char*
9685 // char*
9686 // const wchar_t*
9687 // wchar_t*
9688 template <typename CharType>
9689 bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
9690 return s != nullptr && MatchAndExplain(std::string(s), listener);
9691 }
9692
9693 // Matches anything that can convert to std::string.
9694 //
9695 // This is a template, not just a plain function with const std::string&,
9696 // because absl::string_view has some interfering non-explicit constructors.
9697 template <class MatcheeStringType>
9698 bool MatchAndExplain(const MatcheeStringType& s,
9699 MatchResultListener* /* listener */) const {
9700 const std::string& s2(s);
9701 return full_match_ ? RE::FullMatch(s2, *regex_)
9702 : RE::PartialMatch(s2, *regex_);
9703 }
9704
9705 void DescribeTo(::std::ostream* os) const {
9706 *os << (full_match_ ? "matches" : "contains") << " regular expression ";
9707 UniversalPrinter<std::string>::Print(regex_->pattern(), os);
9708 }
9709
9710 void DescribeNegationTo(::std::ostream* os) const {
9711 *os << "doesn't " << (full_match_ ? "match" : "contain")
9712 << " regular expression ";
9713 UniversalPrinter<std::string>::Print(regex_->pattern(), os);
9714 }
9715
9716 private:
9717 const std::shared_ptr<const RE> regex_;
9718 const bool full_match_;
9719};
9720} // namespace internal
9721
9722// Matches a string that fully matches regular expression 'regex'.
9723// The matcher takes ownership of 'regex'.
9724inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
9725 const internal::RE* regex) {
9726 return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
9727}
9728inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
9729 const std::string& regex) {
9730 return MatchesRegex(new internal::RE(regex));
9731}
9732
9733// Matches a string that contains regular expression 'regex'.
9734// The matcher takes ownership of 'regex'.
9735inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
9736 const internal::RE* regex) {
9737 return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
9738}
9739inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
9740 const std::string& regex) {
9741 return ContainsRegex(new internal::RE(regex));
9742}
9743
9744// Creates a polymorphic matcher that matches anything equal to x.
9745// Note: if the parameter of Eq() were declared as const T&, Eq("foo")
9746// wouldn't compile.
9747template <typename T>
9748inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
9749
9750// Constructs a Matcher<T> from a 'value' of type T. The constructed
9751// matcher matches any value that's equal to 'value'.
9752template <typename T>
9753Matcher<T>::Matcher(T value) { *this = Eq(value); }
9754
9755// Creates a monomorphic matcher that matches anything with type Lhs
9756// and equal to rhs. A user may need to use this instead of Eq(...)
9757// in order to resolve an overloading ambiguity.
9758//
9759// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
9760// or Matcher<T>(x), but more readable than the latter.
9761//
9762// We could define similar monomorphic matchers for other comparison
9763// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
9764// it yet as those are used much less than Eq() in practice. A user
9765// can always write Matcher<T>(Lt(5)) to be explicit about the type,
9766// for example.
9767template <typename Lhs, typename Rhs>
9768inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
9769
9770// Creates a polymorphic matcher that matches anything >= x.
9771template <typename Rhs>
9772inline internal::GeMatcher<Rhs> Ge(Rhs x) {
9773 return internal::GeMatcher<Rhs>(x);
9774}
9775
9776// Creates a polymorphic matcher that matches anything > x.
9777template <typename Rhs>
9778inline internal::GtMatcher<Rhs> Gt(Rhs x) {
9779 return internal::GtMatcher<Rhs>(x);
9780}
9781
9782// Creates a polymorphic matcher that matches anything <= x.
9783template <typename Rhs>
9784inline internal::LeMatcher<Rhs> Le(Rhs x) {
9785 return internal::LeMatcher<Rhs>(x);
9786}
9787
9788// Creates a polymorphic matcher that matches anything < x.
9789template <typename Rhs>
9790inline internal::LtMatcher<Rhs> Lt(Rhs x) {
9791 return internal::LtMatcher<Rhs>(x);
9792}
9793
9794// Creates a polymorphic matcher that matches anything != x.
9795template <typename Rhs>
9796inline internal::NeMatcher<Rhs> Ne(Rhs x) {
9797 return internal::NeMatcher<Rhs>(x);
9798}
9799} // namespace testing
9800
9801GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 5046
9802
9803#endif // GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
9804
9805#include <stdio.h>
9806#include <memory>
9807
9808namespace testing {
9809namespace internal {
9810
9811GTEST_DECLARE_string_(internal_run_death_test);
9812
9813// Names of the flags (needed for parsing Google Test flags).
9814const char kDeathTestStyleFlag[] = "death_test_style";
9815const char kDeathTestUseFork[] = "death_test_use_fork";
9816const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
9817
9818#if GTEST_HAS_DEATH_TEST
9819
9820GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
9821/* class A needs to have dll-interface to be used by clients of class B */)
9822
9823// DeathTest is a class that hides much of the complexity of the
9824// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
9825// returns a concrete class that depends on the prevailing death test
9826// style, as defined by the --gtest_death_test_style and/or
9827// --gtest_internal_run_death_test flags.
9828
9829// In describing the results of death tests, these terms are used with
9830// the corresponding definitions:
9831//
9832// exit status: The integer exit information in the format specified
9833// by wait(2)
9834// exit code: The integer code passed to exit(3), _exit(2), or
9835// returned from main()
9836class GTEST_API_ DeathTest {
9837 public:
9838 // Create returns false if there was an error determining the
9839 // appropriate action to take for the current death test; for example,
9840 // if the gtest_death_test_style flag is set to an invalid value.
9841 // The LastMessage method will return a more detailed message in that
9842 // case. Otherwise, the DeathTest pointer pointed to by the "test"
9843 // argument is set. If the death test should be skipped, the pointer
9844 // is set to NULL; otherwise, it is set to the address of a new concrete
9845 // DeathTest object that controls the execution of the current test.
9846 static bool Create(const char* statement, Matcher<const std::string&> matcher,
9847 const char* file, int line, DeathTest** test);
9848 DeathTest();
9849 virtual ~DeathTest() { }
9850
9851 // A helper class that aborts a death test when it's deleted.
9852 class ReturnSentinel {
9853 public:
9854 explicit ReturnSentinel(DeathTest* test) : test_(test) { }
9855 ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
9856 private:
9857 DeathTest* const test_;
9858 GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
9859 } GTEST_ATTRIBUTE_UNUSED_;
9860
9861 // An enumeration of possible roles that may be taken when a death
9862 // test is encountered. EXECUTE means that the death test logic should
9863 // be executed immediately. OVERSEE means that the program should prepare
9864 // the appropriate environment for a child process to execute the death
9865 // test, then wait for it to complete.
9866 enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
9867
9868 // An enumeration of the three reasons that a test might be aborted.
9869 enum AbortReason {
9870 TEST_ENCOUNTERED_RETURN_STATEMENT,
9871 TEST_THREW_EXCEPTION,
9872 TEST_DID_NOT_DIE
9873 };
9874
9875 // Assumes one of the above roles.
9876 virtual TestRole AssumeRole() = 0;
9877
9878 // Waits for the death test to finish and returns its status.
9879 virtual int Wait() = 0;
9880
9881 // Returns true if the death test passed; that is, the test process
9882 // exited during the test, its exit status matches a user-supplied
9883 // predicate, and its stderr output matches a user-supplied regular
9884 // expression.
9885 // The user-supplied predicate may be a macro expression rather
9886 // than a function pointer or functor, or else Wait and Passed could
9887 // be combined.
9888 virtual bool Passed(bool exit_status_ok) = 0;
9889
9890 // Signals that the death test did not die as expected.
9891 virtual void Abort(AbortReason reason) = 0;
9892
9893 // Returns a human-readable outcome message regarding the outcome of
9894 // the last death test.
9895 static const char* LastMessage();
9896
9897 static void set_last_death_test_message(const std::string& message);
9898
9899 private:
9900 // A string containing a description of the outcome of the last death test.
9901 static std::string last_death_test_message_;
9902
9903 GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
9904};
9905
9906GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
9907
9908// Factory interface for death tests. May be mocked out for testing.
9909class DeathTestFactory {
9910 public:
9911 virtual ~DeathTestFactory() { }
9912 virtual bool Create(const char* statement,
9913 Matcher<const std::string&> matcher, const char* file,
9914 int line, DeathTest** test) = 0;
9915};
9916
9917// A concrete DeathTestFactory implementation for normal use.
9918class DefaultDeathTestFactory : public DeathTestFactory {
9919 public:
9920 bool Create(const char* statement, Matcher<const std::string&> matcher,
9921 const char* file, int line, DeathTest** test) override;
9922};
9923
9924// Returns true if exit_status describes a process that was terminated
9925// by a signal, or exited normally with a nonzero exit code.
9926GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
9927
9928// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
9929// and interpreted as a regex (rather than an Eq matcher) for legacy
9930// compatibility.
9931inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9932 ::testing::internal::RE regex) {
9933 return ContainsRegex(regex.pattern());
9934}
9935inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
9936 return ContainsRegex(regex);
9937}
9938inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9939 const ::std::string& regex) {
9940 return ContainsRegex(regex);
9941}
9942#if GTEST_HAS_GLOBAL_STRING
9943inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9944 const ::string& regex) {
9945 return ContainsRegex(regex);
9946}
9947#endif
9948
9949// If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
9950// used directly.
9951inline Matcher<const ::std::string&> MakeDeathTestMatcher(
9952 Matcher<const ::std::string&> matcher) {
9953 return matcher;
9954}
9955
9956// Traps C++ exceptions escaping statement and reports them as test
9957// failures. Note that trapping SEH exceptions is not implemented here.
9958# if GTEST_HAS_EXCEPTIONS
9959# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
9960 try { \
9961 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
9962 } catch (const ::std::exception& gtest_exception) { \
9963 fprintf(\
9964 stderr, \
9965 "\n%s: Caught std::exception-derived exception escaping the " \
9966 "death test statement. Exception message: %s\n", \
9967 ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
9968 gtest_exception.what()); \
9969 fflush(stderr); \
9970 death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
9971 } catch (...) { \
9972 death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
9973 }
9974
9975# else
9976# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
9977 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
9978
9979# endif
9980
9981// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
9982// ASSERT_EXIT*, and EXPECT_EXIT*.
9983#define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail) \
9984 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
9985 if (::testing::internal::AlwaysTrue()) { \
9986 ::testing::internal::DeathTest* gtest_dt; \
9987 if (!::testing::internal::DeathTest::Create( \
9988 #statement, \
9989 ::testing::internal::MakeDeathTestMatcher(regex_or_matcher), \
9990 __FILE__, __LINE__, &gtest_dt)) { \
9991 goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
9992 } \
9993 if (gtest_dt != nullptr) { \
9994 std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
9995 switch (gtest_dt->AssumeRole()) { \
9996 case ::testing::internal::DeathTest::OVERSEE_TEST: \
9997 if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
9998 goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
9999 } \
10000 break; \
10001 case ::testing::internal::DeathTest::EXECUTE_TEST: { \
10002 ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
10003 gtest_dt); \
10004 GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
10005 gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
10006 break; \
10007 } \
10008 default: \
10009 break; \
10010 } \
10011 } \
10012 } else \
10013 GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__) \
10014 : fail(::testing::internal::DeathTest::LastMessage())
10015// The symbol "fail" here expands to something into which a message
10016// can be streamed.
10017
10018// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
10019// NDEBUG mode. In this case we need the statements to be executed and the macro
10020// must accept a streamed message even though the message is never printed.
10021// The regex object is not evaluated, but it is used to prevent "unused"
10022// warnings and to avoid an expression that doesn't compile in debug mode.
10023#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \
10024 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
10025 if (::testing::internal::AlwaysTrue()) { \
10026 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
10027 } else if (!::testing::internal::AlwaysTrue()) { \
10028 ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
10029 } else \
10030 ::testing::Message()
10031
10032// A class representing the parsed contents of the
10033// --gtest_internal_run_death_test flag, as it existed when
10034// RUN_ALL_TESTS was called.
10035class InternalRunDeathTestFlag {
10036 public:
10037 InternalRunDeathTestFlag(const std::string& a_file,
10038 int a_line,
10039 int an_index,
10040 int a_write_fd)
10041 : file_(a_file), line_(a_line), index_(an_index),
10042 write_fd_(a_write_fd) {}
10043
10044 ~InternalRunDeathTestFlag() {
10045 if (write_fd_ >= 0)
10046 posix::Close(write_fd_);
10047 }
10048
10049 const std::string& file() const { return file_; }
10050 int line() const { return line_; }
10051 int index() const { return index_; }
10052 int write_fd() const { return write_fd_; }
10053
10054 private:
10055 std::string file_;
10056 int line_;
10057 int index_;
10058 int write_fd_;
10059
10060 GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
10061};
10062
10063// Returns a newly created InternalRunDeathTestFlag object with fields
10064// initialized from the GTEST_FLAG(internal_run_death_test) flag if
10065// the flag is specified; otherwise returns NULL.
10066InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
10067
10068#endif // GTEST_HAS_DEATH_TEST
10069
10070} // namespace internal
10071} // namespace testing
10072
10073#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
10074
10075namespace testing {
10076
10077// This flag controls the style of death tests. Valid values are "threadsafe",
10078// meaning that the death test child process will re-execute the test binary
10079// from the start, running only a single death test, or "fast",
10080// meaning that the child process will execute the test logic immediately
10081// after forking.
10082GTEST_DECLARE_string_(death_test_style);
10083
10084#if GTEST_HAS_DEATH_TEST
10085
10086namespace internal {
10087
10088// Returns a Boolean value indicating whether the caller is currently
10089// executing in the context of the death test child process. Tools such as
10090// Valgrind heap checkers may need this to modify their behavior in death
10091// tests. IMPORTANT: This is an internal utility. Using it may break the
10092// implementation of death tests. User code MUST NOT use it.
10093GTEST_API_ bool InDeathTestChild();
10094
10095} // namespace internal
10096
10097// The following macros are useful for writing death tests.
10098
10099// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
10100// executed:
10101//
10102// 1. It generates a warning if there is more than one active
10103// thread. This is because it's safe to fork() or clone() only
10104// when there is a single thread.
10105//
10106// 2. The parent process clone()s a sub-process and runs the death
10107// test in it; the sub-process exits with code 0 at the end of the
10108// death test, if it hasn't exited already.
10109//
10110// 3. The parent process waits for the sub-process to terminate.
10111//
10112// 4. The parent process checks the exit code and error message of
10113// the sub-process.
10114//
10115// Examples:
10116//
10117// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
10118// for (int i = 0; i < 5; i++) {
10119// EXPECT_DEATH(server.ProcessRequest(i),
10120// "Invalid request .* in ProcessRequest()")
10121// << "Failed to die on request " << i;
10122// }
10123//
10124// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
10125//
10126// bool KilledBySIGHUP(int exit_code) {
10127// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
10128// }
10129//
10130// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
10131//
10132// On the regular expressions used in death tests:
10133//
10134// GOOGLETEST_CM0005 DO NOT DELETE
10135// On POSIX-compliant systems (*nix), we use the <regex.h> library,
10136// which uses the POSIX extended regex syntax.
10137//
10138// On other platforms (e.g. Windows or Mac), we only support a simple regex
10139// syntax implemented as part of Google Test. This limited
10140// implementation should be enough most of the time when writing
10141// death tests; though it lacks many features you can find in PCRE
10142// or POSIX extended regex syntax. For example, we don't support
10143// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
10144// repetition count ("x{5,7}"), among others.
10145//
10146// Below is the syntax that we do support. We chose it to be a
10147// subset of both PCRE and POSIX extended regex, so it's easy to
10148// learn wherever you come from. In the following: 'A' denotes a
10149// literal character, period (.), or a single \\ escape sequence;
10150// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
10151// natural numbers.
10152//
10153// c matches any literal character c
10154// \\d matches any decimal digit
10155// \\D matches any character that's not a decimal digit
10156// \\f matches \f
10157// \\n matches \n
10158// \\r matches \r
10159// \\s matches any ASCII whitespace, including \n
10160// \\S matches any character that's not a whitespace
10161// \\t matches \t
10162// \\v matches \v
10163// \\w matches any letter, _, or decimal digit
10164// \\W matches any character that \\w doesn't match
10165// \\c matches any literal character c, which must be a punctuation
10166// . matches any single character except \n
10167// A? matches 0 or 1 occurrences of A
10168// A* matches 0 or many occurrences of A
10169// A+ matches 1 or many occurrences of A
10170// ^ matches the beginning of a string (not that of each line)
10171// $ matches the end of a string (not that of each line)
10172// xy matches x followed by y
10173//
10174// If you accidentally use PCRE or POSIX extended regex features
10175// not implemented by us, you will get a run-time failure. In that
10176// case, please try to rewrite your regular expression within the
10177// above syntax.
10178//
10179// This implementation is *not* meant to be as highly tuned or robust
10180// as a compiled regex library, but should perform well enough for a
10181// death test, which already incurs significant overhead by launching
10182// a child process.
10183//
10184// Known caveats:
10185//
10186// A "threadsafe" style death test obtains the path to the test
10187// program from argv[0] and re-executes it in the sub-process. For
10188// simplicity, the current implementation doesn't search the PATH
10189// when launching the sub-process. This means that the user must
10190// invoke the test program via a path that contains at least one
10191// path separator (e.g. path/to/foo_test and
10192// /absolute/path/to/bar_test are fine, but foo_test is not). This
10193// is rarely a problem as people usually don't put the test binary
10194// directory in PATH.
10195//
10196
10197// Asserts that a given statement causes the program to exit, with an
10198// integer exit status that satisfies predicate, and emitting error output
10199// that matches regex.
10200# define ASSERT_EXIT(statement, predicate, regex) \
10201 GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
10202
10203// Like ASSERT_EXIT, but continues on to successive tests in the
10204// test suite, if any:
10205# define EXPECT_EXIT(statement, predicate, regex) \
10206 GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
10207
10208// Asserts that a given statement causes the program to exit, either by
10209// explicitly exiting with a nonzero exit code or being killed by a
10210// signal, and emitting error output that matches regex.
10211# define ASSERT_DEATH(statement, regex) \
10212 ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
10213
10214// Like ASSERT_DEATH, but continues on to successive tests in the
10215// test suite, if any:
10216# define EXPECT_DEATH(statement, regex) \
10217 EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
10218
10219// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
10220
10221// Tests that an exit code describes a normal exit with a given exit code.
10222class GTEST_API_ ExitedWithCode {
10223 public:
10224 explicit ExitedWithCode(int exit_code);
10225 bool operator()(int exit_status) const;
10226 private:
10227 // No implementation - assignment is unsupported.
10228 void operator=(const ExitedWithCode& other);
10229
10230 const int exit_code_;
10231};
10232
10233# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
10234// Tests that an exit code describes an exit due to termination by a
10235// given signal.
10236// GOOGLETEST_CM0006 DO NOT DELETE
10237class GTEST_API_ KilledBySignal {
10238 public:
10239 explicit KilledBySignal(int signum);
10240 bool operator()(int exit_status) const;
10241 private:
10242 const int signum_;
10243};
10244# endif // !GTEST_OS_WINDOWS
10245
10246// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
10247// The death testing framework causes this to have interesting semantics,
10248// since the sideeffects of the call are only visible in opt mode, and not
10249// in debug mode.
10250//
10251// In practice, this can be used to test functions that utilize the
10252// LOG(DFATAL) macro using the following style:
10253//
10254// int DieInDebugOr12(int* sideeffect) {
10255// if (sideeffect) {
10256// *sideeffect = 12;
10257// }
10258// LOG(DFATAL) << "death";
10259// return 12;
10260// }
10261//
10262// TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) {
10263// int sideeffect = 0;
10264// // Only asserts in dbg.
10265// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
10266//
10267// #ifdef NDEBUG
10268// // opt-mode has sideeffect visible.
10269// EXPECT_EQ(12, sideeffect);
10270// #else
10271// // dbg-mode no visible sideeffect.
10272// EXPECT_EQ(0, sideeffect);
10273// #endif
10274// }
10275//
10276// This will assert that DieInDebugReturn12InOpt() crashes in debug
10277// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
10278// appropriate fallback value (12 in this case) in opt mode. If you
10279// need to test that a function has appropriate side-effects in opt
10280// mode, include assertions against the side-effects. A general
10281// pattern for this is:
10282//
10283// EXPECT_DEBUG_DEATH({
10284// // Side-effects here will have an effect after this statement in
10285// // opt mode, but none in debug mode.
10286// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
10287// }, "death");
10288//
10289# ifdef NDEBUG
10290
10291# define EXPECT_DEBUG_DEATH(statement, regex) \
10292 GTEST_EXECUTE_STATEMENT_(statement, regex)
10293
10294# define ASSERT_DEBUG_DEATH(statement, regex) \
10295 GTEST_EXECUTE_STATEMENT_(statement, regex)
10296
10297# else
10298
10299# define EXPECT_DEBUG_DEATH(statement, regex) \
10300 EXPECT_DEATH(statement, regex)
10301
10302# define ASSERT_DEBUG_DEATH(statement, regex) \
10303 ASSERT_DEATH(statement, regex)
10304
10305# endif // NDEBUG for EXPECT_DEBUG_DEATH
10306#endif // GTEST_HAS_DEATH_TEST
10307
10308// This macro is used for implementing macros such as
10309// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
10310// death tests are not supported. Those macros must compile on such systems
10311// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
10312// systems that support death tests. This allows one to write such a macro
10313// on a system that does not support death tests and be sure that it will
10314// compile on a death-test supporting system. It is exposed publicly so that
10315// systems that have death-tests with stricter requirements than
10316// GTEST_HAS_DEATH_TEST can write their own equivalent of
10317// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
10318//
10319// Parameters:
10320// statement - A statement that a macro such as EXPECT_DEATH would test
10321// for program termination. This macro has to make sure this
10322// statement is compiled but not executed, to ensure that
10323// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
10324// parameter iff EXPECT_DEATH compiles with it.
10325// regex - A regex that a macro such as EXPECT_DEATH would use to test
10326// the output of statement. This parameter has to be
10327// compiled but not evaluated by this macro, to ensure that
10328// this macro only accepts expressions that a macro such as
10329// EXPECT_DEATH would accept.
10330// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
10331// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
10332// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
10333// compile inside functions where ASSERT_DEATH doesn't
10334// compile.
10335//
10336// The branch that has an always false condition is used to ensure that
10337// statement and regex are compiled (and thus syntactically correct) but
10338// never executed. The unreachable code macro protects the terminator
10339// statement from generating an 'unreachable code' warning in case
10340// statement unconditionally returns or throws. The Message constructor at
10341// the end allows the syntax of streaming additional messages into the
10342// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
10343# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
10344 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
10345 if (::testing::internal::AlwaysTrue()) { \
10346 GTEST_LOG_(WARNING) \
10347 << "Death tests are not supported on this platform.\n" \
10348 << "Statement '" #statement "' cannot be verified."; \
10349 } else if (::testing::internal::AlwaysFalse()) { \
10350 ::testing::internal::RE::PartialMatch(".*", (regex)); \
10351 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
10352 terminator; \
10353 } else \
10354 ::testing::Message()
10355
10356// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
10357// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
10358// death tests are supported; otherwise they just issue a warning. This is
10359// useful when you are combining death test assertions with normal test
10360// assertions in one test.
10361#if GTEST_HAS_DEATH_TEST
10362# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
10363 EXPECT_DEATH(statement, regex)
10364# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
10365 ASSERT_DEATH(statement, regex)
10366#else
10367# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
10368 GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
10369# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
10370 GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
10371#endif
10372
10373} // namespace testing
10374
10375#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
10376// Copyright 2008, Google Inc.
10377// All rights reserved.
10378//
10379// Redistribution and use in source and binary forms, with or without
10380// modification, are permitted provided that the following conditions are
10381// met:
10382//
10383// * Redistributions of source code must retain the above copyright
10384// notice, this list of conditions and the following disclaimer.
10385// * Redistributions in binary form must reproduce the above
10386// copyright notice, this list of conditions and the following disclaimer
10387// in the documentation and/or other materials provided with the
10388// distribution.
10389// * Neither the name of Google Inc. nor the names of its
10390// contributors may be used to endorse or promote products derived from
10391// this software without specific prior written permission.
10392//
10393// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10394// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10395// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
10396// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10397// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10398// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10399// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10400// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
10401// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10402// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
10403// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10404//
10405// Macros and functions for implementing parameterized tests
10406// in Google C++ Testing and Mocking Framework (Google Test)
10407//
10408// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
10409//
10410// GOOGLETEST_CM0001 DO NOT DELETE
10411#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
10412#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
10413
10414
10415// Value-parameterized tests allow you to test your code with different
10416// parameters without writing multiple copies of the same test.
10417//
10418// Here is how you use value-parameterized tests:
10419
10420#if 0
10421
10422// To write value-parameterized tests, first you should define a fixture
10423// class. It is usually derived from testing::TestWithParam<T> (see below for
10424// another inheritance scheme that's sometimes useful in more complicated
10425// class hierarchies), where the type of your parameter values.
10426// TestWithParam<T> is itself derived from testing::Test. T can be any
10427// copyable type. If it's a raw pointer, you are responsible for managing the
10428// lifespan of the pointed values.
10429
10430class FooTest : public ::testing::TestWithParam<const char*> {
10431 // You can implement all the usual class fixture members here.
10432};
10433
10434// Then, use the TEST_P macro to define as many parameterized tests
10435// for this fixture as you want. The _P suffix is for "parameterized"
10436// or "pattern", whichever you prefer to think.
10437
10438TEST_P(FooTest, DoesBlah) {
10439 // Inside a test, access the test parameter with the GetParam() method
10440 // of the TestWithParam<T> class:
10441 EXPECT_TRUE(foo.Blah(GetParam()));
10442 ...
10443}
10444
10445TEST_P(FooTest, HasBlahBlah) {
10446 ...
10447}
10448
10449// Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test
10450// case with any set of parameters you want. Google Test defines a number
10451// of functions for generating test parameters. They return what we call
10452// (surprise!) parameter generators. Here is a summary of them, which
10453// are all in the testing namespace:
10454//
10455//
10456// Range(begin, end [, step]) - Yields values {begin, begin+step,
10457// begin+step+step, ...}. The values do not
10458// include end. step defaults to 1.
10459// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
10460// ValuesIn(container) - Yields values from a C-style array, an STL
10461// ValuesIn(begin,end) container, or an iterator range [begin, end).
10462// Bool() - Yields sequence {false, true}.
10463// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
10464// for the math savvy) of the values generated
10465// by the N generators.
10466//
10467// For more details, see comments at the definitions of these functions below
10468// in this file.
10469//
10470// The following statement will instantiate tests from the FooTest test suite
10471// each with parameter values "meeny", "miny", and "moe".
10472
10473INSTANTIATE_TEST_SUITE_P(InstantiationName,
10474 FooTest,
10475 Values("meeny", "miny", "moe"));
10476
10477// To distinguish different instances of the pattern, (yes, you
10478// can instantiate it more then once) the first argument to the
10479// INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the
10480// actual test suite name. Remember to pick unique prefixes for different
10481// instantiations. The tests from the instantiation above will have
10482// these names:
10483//
10484// * InstantiationName/FooTest.DoesBlah/0 for "meeny"
10485// * InstantiationName/FooTest.DoesBlah/1 for "miny"
10486// * InstantiationName/FooTest.DoesBlah/2 for "moe"
10487// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
10488// * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
10489// * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
10490//
10491// You can use these names in --gtest_filter.
10492//
10493// This statement will instantiate all tests from FooTest again, each
10494// with parameter values "cat" and "dog":
10495
10496const char* pets[] = {"cat", "dog"};
10497INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
10498
10499// The tests from the instantiation above will have these names:
10500//
10501// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
10502// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
10503// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
10504// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
10505//
10506// Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests
10507// in the given test suite, whether their definitions come before or
10508// AFTER the INSTANTIATE_TEST_SUITE_P statement.
10509//
10510// Please also note that generator expressions (including parameters to the
10511// generators) are evaluated in InitGoogleTest(), after main() has started.
10512// This allows the user on one hand, to adjust generator parameters in order
10513// to dynamically determine a set of tests to run and on the other hand,
10514// give the user a chance to inspect the generated tests with Google Test
10515// reflection API before RUN_ALL_TESTS() is executed.
10516//
10517// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
10518// for more examples.
10519//
10520// In the future, we plan to publish the API for defining new parameter
10521// generators. But for now this interface remains part of the internal
10522// implementation and is subject to change.
10523//
10524//
10525// A parameterized test fixture must be derived from testing::Test and from
10526// testing::WithParamInterface<T>, where T is the type of the parameter
10527// values. Inheriting from TestWithParam<T> satisfies that requirement because
10528// TestWithParam<T> inherits from both Test and WithParamInterface. In more
10529// complicated hierarchies, however, it is occasionally useful to inherit
10530// separately from Test and WithParamInterface. For example:
10531
10532class BaseTest : public ::testing::Test {
10533 // You can inherit all the usual members for a non-parameterized test
10534 // fixture here.
10535};
10536
10537class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
10538 // The usual test fixture members go here too.
10539};
10540
10541TEST_F(BaseTest, HasFoo) {
10542 // This is an ordinary non-parameterized test.
10543}
10544
10545TEST_P(DerivedTest, DoesBlah) {
10546 // GetParam works just the same here as if you inherit from TestWithParam.
10547 EXPECT_TRUE(foo.Blah(GetParam()));
10548}
10549
10550#endif // 0
10551
10552#include <utility>
10553
10554// Copyright 2008 Google Inc.
10555// All Rights Reserved.
10556//
10557// Redistribution and use in source and binary forms, with or without
10558// modification, are permitted provided that the following conditions are
10559// met:
10560//
10561// * Redistributions of source code must retain the above copyright
10562// notice, this list of conditions and the following disclaimer.
10563// * Redistributions in binary form must reproduce the above
10564// copyright notice, this list of conditions and the following disclaimer
10565// in the documentation and/or other materials provided with the
10566// distribution.
10567// * Neither the name of Google Inc. nor the names of its
10568// contributors may be used to endorse or promote products derived from
10569// this software without specific prior written permission.
10570//
10571// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10572// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10573// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
10574// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10575// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10576// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10577// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10578// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
10579// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10580// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
10581// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10582
10583
10584// Type and function utilities for implementing parameterized tests.
10585
10586// GOOGLETEST_CM0001 DO NOT DELETE
10587
10588#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
10589#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
10590
10591#include <ctype.h>
10592
10593#include <cassert>
10594#include <iterator>
10595#include <memory>
10596#include <set>
10597#include <tuple>
10598#include <utility>
10599#include <vector>
10600
10601
10602namespace testing {
Austin Schuh70cc9552019-01-21 19:46:48 -080010603// Input to a parameterized test name generator, describing a test parameter.
10604// Consists of the parameter value and the integer parameter index.
10605template <class ParamType>
10606struct TestParamInfo {
10607 TestParamInfo(const ParamType& a_param, size_t an_index) :
10608 param(a_param),
10609 index(an_index) {}
10610 ParamType param;
10611 size_t index;
10612};
10613
10614// A builtin parameterized test name generator which returns the result of
10615// testing::PrintToString.
10616struct PrintToStringParamName {
10617 template <class ParamType>
10618 std::string operator()(const TestParamInfo<ParamType>& info) const {
10619 return PrintToString(info.param);
10620 }
10621};
10622
10623namespace internal {
10624
10625// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010626// Utility Functions
10627
Austin Schuh70cc9552019-01-21 19:46:48 -080010628// Outputs a message explaining invalid registration of different
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010629// fixture class for the same test suite. This may happen when
Austin Schuh70cc9552019-01-21 19:46:48 -080010630// TEST_P macro is used to define two tests with the same name
10631// but in different namespaces.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010632GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
10633 CodeLocation code_location);
Austin Schuh70cc9552019-01-21 19:46:48 -080010634
10635template <typename> class ParamGeneratorInterface;
10636template <typename> class ParamGenerator;
10637
10638// Interface for iterating over elements provided by an implementation
10639// of ParamGeneratorInterface<T>.
10640template <typename T>
10641class ParamIteratorInterface {
10642 public:
10643 virtual ~ParamIteratorInterface() {}
10644 // A pointer to the base generator instance.
10645 // Used only for the purposes of iterator comparison
10646 // to make sure that two iterators belong to the same generator.
10647 virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
10648 // Advances iterator to point to the next element
10649 // provided by the generator. The caller is responsible
10650 // for not calling Advance() on an iterator equal to
10651 // BaseGenerator()->End().
10652 virtual void Advance() = 0;
10653 // Clones the iterator object. Used for implementing copy semantics
10654 // of ParamIterator<T>.
10655 virtual ParamIteratorInterface* Clone() const = 0;
10656 // Dereferences the current iterator and provides (read-only) access
10657 // to the pointed value. It is the caller's responsibility not to call
10658 // Current() on an iterator equal to BaseGenerator()->End().
10659 // Used for implementing ParamGenerator<T>::operator*().
10660 virtual const T* Current() const = 0;
10661 // Determines whether the given iterator and other point to the same
10662 // element in the sequence generated by the generator.
10663 // Used for implementing ParamGenerator<T>::operator==().
10664 virtual bool Equals(const ParamIteratorInterface& other) const = 0;
10665};
10666
10667// Class iterating over elements provided by an implementation of
10668// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
10669// and implements the const forward iterator concept.
10670template <typename T>
10671class ParamIterator {
10672 public:
10673 typedef T value_type;
10674 typedef const T& reference;
10675 typedef ptrdiff_t difference_type;
10676
10677 // ParamIterator assumes ownership of the impl_ pointer.
10678 ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
10679 ParamIterator& operator=(const ParamIterator& other) {
10680 if (this != &other)
10681 impl_.reset(other.impl_->Clone());
10682 return *this;
10683 }
10684
10685 const T& operator*() const { return *impl_->Current(); }
10686 const T* operator->() const { return impl_->Current(); }
10687 // Prefix version of operator++.
10688 ParamIterator& operator++() {
10689 impl_->Advance();
10690 return *this;
10691 }
10692 // Postfix version of operator++.
10693 ParamIterator operator++(int /*unused*/) {
10694 ParamIteratorInterface<T>* clone = impl_->Clone();
10695 impl_->Advance();
10696 return ParamIterator(clone);
10697 }
10698 bool operator==(const ParamIterator& other) const {
10699 return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
10700 }
10701 bool operator!=(const ParamIterator& other) const {
10702 return !(*this == other);
10703 }
10704
10705 private:
10706 friend class ParamGenerator<T>;
10707 explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010708 std::unique_ptr<ParamIteratorInterface<T> > impl_;
Austin Schuh70cc9552019-01-21 19:46:48 -080010709};
10710
10711// ParamGeneratorInterface<T> is the binary interface to access generators
10712// defined in other translation units.
10713template <typename T>
10714class ParamGeneratorInterface {
10715 public:
10716 typedef T ParamType;
10717
10718 virtual ~ParamGeneratorInterface() {}
10719
10720 // Generator interface definition
10721 virtual ParamIteratorInterface<T>* Begin() const = 0;
10722 virtual ParamIteratorInterface<T>* End() const = 0;
10723};
10724
10725// Wraps ParamGeneratorInterface<T> and provides general generator syntax
10726// compatible with the STL Container concept.
10727// This class implements copy initialization semantics and the contained
10728// ParamGeneratorInterface<T> instance is shared among all copies
10729// of the original object. This is possible because that instance is immutable.
10730template<typename T>
10731class ParamGenerator {
10732 public:
10733 typedef ParamIterator<T> iterator;
10734
10735 explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
10736 ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
10737
10738 ParamGenerator& operator=(const ParamGenerator& other) {
10739 impl_ = other.impl_;
10740 return *this;
10741 }
10742
10743 iterator begin() const { return iterator(impl_->Begin()); }
10744 iterator end() const { return iterator(impl_->End()); }
10745
10746 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010747 std::shared_ptr<const ParamGeneratorInterface<T> > impl_;
Austin Schuh70cc9552019-01-21 19:46:48 -080010748};
10749
10750// Generates values from a range of two comparable values. Can be used to
10751// generate sequences of user-defined types that implement operator+() and
10752// operator<().
10753// This class is used in the Range() function.
10754template <typename T, typename IncrementT>
10755class RangeGenerator : public ParamGeneratorInterface<T> {
10756 public:
10757 RangeGenerator(T begin, T end, IncrementT step)
10758 : begin_(begin), end_(end),
10759 step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010760 ~RangeGenerator() override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080010761
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010762 ParamIteratorInterface<T>* Begin() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010763 return new Iterator(this, begin_, 0, step_);
10764 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010765 ParamIteratorInterface<T>* End() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010766 return new Iterator(this, end_, end_index_, step_);
10767 }
10768
10769 private:
10770 class Iterator : public ParamIteratorInterface<T> {
10771 public:
10772 Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
10773 IncrementT step)
10774 : base_(base), value_(value), index_(index), step_(step) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010775 ~Iterator() override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080010776
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010777 const ParamGeneratorInterface<T>* BaseGenerator() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010778 return base_;
10779 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010780 void Advance() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010781 value_ = static_cast<T>(value_ + step_);
10782 index_++;
10783 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010784 ParamIteratorInterface<T>* Clone() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010785 return new Iterator(*this);
10786 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010787 const T* Current() const override { return &value_; }
10788 bool Equals(const ParamIteratorInterface<T>& other) const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010789 // Having the same base generator guarantees that the other
10790 // iterator is of the same type and we can downcast.
10791 GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
10792 << "The program attempted to compare iterators "
10793 << "from different generators." << std::endl;
10794 const int other_index =
10795 CheckedDowncastToActualType<const Iterator>(&other)->index_;
10796 return index_ == other_index;
10797 }
10798
10799 private:
10800 Iterator(const Iterator& other)
10801 : ParamIteratorInterface<T>(),
10802 base_(other.base_), value_(other.value_), index_(other.index_),
10803 step_(other.step_) {}
10804
10805 // No implementation - assignment is unsupported.
10806 void operator=(const Iterator& other);
10807
10808 const ParamGeneratorInterface<T>* const base_;
10809 T value_;
10810 int index_;
10811 const IncrementT step_;
10812 }; // class RangeGenerator::Iterator
10813
10814 static int CalculateEndIndex(const T& begin,
10815 const T& end,
10816 const IncrementT& step) {
10817 int end_index = 0;
10818 for (T i = begin; i < end; i = static_cast<T>(i + step))
10819 end_index++;
10820 return end_index;
10821 }
10822
10823 // No implementation - assignment is unsupported.
10824 void operator=(const RangeGenerator& other);
10825
10826 const T begin_;
10827 const T end_;
10828 const IncrementT step_;
10829 // The index for the end() iterator. All the elements in the generated
10830 // sequence are indexed (0-based) to aid iterator comparison.
10831 const int end_index_;
10832}; // class RangeGenerator
10833
10834
10835// Generates values from a pair of STL-style iterators. Used in the
10836// ValuesIn() function. The elements are copied from the source range
10837// since the source can be located on the stack, and the generator
10838// is likely to persist beyond that stack frame.
10839template <typename T>
10840class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
10841 public:
10842 template <typename ForwardIterator>
10843 ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
10844 : container_(begin, end) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010845 ~ValuesInIteratorRangeGenerator() override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080010846
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010847 ParamIteratorInterface<T>* Begin() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010848 return new Iterator(this, container_.begin());
10849 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010850 ParamIteratorInterface<T>* End() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010851 return new Iterator(this, container_.end());
10852 }
10853
10854 private:
10855 typedef typename ::std::vector<T> ContainerType;
10856
10857 class Iterator : public ParamIteratorInterface<T> {
10858 public:
10859 Iterator(const ParamGeneratorInterface<T>* base,
10860 typename ContainerType::const_iterator iterator)
10861 : base_(base), iterator_(iterator) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010862 ~Iterator() override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080010863
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010864 const ParamGeneratorInterface<T>* BaseGenerator() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010865 return base_;
10866 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010867 void Advance() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010868 ++iterator_;
10869 value_.reset();
10870 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010871 ParamIteratorInterface<T>* Clone() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010872 return new Iterator(*this);
10873 }
10874 // We need to use cached value referenced by iterator_ because *iterator_
10875 // can return a temporary object (and of type other then T), so just
10876 // having "return &*iterator_;" doesn't work.
10877 // value_ is updated here and not in Advance() because Advance()
10878 // can advance iterator_ beyond the end of the range, and we cannot
10879 // detect that fact. The client code, on the other hand, is
10880 // responsible for not calling Current() on an out-of-range iterator.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010881 const T* Current() const override {
10882 if (value_.get() == nullptr) value_.reset(new T(*iterator_));
Austin Schuh70cc9552019-01-21 19:46:48 -080010883 return value_.get();
10884 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010885 bool Equals(const ParamIteratorInterface<T>& other) const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010886 // Having the same base generator guarantees that the other
10887 // iterator is of the same type and we can downcast.
10888 GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
10889 << "The program attempted to compare iterators "
10890 << "from different generators." << std::endl;
10891 return iterator_ ==
10892 CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
10893 }
10894
10895 private:
10896 Iterator(const Iterator& other)
10897 // The explicit constructor call suppresses a false warning
10898 // emitted by gcc when supplied with the -Wextra option.
10899 : ParamIteratorInterface<T>(),
10900 base_(other.base_),
10901 iterator_(other.iterator_) {}
10902
10903 const ParamGeneratorInterface<T>* const base_;
10904 typename ContainerType::const_iterator iterator_;
10905 // A cached value of *iterator_. We keep it here to allow access by
10906 // pointer in the wrapping iterator's operator->().
10907 // value_ needs to be mutable to be accessed in Current().
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010908 // Use of std::unique_ptr helps manage cached value's lifetime,
Austin Schuh70cc9552019-01-21 19:46:48 -080010909 // which is bound by the lifespan of the iterator itself.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010910 mutable std::unique_ptr<const T> value_;
Austin Schuh70cc9552019-01-21 19:46:48 -080010911 }; // class ValuesInIteratorRangeGenerator::Iterator
10912
10913 // No implementation - assignment is unsupported.
10914 void operator=(const ValuesInIteratorRangeGenerator& other);
10915
10916 const ContainerType container_;
10917}; // class ValuesInIteratorRangeGenerator
10918
10919// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10920//
10921// Default parameterized test name generator, returns a string containing the
10922// integer test parameter index.
10923template <class ParamType>
10924std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
10925 Message name_stream;
10926 name_stream << info.index;
10927 return name_stream.GetString();
10928}
10929
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010930template <typename T = int>
10931void TestNotEmpty() {
10932 static_assert(sizeof(T) == 0, "Empty arguments are not allowed.");
Austin Schuh70cc9552019-01-21 19:46:48 -080010933}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010934template <typename T = int>
10935void TestNotEmpty(const T&) {}
Austin Schuh70cc9552019-01-21 19:46:48 -080010936
10937// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10938//
10939// Stores a parameter value and later creates tests parameterized with that
10940// value.
10941template <class TestClass>
10942class ParameterizedTestFactory : public TestFactoryBase {
10943 public:
10944 typedef typename TestClass::ParamType ParamType;
10945 explicit ParameterizedTestFactory(ParamType parameter) :
10946 parameter_(parameter) {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010947 Test* CreateTest() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080010948 TestClass::SetParam(&parameter_);
10949 return new TestClass();
10950 }
10951
10952 private:
10953 const ParamType parameter_;
10954
10955 GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
10956};
10957
10958// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10959//
10960// TestMetaFactoryBase is a base class for meta-factories that create
10961// test factories for passing into MakeAndRegisterTestInfo function.
10962template <class ParamType>
10963class TestMetaFactoryBase {
10964 public:
10965 virtual ~TestMetaFactoryBase() {}
10966
10967 virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
10968};
10969
10970// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10971//
10972// TestMetaFactory creates test factories for passing into
10973// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
10974// ownership of test factory pointer, same factory object cannot be passed
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010975// into that method twice. But ParameterizedTestSuiteInfo is going to call
Austin Schuh70cc9552019-01-21 19:46:48 -080010976// it for each Test/Parameter value combination. Thus it needs meta factory
10977// creator class.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010978template <class TestSuite>
Austin Schuh70cc9552019-01-21 19:46:48 -080010979class TestMetaFactory
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010980 : public TestMetaFactoryBase<typename TestSuite::ParamType> {
Austin Schuh70cc9552019-01-21 19:46:48 -080010981 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010982 using ParamType = typename TestSuite::ParamType;
Austin Schuh70cc9552019-01-21 19:46:48 -080010983
10984 TestMetaFactory() {}
10985
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010986 TestFactoryBase* CreateTestFactory(ParamType parameter) override {
10987 return new ParameterizedTestFactory<TestSuite>(parameter);
Austin Schuh70cc9552019-01-21 19:46:48 -080010988 }
10989
10990 private:
10991 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
10992};
10993
10994// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
10995//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010996// ParameterizedTestSuiteInfoBase is a generic interface
10997// to ParameterizedTestSuiteInfo classes. ParameterizedTestSuiteInfoBase
Austin Schuh70cc9552019-01-21 19:46:48 -080010998// accumulates test information provided by TEST_P macro invocations
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080010999// and generators provided by INSTANTIATE_TEST_SUITE_P macro invocations
Austin Schuh70cc9552019-01-21 19:46:48 -080011000// and uses that information to register all resulting test instances
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011001// in RegisterTests method. The ParameterizeTestSuiteRegistry class holds
11002// a collection of pointers to the ParameterizedTestSuiteInfo objects
Austin Schuh70cc9552019-01-21 19:46:48 -080011003// and calls RegisterTests() on each of them when asked.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011004class ParameterizedTestSuiteInfoBase {
Austin Schuh70cc9552019-01-21 19:46:48 -080011005 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011006 virtual ~ParameterizedTestSuiteInfoBase() {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011007
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011008 // Base part of test suite name for display purposes.
11009 virtual const std::string& GetTestSuiteName() const = 0;
Austin Schuh70cc9552019-01-21 19:46:48 -080011010 // Test case id to verify identity.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011011 virtual TypeId GetTestSuiteTypeId() const = 0;
Austin Schuh70cc9552019-01-21 19:46:48 -080011012 // UnitTest class invokes this method to register tests in this
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011013 // test suite right before running them in RUN_ALL_TESTS macro.
Austin Schuh70cc9552019-01-21 19:46:48 -080011014 // This method should not be called more then once on any single
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011015 // instance of a ParameterizedTestSuiteInfoBase derived class.
Austin Schuh70cc9552019-01-21 19:46:48 -080011016 virtual void RegisterTests() = 0;
11017
11018 protected:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011019 ParameterizedTestSuiteInfoBase() {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011020
11021 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011022 GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);
Austin Schuh70cc9552019-01-21 19:46:48 -080011023};
11024
11025// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
11026//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011027// ParameterizedTestSuiteInfo accumulates tests obtained from TEST_P
11028// macro invocations for a particular test suite and generators
11029// obtained from INSTANTIATE_TEST_SUITE_P macro invocations for that
11030// test suite. It registers tests with all values generated by all
Austin Schuh70cc9552019-01-21 19:46:48 -080011031// generators when asked.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011032template <class TestSuite>
11033class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
Austin Schuh70cc9552019-01-21 19:46:48 -080011034 public:
11035 // ParamType and GeneratorCreationFunc are private types but are required
11036 // for declarations of public methods AddTestPattern() and
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011037 // AddTestSuiteInstantiation().
11038 using ParamType = typename TestSuite::ParamType;
Austin Schuh70cc9552019-01-21 19:46:48 -080011039 // A function that returns an instance of appropriate generator type.
11040 typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011041 using ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&);
Austin Schuh70cc9552019-01-21 19:46:48 -080011042
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011043 explicit ParameterizedTestSuiteInfo(const char* name,
11044 CodeLocation code_location)
11045 : test_suite_name_(name), code_location_(code_location) {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011046
11047 // Test case base name for display purposes.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011048 const std::string& GetTestSuiteName() const override {
11049 return test_suite_name_;
11050 }
Austin Schuh70cc9552019-01-21 19:46:48 -080011051 // Test case id to verify identity.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011052 TypeId GetTestSuiteTypeId() const override { return GetTypeId<TestSuite>(); }
Austin Schuh70cc9552019-01-21 19:46:48 -080011053 // TEST_P macro uses AddTestPattern() to record information
11054 // about a single test in a LocalTestInfo structure.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011055 // test_suite_name is the base name of the test suite (without invocation
Austin Schuh70cc9552019-01-21 19:46:48 -080011056 // prefix). test_base_name is the name of an individual test without
11057 // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011058 // test suite base name and DoBar is test base name.
11059 void AddTestPattern(const char* test_suite_name, const char* test_base_name,
Austin Schuh70cc9552019-01-21 19:46:48 -080011060 TestMetaFactoryBase<ParamType>* meta_factory) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011061 tests_.push_back(std::shared_ptr<TestInfo>(
11062 new TestInfo(test_suite_name, test_base_name, meta_factory)));
Austin Schuh70cc9552019-01-21 19:46:48 -080011063 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011064 // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
Austin Schuh70cc9552019-01-21 19:46:48 -080011065 // about a generator.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011066 int AddTestSuiteInstantiation(const std::string& instantiation_name,
11067 GeneratorCreationFunc* func,
11068 ParamNameGeneratorFunc* name_func,
11069 const char* file, int line) {
Austin Schuh70cc9552019-01-21 19:46:48 -080011070 instantiations_.push_back(
11071 InstantiationInfo(instantiation_name, func, name_func, file, line));
11072 return 0; // Return value used only to run this method in namespace scope.
11073 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011074 // UnitTest class invokes this method to register tests in this test suite
11075 // test suites right before running tests in RUN_ALL_TESTS macro.
Austin Schuh70cc9552019-01-21 19:46:48 -080011076 // This method should not be called more then once on any single
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011077 // instance of a ParameterizedTestSuiteInfoBase derived class.
Austin Schuh70cc9552019-01-21 19:46:48 -080011078 // UnitTest has a guard to prevent from calling this method more then once.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011079 void RegisterTests() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080011080 for (typename TestInfoContainer::iterator test_it = tests_.begin();
11081 test_it != tests_.end(); ++test_it) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011082 std::shared_ptr<TestInfo> test_info = *test_it;
Austin Schuh70cc9552019-01-21 19:46:48 -080011083 for (typename InstantiationContainer::iterator gen_it =
11084 instantiations_.begin(); gen_it != instantiations_.end();
11085 ++gen_it) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011086 const std::string& instantiation_name = gen_it->name;
Austin Schuh70cc9552019-01-21 19:46:48 -080011087 ParamGenerator<ParamType> generator((*gen_it->generator)());
11088 ParamNameGeneratorFunc* name_func = gen_it->name_func;
11089 const char* file = gen_it->file;
11090 int line = gen_it->line;
11091
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011092 std::string test_suite_name;
Austin Schuh70cc9552019-01-21 19:46:48 -080011093 if ( !instantiation_name.empty() )
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011094 test_suite_name = instantiation_name + "/";
11095 test_suite_name += test_info->test_suite_base_name;
Austin Schuh70cc9552019-01-21 19:46:48 -080011096
11097 size_t i = 0;
11098 std::set<std::string> test_param_names;
11099 for (typename ParamGenerator<ParamType>::iterator param_it =
11100 generator.begin();
11101 param_it != generator.end(); ++param_it, ++i) {
11102 Message test_name_stream;
11103
11104 std::string param_name = name_func(
11105 TestParamInfo<ParamType>(*param_it, i));
11106
11107 GTEST_CHECK_(IsValidParamName(param_name))
11108 << "Parameterized test name '" << param_name
11109 << "' is invalid, in " << file
11110 << " line " << line << std::endl;
11111
11112 GTEST_CHECK_(test_param_names.count(param_name) == 0)
11113 << "Duplicate parameterized test name '" << param_name
11114 << "', in " << file << " line " << line << std::endl;
11115
11116 test_param_names.insert(param_name);
11117
11118 test_name_stream << test_info->test_base_name << "/" << param_name;
11119 MakeAndRegisterTestInfo(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011120 test_suite_name.c_str(), test_name_stream.GetString().c_str(),
11121 nullptr, // No type parameter.
11122 PrintToString(*param_it).c_str(), code_location_,
11123 GetTestSuiteTypeId(),
11124 SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(),
11125 SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(),
Austin Schuh70cc9552019-01-21 19:46:48 -080011126 test_info->test_meta_factory->CreateTestFactory(*param_it));
11127 } // for param_it
11128 } // for gen_it
11129 } // for test_it
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011130 } // RegisterTests
Austin Schuh70cc9552019-01-21 19:46:48 -080011131
11132 private:
11133 // LocalTestInfo structure keeps information about a single test registered
11134 // with TEST_P macro.
11135 struct TestInfo {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011136 TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
11137 TestMetaFactoryBase<ParamType>* a_test_meta_factory)
11138 : test_suite_base_name(a_test_suite_base_name),
11139 test_base_name(a_test_base_name),
11140 test_meta_factory(a_test_meta_factory) {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011141
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011142 const std::string test_suite_base_name;
11143 const std::string test_base_name;
11144 const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
Austin Schuh70cc9552019-01-21 19:46:48 -080011145 };
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011146 using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;
11147 // Records data received from INSTANTIATE_TEST_SUITE_P macros:
Austin Schuh70cc9552019-01-21 19:46:48 -080011148 // <Instantiation name, Sequence generator creation function,
11149 // Name generator function, Source file, Source line>
11150 struct InstantiationInfo {
11151 InstantiationInfo(const std::string &name_in,
11152 GeneratorCreationFunc* generator_in,
11153 ParamNameGeneratorFunc* name_func_in,
11154 const char* file_in,
11155 int line_in)
11156 : name(name_in),
11157 generator(generator_in),
11158 name_func(name_func_in),
11159 file(file_in),
11160 line(line_in) {}
11161
11162 std::string name;
11163 GeneratorCreationFunc* generator;
11164 ParamNameGeneratorFunc* name_func;
11165 const char* file;
11166 int line;
11167 };
11168 typedef ::std::vector<InstantiationInfo> InstantiationContainer;
11169
11170 static bool IsValidParamName(const std::string& name) {
11171 // Check for empty string
11172 if (name.empty())
11173 return false;
11174
11175 // Check for invalid characters
11176 for (std::string::size_type index = 0; index < name.size(); ++index) {
11177 if (!isalnum(name[index]) && name[index] != '_')
11178 return false;
11179 }
11180
11181 return true;
11182 }
11183
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011184 const std::string test_suite_name_;
Austin Schuh70cc9552019-01-21 19:46:48 -080011185 CodeLocation code_location_;
11186 TestInfoContainer tests_;
11187 InstantiationContainer instantiations_;
11188
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011189 GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);
11190}; // class ParameterizedTestSuiteInfo
11191
11192// Legacy API is deprecated but still available
11193#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11194template <class TestCase>
11195using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
11196#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080011197
11198// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
11199//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011200// ParameterizedTestSuiteRegistry contains a map of
11201// ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P
11202// and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding
11203// ParameterizedTestSuiteInfo descriptors.
11204class ParameterizedTestSuiteRegistry {
Austin Schuh70cc9552019-01-21 19:46:48 -080011205 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011206 ParameterizedTestSuiteRegistry() {}
11207 ~ParameterizedTestSuiteRegistry() {
11208 for (auto& test_suite_info : test_suite_infos_) {
11209 delete test_suite_info;
Austin Schuh70cc9552019-01-21 19:46:48 -080011210 }
11211 }
11212
11213 // Looks up or creates and returns a structure containing information about
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011214 // tests and instantiations of a particular test suite.
11215 template <class TestSuite>
11216 ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(
11217 const char* test_suite_name, CodeLocation code_location) {
11218 ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;
11219 for (auto& test_suite_info : test_suite_infos_) {
11220 if (test_suite_info->GetTestSuiteName() == test_suite_name) {
11221 if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
Austin Schuh70cc9552019-01-21 19:46:48 -080011222 // Complain about incorrect usage of Google Test facilities
11223 // and terminate the program since we cannot guaranty correct
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011224 // test suite setup and tear-down in this case.
11225 ReportInvalidTestSuiteType(test_suite_name, code_location);
Austin Schuh70cc9552019-01-21 19:46:48 -080011226 posix::Abort();
11227 } else {
11228 // At this point we are sure that the object we found is of the same
11229 // type we are looking for, so we downcast it to that type
11230 // without further checks.
11231 typed_test_info = CheckedDowncastToActualType<
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011232 ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);
Austin Schuh70cc9552019-01-21 19:46:48 -080011233 }
11234 break;
11235 }
11236 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011237 if (typed_test_info == nullptr) {
11238 typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(
11239 test_suite_name, code_location);
11240 test_suite_infos_.push_back(typed_test_info);
Austin Schuh70cc9552019-01-21 19:46:48 -080011241 }
11242 return typed_test_info;
11243 }
11244 void RegisterTests() {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011245 for (auto& test_suite_info : test_suite_infos_) {
11246 test_suite_info->RegisterTests();
Austin Schuh70cc9552019-01-21 19:46:48 -080011247 }
11248 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011249// Legacy API is deprecated but still available
11250#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11251 template <class TestCase>
11252 ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
11253 const char* test_case_name, CodeLocation code_location) {
11254 return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);
11255 }
11256
11257#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080011258
11259 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011260 using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;
Austin Schuh70cc9552019-01-21 19:46:48 -080011261
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011262 TestSuiteInfoContainer test_suite_infos_;
Austin Schuh70cc9552019-01-21 19:46:48 -080011263
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011264 GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);
Austin Schuh70cc9552019-01-21 19:46:48 -080011265};
11266
11267} // namespace internal
Austin Schuh70cc9552019-01-21 19:46:48 -080011268
11269// Forward declarations of ValuesIn(), which is implemented in
11270// include/gtest/gtest-param-test.h.
Austin Schuh70cc9552019-01-21 19:46:48 -080011271template <class Container>
11272internal::ParamGenerator<typename Container::value_type> ValuesIn(
11273 const Container& container);
11274
11275namespace internal {
Austin Schuh70cc9552019-01-21 19:46:48 -080011276// Used in the Values() function to provide polymorphic capabilities.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011277
11278template <typename... Ts>
11279class ValueArray {
Austin Schuh70cc9552019-01-21 19:46:48 -080011280 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011281 ValueArray(Ts... v) : v_{std::move(v)...} {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011282
11283 template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011284 operator ParamGenerator<T>() const { // NOLINT
11285 return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
Austin Schuh70cc9552019-01-21 19:46:48 -080011286 }
11287
11288 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011289 template <typename T, size_t... I>
11290 std::vector<T> MakeVector(IndexSequence<I...>) const {
11291 return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
11292 }
Austin Schuh70cc9552019-01-21 19:46:48 -080011293
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011294 FlatTuple<Ts...> v_;
Austin Schuh70cc9552019-01-21 19:46:48 -080011295};
11296
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011297template <typename... T>
11298class CartesianProductGenerator
11299 : public ParamGeneratorInterface<::std::tuple<T...>> {
Austin Schuh70cc9552019-01-21 19:46:48 -080011300 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011301 typedef ::std::tuple<T...> ParamType;
Austin Schuh70cc9552019-01-21 19:46:48 -080011302
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011303 CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
11304 : generators_(g) {}
11305 ~CartesianProductGenerator() override {}
11306
11307 ParamIteratorInterface<ParamType>* Begin() const override {
11308 return new Iterator(this, generators_, false);
11309 }
11310 ParamIteratorInterface<ParamType>* End() const override {
11311 return new Iterator(this, generators_, true);
Austin Schuh70cc9552019-01-21 19:46:48 -080011312 }
11313
11314 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011315 template <class I>
11316 class IteratorImpl;
11317 template <size_t... I>
11318 class IteratorImpl<IndexSequence<I...>>
11319 : public ParamIteratorInterface<ParamType> {
Austin Schuh70cc9552019-01-21 19:46:48 -080011320 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011321 IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
11322 const std::tuple<ParamGenerator<T>...>& generators, bool is_end)
Austin Schuh70cc9552019-01-21 19:46:48 -080011323 : base_(base),
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011324 begin_(std::get<I>(generators).begin()...),
11325 end_(std::get<I>(generators).end()...),
11326 current_(is_end ? end_ : begin_) {
Austin Schuh70cc9552019-01-21 19:46:48 -080011327 ComputeCurrentValue();
11328 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011329 ~IteratorImpl() override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011330
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011331 const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080011332 return base_;
11333 }
11334 // Advance should not be called on beyond-of-range iterators
11335 // so no component iterators must be beyond end of range, either.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011336 void Advance() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080011337 assert(!AtEnd());
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011338 // Advance the last iterator.
11339 ++std::get<sizeof...(T) - 1>(current_);
11340 // if that reaches end, propagate that up.
11341 AdvanceIfEnd<sizeof...(T) - 1>();
Austin Schuh70cc9552019-01-21 19:46:48 -080011342 ComputeCurrentValue();
11343 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011344 ParamIteratorInterface<ParamType>* Clone() const override {
11345 return new IteratorImpl(*this);
Austin Schuh70cc9552019-01-21 19:46:48 -080011346 }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011347
11348 const ParamType* Current() const override { return current_value_.get(); }
11349
11350 bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
Austin Schuh70cc9552019-01-21 19:46:48 -080011351 // Having the same base generator guarantees that the other
11352 // iterator is of the same type and we can downcast.
11353 GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
11354 << "The program attempted to compare iterators "
11355 << "from different generators." << std::endl;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011356 const IteratorImpl* typed_other =
11357 CheckedDowncastToActualType<const IteratorImpl>(&other);
11358
Austin Schuh70cc9552019-01-21 19:46:48 -080011359 // We must report iterators equal if they both point beyond their
11360 // respective ranges. That can happen in a variety of fashions,
11361 // so we have to consult AtEnd().
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011362 if (AtEnd() && typed_other->AtEnd()) return true;
11363
11364 bool same = true;
11365 bool dummy[] = {
11366 (same = same && std::get<I>(current_) ==
11367 std::get<I>(typed_other->current_))...};
11368 (void)dummy;
11369 return same;
Austin Schuh70cc9552019-01-21 19:46:48 -080011370 }
11371
11372 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011373 template <size_t ThisI>
11374 void AdvanceIfEnd() {
11375 if (std::get<ThisI>(current_) != std::get<ThisI>(end_)) return;
11376
11377 bool last = ThisI == 0;
11378 if (last) {
11379 // We are done. Nothing else to propagate.
11380 return;
11381 }
11382
11383 constexpr size_t NextI = ThisI - (ThisI != 0);
11384 std::get<ThisI>(current_) = std::get<ThisI>(begin_);
11385 ++std::get<NextI>(current_);
11386 AdvanceIfEnd<NextI>();
Austin Schuh70cc9552019-01-21 19:46:48 -080011387 }
11388
11389 void ComputeCurrentValue() {
11390 if (!AtEnd())
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011391 current_value_ = std::make_shared<ParamType>(*std::get<I>(current_)...);
Austin Schuh70cc9552019-01-21 19:46:48 -080011392 }
11393 bool AtEnd() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011394 bool at_end = false;
11395 bool dummy[] = {
11396 (at_end = at_end || std::get<I>(current_) == std::get<I>(end_))...};
11397 (void)dummy;
11398 return at_end;
Austin Schuh70cc9552019-01-21 19:46:48 -080011399 }
11400
Austin Schuh70cc9552019-01-21 19:46:48 -080011401 const ParamGeneratorInterface<ParamType>* const base_;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011402 std::tuple<typename ParamGenerator<T>::iterator...> begin_;
11403 std::tuple<typename ParamGenerator<T>::iterator...> end_;
11404 std::tuple<typename ParamGenerator<T>::iterator...> current_;
11405 std::shared_ptr<ParamType> current_value_;
11406 };
Austin Schuh70cc9552019-01-21 19:46:48 -080011407
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011408 using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;
Austin Schuh70cc9552019-01-21 19:46:48 -080011409
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011410 std::tuple<ParamGenerator<T>...> generators_;
11411};
Austin Schuh70cc9552019-01-21 19:46:48 -080011412
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011413template <class... Gen>
11414class CartesianProductHolder {
Austin Schuh70cc9552019-01-21 19:46:48 -080011415 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011416 CartesianProductHolder(const Gen&... g) : generators_(g...) {}
11417 template <typename... T>
11418 operator ParamGenerator<::std::tuple<T...>>() const {
11419 return ParamGenerator<::std::tuple<T...>>(
11420 new CartesianProductGenerator<T...>(generators_));
Austin Schuh70cc9552019-01-21 19:46:48 -080011421 }
11422
11423 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011424 std::tuple<Gen...> generators_;
11425};
Austin Schuh70cc9552019-01-21 19:46:48 -080011426
11427} // namespace internal
11428} // namespace testing
11429
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011430#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
Austin Schuh70cc9552019-01-21 19:46:48 -080011431
11432namespace testing {
11433
11434// Functions producing parameter generators.
11435//
11436// Google Test uses these generators to produce parameters for value-
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011437// parameterized tests. When a parameterized test suite is instantiated
Austin Schuh70cc9552019-01-21 19:46:48 -080011438// with a particular generator, Google Test creates and runs tests
11439// for each element in the sequence produced by the generator.
11440//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011441// In the following sample, tests from test suite FooTest are instantiated
Austin Schuh70cc9552019-01-21 19:46:48 -080011442// each three times with parameter values 3, 5, and 8:
11443//
11444// class FooTest : public TestWithParam<int> { ... };
11445//
11446// TEST_P(FooTest, TestThis) {
11447// }
11448// TEST_P(FooTest, TestThat) {
11449// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011450// INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8));
Austin Schuh70cc9552019-01-21 19:46:48 -080011451//
11452
11453// Range() returns generators providing sequences of values in a range.
11454//
11455// Synopsis:
11456// Range(start, end)
11457// - returns a generator producing a sequence of values {start, start+1,
11458// start+2, ..., }.
11459// Range(start, end, step)
11460// - returns a generator producing a sequence of values {start, start+step,
11461// start+step+step, ..., }.
11462// Notes:
11463// * The generated sequences never include end. For example, Range(1, 5)
11464// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
11465// returns a generator producing {1, 3, 5, 7}.
11466// * start and end must have the same type. That type may be any integral or
11467// floating-point type or a user defined type satisfying these conditions:
11468// * It must be assignable (have operator=() defined).
11469// * It must have operator+() (operator+(int-compatible type) for
11470// two-operand version).
11471// * It must have operator<() defined.
11472// Elements in the resulting sequences will also have that type.
11473// * Condition start < end must be satisfied in order for resulting sequences
11474// to contain any elements.
11475//
11476template <typename T, typename IncrementT>
11477internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
11478 return internal::ParamGenerator<T>(
11479 new internal::RangeGenerator<T, IncrementT>(start, end, step));
11480}
11481
11482template <typename T>
11483internal::ParamGenerator<T> Range(T start, T end) {
11484 return Range(start, end, 1);
11485}
11486
11487// ValuesIn() function allows generation of tests with parameters coming from
11488// a container.
11489//
11490// Synopsis:
11491// ValuesIn(const T (&array)[N])
11492// - returns a generator producing sequences with elements from
11493// a C-style array.
11494// ValuesIn(const Container& container)
11495// - returns a generator producing sequences with elements from
11496// an STL-style container.
11497// ValuesIn(Iterator begin, Iterator end)
11498// - returns a generator producing sequences with elements from
11499// a range [begin, end) defined by a pair of STL-style iterators. These
11500// iterators can also be plain C pointers.
11501//
11502// Please note that ValuesIn copies the values from the containers
11503// passed in and keeps them to generate tests in RUN_ALL_TESTS().
11504//
11505// Examples:
11506//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011507// This instantiates tests from test suite StringTest
Austin Schuh70cc9552019-01-21 19:46:48 -080011508// each with C-string values of "foo", "bar", and "baz":
11509//
11510// const char* strings[] = {"foo", "bar", "baz"};
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011511// INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));
Austin Schuh70cc9552019-01-21 19:46:48 -080011512//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011513// This instantiates tests from test suite StlStringTest
Austin Schuh70cc9552019-01-21 19:46:48 -080011514// each with STL strings with values "a" and "b":
11515//
11516// ::std::vector< ::std::string> GetParameterStrings() {
11517// ::std::vector< ::std::string> v;
11518// v.push_back("a");
11519// v.push_back("b");
11520// return v;
11521// }
11522//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011523// INSTANTIATE_TEST_SUITE_P(CharSequence,
11524// StlStringTest,
11525// ValuesIn(GetParameterStrings()));
Austin Schuh70cc9552019-01-21 19:46:48 -080011526//
11527//
11528// This will also instantiate tests from CharTest
11529// each with parameter values 'a' and 'b':
11530//
11531// ::std::list<char> GetParameterChars() {
11532// ::std::list<char> list;
11533// list.push_back('a');
11534// list.push_back('b');
11535// return list;
11536// }
11537// ::std::list<char> l = GetParameterChars();
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011538// INSTANTIATE_TEST_SUITE_P(CharSequence2,
11539// CharTest,
11540// ValuesIn(l.begin(), l.end()));
Austin Schuh70cc9552019-01-21 19:46:48 -080011541//
11542template <typename ForwardIterator>
11543internal::ParamGenerator<
11544 typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
11545ValuesIn(ForwardIterator begin, ForwardIterator end) {
11546 typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
11547 ::value_type ParamType;
11548 return internal::ParamGenerator<ParamType>(
11549 new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
11550}
11551
11552template <typename T, size_t N>
11553internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
11554 return ValuesIn(array, array + N);
11555}
11556
11557template <class Container>
11558internal::ParamGenerator<typename Container::value_type> ValuesIn(
11559 const Container& container) {
11560 return ValuesIn(container.begin(), container.end());
11561}
11562
11563// Values() allows generating tests from explicitly specified list of
11564// parameters.
11565//
11566// Synopsis:
11567// Values(T v1, T v2, ..., T vN)
11568// - returns a generator producing sequences with elements v1, v2, ..., vN.
11569//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011570// For example, this instantiates tests from test suite BarTest each
Austin Schuh70cc9552019-01-21 19:46:48 -080011571// with values "one", "two", and "three":
11572//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011573// INSTANTIATE_TEST_SUITE_P(NumSequence,
11574// BarTest,
11575// Values("one", "two", "three"));
Austin Schuh70cc9552019-01-21 19:46:48 -080011576//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011577// This instantiates tests from test suite BazTest each with values 1, 2, 3.5.
Austin Schuh70cc9552019-01-21 19:46:48 -080011578// The exact type of values will depend on the type of parameter in BazTest.
11579//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011580// INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
Austin Schuh70cc9552019-01-21 19:46:48 -080011581//
Austin Schuh70cc9552019-01-21 19:46:48 -080011582//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011583template <typename... T>
11584internal::ValueArray<T...> Values(T... v) {
11585 return internal::ValueArray<T...>(std::move(v)...);
Austin Schuh70cc9552019-01-21 19:46:48 -080011586}
11587
11588// Bool() allows generating tests with parameters in a set of (false, true).
11589//
11590// Synopsis:
11591// Bool()
11592// - returns a generator producing sequences with elements {false, true}.
11593//
11594// It is useful when testing code that depends on Boolean flags. Combinations
11595// of multiple flags can be tested when several Bool()'s are combined using
11596// Combine() function.
11597//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011598// In the following example all tests in the test suite FlagDependentTest
Austin Schuh70cc9552019-01-21 19:46:48 -080011599// will be instantiated twice with parameters false and true.
11600//
11601// class FlagDependentTest : public testing::TestWithParam<bool> {
11602// virtual void SetUp() {
11603// external_flag = GetParam();
11604// }
11605// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011606// INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
Austin Schuh70cc9552019-01-21 19:46:48 -080011607//
11608inline internal::ParamGenerator<bool> Bool() {
11609 return Values(false, true);
11610}
11611
Austin Schuh70cc9552019-01-21 19:46:48 -080011612// Combine() allows the user to combine two or more sequences to produce
11613// values of a Cartesian product of those sequences' elements.
11614//
11615// Synopsis:
11616// Combine(gen1, gen2, ..., genN)
11617// - returns a generator producing sequences with elements coming from
11618// the Cartesian product of elements from the sequences generated by
11619// gen1, gen2, ..., genN. The sequence elements will have a type of
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011620// std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
Austin Schuh70cc9552019-01-21 19:46:48 -080011621// of elements from sequences produces by gen1, gen2, ..., genN.
11622//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011623// Combine can have up to 10 arguments.
Austin Schuh70cc9552019-01-21 19:46:48 -080011624//
11625// Example:
11626//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011627// This will instantiate tests in test suite AnimalTest each one with
Austin Schuh70cc9552019-01-21 19:46:48 -080011628// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
11629// tuple("dog", BLACK), and tuple("dog", WHITE):
11630//
11631// enum Color { BLACK, GRAY, WHITE };
11632// class AnimalTest
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011633// : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
Austin Schuh70cc9552019-01-21 19:46:48 -080011634//
11635// TEST_P(AnimalTest, AnimalLooksNice) {...}
11636//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011637// INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
11638// Combine(Values("cat", "dog"),
11639// Values(BLACK, WHITE)));
Austin Schuh70cc9552019-01-21 19:46:48 -080011640//
11641// This will instantiate tests in FlagDependentTest with all variations of two
11642// Boolean flags:
11643//
11644// class FlagDependentTest
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011645// : public testing::TestWithParam<std::tuple<bool, bool> > {
Austin Schuh70cc9552019-01-21 19:46:48 -080011646// virtual void SetUp() {
11647// // Assigns external_flag_1 and external_flag_2 values from the tuple.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011648// std::tie(external_flag_1, external_flag_2) = GetParam();
Austin Schuh70cc9552019-01-21 19:46:48 -080011649// }
11650// };
11651//
11652// TEST_P(FlagDependentTest, TestFeature1) {
11653// // Test your code using external_flag_1 and external_flag_2 here.
11654// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011655// INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,
11656// Combine(Bool(), Bool()));
Austin Schuh70cc9552019-01-21 19:46:48 -080011657//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011658template <typename... Generator>
11659internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
11660 return internal::CartesianProductHolder<Generator...>(g...);
Austin Schuh70cc9552019-01-21 19:46:48 -080011661}
11662
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011663#define TEST_P(test_suite_name, test_name) \
11664 class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
11665 : public test_suite_name { \
11666 public: \
11667 GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
11668 virtual void TestBody(); \
11669 \
11670 private: \
11671 static int AddToRegistry() { \
11672 ::testing::UnitTest::GetInstance() \
11673 ->parameterized_test_registry() \
11674 .GetTestSuitePatternHolder<test_suite_name>( \
11675 #test_suite_name, \
11676 ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
11677 ->AddTestPattern( \
11678 GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
11679 new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
11680 test_suite_name, test_name)>()); \
11681 return 0; \
11682 } \
11683 static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
11684 GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
11685 test_name)); \
11686 }; \
11687 int GTEST_TEST_CLASS_NAME_(test_suite_name, \
11688 test_name)::gtest_registering_dummy_ = \
11689 GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
11690 void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
Austin Schuh70cc9552019-01-21 19:46:48 -080011691
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011692// The last argument to INSTANTIATE_TEST_SUITE_P allows the user to specify
11693// generator and an optional function or functor that generates custom test name
11694// suffixes based on the test parameters. Such a function or functor should
11695// accept one argument of type testing::TestParamInfo<class ParamType>, and
11696// return std::string.
Austin Schuh70cc9552019-01-21 19:46:48 -080011697//
11698// testing::PrintToStringParamName is a builtin test suffix generator that
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011699// returns the value of testing::PrintToString(GetParam()).
Austin Schuh70cc9552019-01-21 19:46:48 -080011700//
11701// Note: test names must be non-empty, unique, and may only contain ASCII
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011702// alphanumeric characters or underscore. Because PrintToString adds quotes
11703// to std::string and C strings, it won't work for these types.
Austin Schuh70cc9552019-01-21 19:46:48 -080011704
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011705#define GTEST_EXPAND_(arg) arg
11706#define GTEST_GET_FIRST_(first, ...) first
11707#define GTEST_GET_SECOND_(first, second, ...) second
11708
11709#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
11710 static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
11711 gtest_##prefix##test_suite_name##_EvalGenerator_() { \
11712 return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
11713 } \
11714 static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
11715 const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
11716 if (::testing::internal::AlwaysFalse()) { \
11717 ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \
11718 __VA_ARGS__, \
11719 ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
11720 DUMMY_PARAM_))); \
11721 auto t = std::make_tuple(__VA_ARGS__); \
11722 static_assert(std::tuple_size<decltype(t)>::value <= 2, \
11723 "Too Many Args!"); \
11724 } \
11725 return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \
11726 __VA_ARGS__, \
11727 ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
11728 DUMMY_PARAM_))))(info); \
11729 } \
11730 static int gtest_##prefix##test_suite_name##_dummy_ \
11731 GTEST_ATTRIBUTE_UNUSED_ = \
11732 ::testing::UnitTest::GetInstance() \
11733 ->parameterized_test_registry() \
11734 .GetTestSuitePatternHolder<test_suite_name>( \
11735 #test_suite_name, \
11736 ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
11737 ->AddTestSuiteInstantiation( \
11738 #prefix, &gtest_##prefix##test_suite_name##_EvalGenerator_, \
11739 &gtest_##prefix##test_suite_name##_EvalGenerateName_, \
11740 __FILE__, __LINE__)
11741
11742// Legacy API is deprecated but still available
11743#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
11744#define INSTANTIATE_TEST_CASE_P \
11745 static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
11746 ""); \
11747 INSTANTIATE_TEST_SUITE_P
11748#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080011749
11750} // namespace testing
11751
Austin Schuh70cc9552019-01-21 19:46:48 -080011752#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
11753// Copyright 2006, Google Inc.
11754// All rights reserved.
11755//
11756// Redistribution and use in source and binary forms, with or without
11757// modification, are permitted provided that the following conditions are
11758// met:
11759//
11760// * Redistributions of source code must retain the above copyright
11761// notice, this list of conditions and the following disclaimer.
11762// * Redistributions in binary form must reproduce the above
11763// copyright notice, this list of conditions and the following disclaimer
11764// in the documentation and/or other materials provided with the
11765// distribution.
11766// * Neither the name of Google Inc. nor the names of its
11767// contributors may be used to endorse or promote products derived from
11768// this software without specific prior written permission.
11769//
11770// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11771// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11772// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11773// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
11774// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11775// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11776// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11777// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11778// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11779// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11780// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011781
Austin Schuh70cc9552019-01-21 19:46:48 -080011782//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011783// Google C++ Testing and Mocking Framework definitions useful in production code.
11784// GOOGLETEST_CM0003 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -080011785
11786#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11787#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11788
11789// When you need to test the private or protected members of a class,
11790// use the FRIEND_TEST macro to declare your tests as friends of the
11791// class. For example:
11792//
11793// class MyClass {
11794// private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011795// void PrivateMethod();
11796// FRIEND_TEST(MyClassTest, PrivateMethodWorks);
Austin Schuh70cc9552019-01-21 19:46:48 -080011797// };
11798//
11799// class MyClassTest : public testing::Test {
11800// // ...
11801// };
11802//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011803// TEST_F(MyClassTest, PrivateMethodWorks) {
11804// // Can call MyClass::PrivateMethod() here.
Austin Schuh70cc9552019-01-21 19:46:48 -080011805// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011806//
11807// Note: The test class must be in the same namespace as the class being tested.
11808// For example, putting MyClassTest in an anonymous namespace will not work.
Austin Schuh70cc9552019-01-21 19:46:48 -080011809
11810#define FRIEND_TEST(test_case_name, test_name)\
11811friend class test_case_name##_##test_name##_Test
11812
11813#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
11814// Copyright 2008, Google Inc.
11815// All rights reserved.
11816//
11817// Redistribution and use in source and binary forms, with or without
11818// modification, are permitted provided that the following conditions are
11819// met:
11820//
11821// * Redistributions of source code must retain the above copyright
11822// notice, this list of conditions and the following disclaimer.
11823// * Redistributions in binary form must reproduce the above
11824// copyright notice, this list of conditions and the following disclaimer
11825// in the documentation and/or other materials provided with the
11826// distribution.
11827// * Neither the name of Google Inc. nor the names of its
11828// contributors may be used to endorse or promote products derived from
11829// this software without specific prior written permission.
11830//
11831// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11832// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11833// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11834// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
11835// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11836// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11837// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11838// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11839// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
11840// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
11841// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11842//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011843// GOOGLETEST_CM0001 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -080011844
11845#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11846#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11847
11848#include <iosfwd>
11849#include <vector>
11850
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011851GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
11852/* class A needs to have dll-interface to be used by clients of class B */)
11853
Austin Schuh70cc9552019-01-21 19:46:48 -080011854namespace testing {
11855
11856// A copyable object representing the result of a test part (i.e. an
11857// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
11858//
11859// Don't inherit from TestPartResult as its destructor is not virtual.
11860class GTEST_API_ TestPartResult {
11861 public:
11862 // The possible outcomes of a test part (i.e. an assertion or an
11863 // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
11864 enum Type {
11865 kSuccess, // Succeeded.
11866 kNonFatalFailure, // Failed but the test can continue.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011867 kFatalFailure, // Failed and the test should be terminated.
11868 kSkip // Skipped.
Austin Schuh70cc9552019-01-21 19:46:48 -080011869 };
11870
11871 // C'tor. TestPartResult does NOT have a default constructor.
11872 // Always use this constructor (with parameters) to create a
11873 // TestPartResult object.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011874 TestPartResult(Type a_type, const char* a_file_name, int a_line_number,
Austin Schuh70cc9552019-01-21 19:46:48 -080011875 const char* a_message)
11876 : type_(a_type),
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011877 file_name_(a_file_name == nullptr ? "" : a_file_name),
Austin Schuh70cc9552019-01-21 19:46:48 -080011878 line_number_(a_line_number),
11879 summary_(ExtractSummary(a_message)),
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011880 message_(a_message) {}
Austin Schuh70cc9552019-01-21 19:46:48 -080011881
11882 // Gets the outcome of the test part.
11883 Type type() const { return type_; }
11884
11885 // Gets the name of the source file where the test part took place, or
11886 // NULL if it's unknown.
11887 const char* file_name() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011888 return file_name_.empty() ? nullptr : file_name_.c_str();
Austin Schuh70cc9552019-01-21 19:46:48 -080011889 }
11890
11891 // Gets the line in the source file where the test part took place,
11892 // or -1 if it's unknown.
11893 int line_number() const { return line_number_; }
11894
11895 // Gets the summary of the failure message.
11896 const char* summary() const { return summary_.c_str(); }
11897
11898 // Gets the message associated with the test part.
11899 const char* message() const { return message_.c_str(); }
11900
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011901 // Returns true iff the test part was skipped.
11902 bool skipped() const { return type_ == kSkip; }
11903
Austin Schuh70cc9552019-01-21 19:46:48 -080011904 // Returns true iff the test part passed.
11905 bool passed() const { return type_ == kSuccess; }
11906
Austin Schuh70cc9552019-01-21 19:46:48 -080011907 // Returns true iff the test part non-fatally failed.
11908 bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
11909
11910 // Returns true iff the test part fatally failed.
11911 bool fatally_failed() const { return type_ == kFatalFailure; }
11912
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011913 // Returns true iff the test part failed.
11914 bool failed() const { return fatally_failed() || nonfatally_failed(); }
11915
Austin Schuh70cc9552019-01-21 19:46:48 -080011916 private:
11917 Type type_;
11918
11919 // Gets the summary of the failure message by omitting the stack
11920 // trace in it.
11921 static std::string ExtractSummary(const char* message);
11922
11923 // The name of the source file where the test part took place, or
11924 // "" if the source file is unknown.
11925 std::string file_name_;
11926 // The line in the source file where the test part took place, or -1
11927 // if the line number is unknown.
11928 int line_number_;
11929 std::string summary_; // The test failure summary.
11930 std::string message_; // The test failure message.
11931};
11932
11933// Prints a TestPartResult object.
11934std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
11935
11936// An array of TestPartResult objects.
11937//
11938// Don't inherit from TestPartResultArray as its destructor is not
11939// virtual.
11940class GTEST_API_ TestPartResultArray {
11941 public:
11942 TestPartResultArray() {}
11943
11944 // Appends the given TestPartResult to the array.
11945 void Append(const TestPartResult& result);
11946
11947 // Returns the TestPartResult at the given index (0-based).
11948 const TestPartResult& GetTestPartResult(int index) const;
11949
11950 // Returns the number of TestPartResult objects in the array.
11951 int size() const;
11952
11953 private:
11954 std::vector<TestPartResult> array_;
11955
11956 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
11957};
11958
11959// This interface knows how to report a test part result.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011960class GTEST_API_ TestPartResultReporterInterface {
Austin Schuh70cc9552019-01-21 19:46:48 -080011961 public:
11962 virtual ~TestPartResultReporterInterface() {}
11963
11964 virtual void ReportTestPartResult(const TestPartResult& result) = 0;
11965};
11966
11967namespace internal {
11968
11969// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
11970// statement generates new fatal failures. To do so it registers itself as the
11971// current test part result reporter. Besides checking if fatal failures were
11972// reported, it only delegates the reporting to the former result reporter.
11973// The original result reporter is restored in the destructor.
11974// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
11975class GTEST_API_ HasNewFatalFailureHelper
11976 : public TestPartResultReporterInterface {
11977 public:
11978 HasNewFatalFailureHelper();
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011979 ~HasNewFatalFailureHelper() override;
11980 void ReportTestPartResult(const TestPartResult& result) override;
Austin Schuh70cc9552019-01-21 19:46:48 -080011981 bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
11982 private:
11983 bool has_new_fatal_failure_;
11984 TestPartResultReporterInterface* original_reporter_;
11985
11986 GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
11987};
11988
11989} // namespace internal
11990
11991} // namespace testing
11992
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080011993GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
11994
Austin Schuh70cc9552019-01-21 19:46:48 -080011995#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
11996// Copyright 2008 Google Inc.
11997// All Rights Reserved.
11998//
11999// Redistribution and use in source and binary forms, with or without
12000// modification, are permitted provided that the following conditions are
12001// met:
12002//
12003// * Redistributions of source code must retain the above copyright
12004// notice, this list of conditions and the following disclaimer.
12005// * Redistributions in binary form must reproduce the above
12006// copyright notice, this list of conditions and the following disclaimer
12007// in the documentation and/or other materials provided with the
12008// distribution.
12009// * Neither the name of Google Inc. nor the names of its
12010// contributors may be used to endorse or promote products derived from
12011// this software without specific prior written permission.
12012//
12013// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12014// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
12015// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12016// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12017// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12018// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12019// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12020// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12021// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12022// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12023// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012024
12025
12026// GOOGLETEST_CM0001 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -080012027
12028#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
12029#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
12030
12031// This header implements typed tests and type-parameterized tests.
12032
12033// Typed (aka type-driven) tests repeat the same test for types in a
12034// list. You must know which types you want to test with when writing
12035// typed tests. Here's how you do it:
12036
12037#if 0
12038
12039// First, define a fixture class template. It should be parameterized
12040// by a type. Remember to derive it from testing::Test.
12041template <typename T>
12042class FooTest : public testing::Test {
12043 public:
12044 ...
12045 typedef std::list<T> List;
12046 static T shared_;
12047 T value_;
12048};
12049
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012050// Next, associate a list of types with the test suite, which will be
Austin Schuh70cc9552019-01-21 19:46:48 -080012051// repeated for each type in the list. The typedef is necessary for
12052// the macro to parse correctly.
12053typedef testing::Types<char, int, unsigned int> MyTypes;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012054TYPED_TEST_SUITE(FooTest, MyTypes);
Austin Schuh70cc9552019-01-21 19:46:48 -080012055
12056// If the type list contains only one type, you can write that type
12057// directly without Types<...>:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012058// TYPED_TEST_SUITE(FooTest, int);
Austin Schuh70cc9552019-01-21 19:46:48 -080012059
12060// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012061// tests for this test suite as you want.
Austin Schuh70cc9552019-01-21 19:46:48 -080012062TYPED_TEST(FooTest, DoesBlah) {
12063 // Inside a test, refer to TypeParam to get the type parameter.
12064 // Since we are inside a derived class template, C++ requires use to
12065 // visit the members of FooTest via 'this'.
12066 TypeParam n = this->value_;
12067
12068 // To visit static members of the fixture, add the TestFixture::
12069 // prefix.
12070 n += TestFixture::shared_;
12071
12072 // To refer to typedefs in the fixture, add the "typename
12073 // TestFixture::" prefix.
12074 typename TestFixture::List values;
12075 values.push_back(n);
12076 ...
12077}
12078
12079TYPED_TEST(FooTest, HasPropertyA) { ... }
12080
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012081// TYPED_TEST_SUITE takes an optional third argument which allows to specify a
12082// class that generates custom test name suffixes based on the type. This should
12083// be a class which has a static template function GetName(int index) returning
12084// a string for each type. The provided integer index equals the index of the
12085// type in the provided type list. In many cases the index can be ignored.
12086//
12087// For example:
12088// class MyTypeNames {
12089// public:
12090// template <typename T>
12091// static std::string GetName(int) {
12092// if (std::is_same<T, char>()) return "char";
12093// if (std::is_same<T, int>()) return "int";
12094// if (std::is_same<T, unsigned int>()) return "unsignedInt";
12095// }
12096// };
12097// TYPED_TEST_SUITE(FooTest, MyTypes, MyTypeNames);
12098
Austin Schuh70cc9552019-01-21 19:46:48 -080012099#endif // 0
12100
12101// Type-parameterized tests are abstract test patterns parameterized
12102// by a type. Compared with typed tests, type-parameterized tests
12103// allow you to define the test pattern without knowing what the type
12104// parameters are. The defined pattern can be instantiated with
12105// different types any number of times, in any number of translation
12106// units.
12107//
12108// If you are designing an interface or concept, you can define a
12109// suite of type-parameterized tests to verify properties that any
12110// valid implementation of the interface/concept should have. Then,
12111// each implementation can easily instantiate the test suite to verify
12112// that it conforms to the requirements, without having to write
12113// similar tests repeatedly. Here's an example:
12114
12115#if 0
12116
12117// First, define a fixture class template. It should be parameterized
12118// by a type. Remember to derive it from testing::Test.
12119template <typename T>
12120class FooTest : public testing::Test {
12121 ...
12122};
12123
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012124// Next, declare that you will define a type-parameterized test suite
Austin Schuh70cc9552019-01-21 19:46:48 -080012125// (the _P suffix is for "parameterized" or "pattern", whichever you
12126// prefer):
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012127TYPED_TEST_SUITE_P(FooTest);
Austin Schuh70cc9552019-01-21 19:46:48 -080012128
12129// Then, use TYPED_TEST_P() to define as many type-parameterized tests
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012130// for this type-parameterized test suite as you want.
Austin Schuh70cc9552019-01-21 19:46:48 -080012131TYPED_TEST_P(FooTest, DoesBlah) {
12132 // Inside a test, refer to TypeParam to get the type parameter.
12133 TypeParam n = 0;
12134 ...
12135}
12136
12137TYPED_TEST_P(FooTest, HasPropertyA) { ... }
12138
12139// Now the tricky part: you need to register all test patterns before
12140// you can instantiate them. The first argument of the macro is the
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012141// test suite name; the rest are the names of the tests in this test
Austin Schuh70cc9552019-01-21 19:46:48 -080012142// case.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012143REGISTER_TYPED_TEST_SUITE_P(FooTest,
12144 DoesBlah, HasPropertyA);
Austin Schuh70cc9552019-01-21 19:46:48 -080012145
12146// Finally, you are free to instantiate the pattern with the types you
12147// want. If you put the above code in a header file, you can #include
12148// it in multiple C++ source files and instantiate it multiple times.
12149//
12150// To distinguish different instances of the pattern, the first
12151// argument to the INSTANTIATE_* macro is a prefix that will be added
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012152// to the actual test suite name. Remember to pick unique prefixes for
Austin Schuh70cc9552019-01-21 19:46:48 -080012153// different instances.
12154typedef testing::Types<char, int, unsigned int> MyTypes;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012155INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
Austin Schuh70cc9552019-01-21 19:46:48 -080012156
12157// If the type list contains only one type, you can write that type
12158// directly without Types<...>:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012159// INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int);
12160//
12161// Similar to the optional argument of TYPED_TEST_SUITE above,
12162// INSTANTIATE_TEST_SUITE_P takes an optional fourth argument which allows to
12163// generate custom names.
12164// INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes, MyTypeNames);
Austin Schuh70cc9552019-01-21 19:46:48 -080012165
12166#endif // 0
12167
12168
12169// Implements typed tests.
12170
12171#if GTEST_HAS_TYPED_TEST
12172
12173// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12174//
12175// Expands to the name of the typedef for the type parameters of the
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012176// given test suite.
12177#define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_
12178
12179// Expands to the name of the typedef for the NameGenerator, responsible for
12180// creating the suffixes of the name.
12181#define GTEST_NAME_GENERATOR_(TestSuiteName) \
12182 gtest_type_params_##TestSuiteName##_NameGenerator
Austin Schuh70cc9552019-01-21 19:46:48 -080012183
12184// The 'Types' template argument below must have spaces around it
12185// since some compilers may choke on '>>' when passing a template
12186// instance (e.g. Types<int>)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012187#define TYPED_TEST_SUITE(CaseName, Types, ...) \
12188 typedef ::testing::internal::TypeList<Types>::type GTEST_TYPE_PARAMS_( \
12189 CaseName); \
12190 typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
12191 GTEST_NAME_GENERATOR_(CaseName)
Austin Schuh70cc9552019-01-21 19:46:48 -080012192
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012193# define TYPED_TEST(CaseName, TestName) \
12194 template <typename gtest_TypeParam_> \
12195 class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
12196 : public CaseName<gtest_TypeParam_> { \
12197 private: \
12198 typedef CaseName<gtest_TypeParam_> TestFixture; \
12199 typedef gtest_TypeParam_ TypeParam; \
12200 virtual void TestBody(); \
12201 }; \
12202 static bool gtest_##CaseName##_##TestName##_registered_ \
12203 GTEST_ATTRIBUTE_UNUSED_ = \
12204 ::testing::internal::TypeParameterizedTest< \
12205 CaseName, \
12206 ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
12207 TestName)>, \
12208 GTEST_TYPE_PARAMS_( \
12209 CaseName)>::Register("", \
12210 ::testing::internal::CodeLocation( \
12211 __FILE__, __LINE__), \
12212 #CaseName, #TestName, 0, \
12213 ::testing::internal::GenerateNames< \
12214 GTEST_NAME_GENERATOR_(CaseName), \
12215 GTEST_TYPE_PARAMS_(CaseName)>()); \
12216 template <typename gtest_TypeParam_> \
12217 void GTEST_TEST_CLASS_NAME_(CaseName, \
12218 TestName)<gtest_TypeParam_>::TestBody()
12219
12220// Legacy API is deprecated but still available
12221#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12222#define TYPED_TEST_CASE \
12223 static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \
12224 TYPED_TEST_SUITE
12225#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080012226
12227#endif // GTEST_HAS_TYPED_TEST
12228
12229// Implements type-parameterized tests.
12230
12231#if GTEST_HAS_TYPED_TEST_P
12232
12233// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12234//
12235// Expands to the namespace name that the type-parameterized tests for
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012236// the given type-parameterized test suite are defined in. The exact
Austin Schuh70cc9552019-01-21 19:46:48 -080012237// name of the namespace is subject to change without notice.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012238#define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_
Austin Schuh70cc9552019-01-21 19:46:48 -080012239
12240// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
12241//
12242// Expands to the name of the variable used to remember the names of
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012243// the defined tests in the given test suite.
12244#define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \
12245 gtest_typed_test_suite_p_state_##TestSuiteName##_
Austin Schuh70cc9552019-01-21 19:46:48 -080012246
12247// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
12248//
12249// Expands to the name of the variable used to remember the names of
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012250// the registered tests in the given test suite.
12251#define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \
12252 gtest_registered_test_names_##TestSuiteName##_
Austin Schuh70cc9552019-01-21 19:46:48 -080012253
12254// The variables defined in the type-parameterized test macros are
12255// static as typically these macros are used in a .h file that can be
12256// #included in multiple translation units linked together.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012257#define TYPED_TEST_SUITE_P(SuiteName) \
12258 static ::testing::internal::TypedTestSuitePState \
12259 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
Austin Schuh70cc9552019-01-21 19:46:48 -080012260
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012261// Legacy API is deprecated but still available
12262#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12263#define TYPED_TEST_CASE_P \
12264 static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), ""); \
12265 TYPED_TEST_SUITE_P
12266#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080012267
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012268#define TYPED_TEST_P(SuiteName, TestName) \
12269 namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
12270 template <typename gtest_TypeParam_> \
12271 class TestName : public SuiteName<gtest_TypeParam_> { \
12272 private: \
12273 typedef SuiteName<gtest_TypeParam_> TestFixture; \
12274 typedef gtest_TypeParam_ TypeParam; \
12275 virtual void TestBody(); \
12276 }; \
12277 static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
12278 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
12279 __FILE__, __LINE__, #SuiteName, #TestName); \
12280 } \
12281 template <typename gtest_TypeParam_> \
12282 void GTEST_SUITE_NAMESPACE_( \
12283 SuiteName)::TestName<gtest_TypeParam_>::TestBody()
12284
12285#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
12286 namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
12287 typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
12288 } \
12289 static const char* const GTEST_REGISTERED_TEST_NAMES_( \
12290 SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
12291 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
Austin Schuh70cc9552019-01-21 19:46:48 -080012292 __FILE__, __LINE__, #__VA_ARGS__)
12293
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012294// Legacy API is deprecated but still available
12295#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12296#define REGISTER_TYPED_TEST_CASE_P \
12297 static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \
12298 ""); \
12299 REGISTER_TYPED_TEST_SUITE_P
12300#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12301
Austin Schuh70cc9552019-01-21 19:46:48 -080012302// The 'Types' template argument below must have spaces around it
12303// since some compilers may choke on '>>' when passing a template
12304// instance (e.g. Types<int>)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012305#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
12306 static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
12307 ::testing::internal::TypeParameterizedTestSuite< \
12308 SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
12309 ::testing::internal::TypeList<Types>::type>:: \
12310 Register(#Prefix, \
12311 ::testing::internal::CodeLocation(__FILE__, __LINE__), \
12312 &GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \
12313 GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
12314 ::testing::internal::GenerateNames< \
12315 ::testing::internal::NameGeneratorSelector< \
12316 __VA_ARGS__>::type, \
12317 ::testing::internal::TypeList<Types>::type>())
12318
12319// Legacy API is deprecated but still available
12320#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12321#define INSTANTIATE_TYPED_TEST_CASE_P \
12322 static_assert( \
12323 ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), ""); \
12324 INSTANTIATE_TYPED_TEST_SUITE_P
12325#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080012326
12327#endif // GTEST_HAS_TYPED_TEST_P
12328
12329#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
12330
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012331GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
12332/* class A needs to have dll-interface to be used by clients of class B */)
12333
Austin Schuh70cc9552019-01-21 19:46:48 -080012334// Depending on the platform, different string classes are available.
12335// On Linux, in addition to ::std::string, Google also makes use of
12336// class ::string, which has the same interface as ::std::string, but
12337// has a different implementation.
12338//
12339// You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
12340// ::string is available AND is a distinct type to ::std::string, or
12341// define it to 0 to indicate otherwise.
12342//
12343// If ::std::string and ::string are the same class on your platform
12344// due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0.
12345//
12346// If you do not define GTEST_HAS_GLOBAL_STRING, it is defined
12347// heuristically.
12348
12349namespace testing {
12350
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012351// Silence C4100 (unreferenced formal parameter) and 4805
12352// unsafe mix of type 'const int' and type 'const bool'
12353#ifdef _MSC_VER
12354# pragma warning(push)
12355# pragma warning(disable:4805)
12356# pragma warning(disable:4100)
12357#endif
12358
12359
Austin Schuh70cc9552019-01-21 19:46:48 -080012360// Declares the flags.
12361
12362// This flag temporary enables the disabled tests.
12363GTEST_DECLARE_bool_(also_run_disabled_tests);
12364
12365// This flag brings the debugger on an assertion failure.
12366GTEST_DECLARE_bool_(break_on_failure);
12367
12368// This flag controls whether Google Test catches all test-thrown exceptions
12369// and logs them as failures.
12370GTEST_DECLARE_bool_(catch_exceptions);
12371
12372// This flag enables using colors in terminal output. Available values are
12373// "yes" to enable colors, "no" (disable colors), or "auto" (the default)
12374// to let Google Test decide.
12375GTEST_DECLARE_string_(color);
12376
12377// This flag sets up the filter to select by name using a glob pattern
12378// the tests to run. If the filter is not given all tests are executed.
12379GTEST_DECLARE_string_(filter);
12380
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012381// This flag controls whether Google Test installs a signal handler that dumps
12382// debugging information when fatal signals are raised.
12383GTEST_DECLARE_bool_(install_failure_signal_handler);
12384
Austin Schuh70cc9552019-01-21 19:46:48 -080012385// This flag causes the Google Test to list tests. None of the tests listed
12386// are actually run if the flag is provided.
12387GTEST_DECLARE_bool_(list_tests);
12388
12389// This flag controls whether Google Test emits a detailed XML report to a file
12390// in addition to its normal textual output.
12391GTEST_DECLARE_string_(output);
12392
12393// This flags control whether Google Test prints the elapsed time for each
12394// test.
12395GTEST_DECLARE_bool_(print_time);
12396
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012397// This flags control whether Google Test prints UTF8 characters as text.
12398GTEST_DECLARE_bool_(print_utf8);
12399
Austin Schuh70cc9552019-01-21 19:46:48 -080012400// This flag specifies the random number seed.
12401GTEST_DECLARE_int32_(random_seed);
12402
12403// This flag sets how many times the tests are repeated. The default value
12404// is 1. If the value is -1 the tests are repeating forever.
12405GTEST_DECLARE_int32_(repeat);
12406
12407// This flag controls whether Google Test includes Google Test internal
12408// stack frames in failure stack traces.
12409GTEST_DECLARE_bool_(show_internal_stack_frames);
12410
12411// When this flag is specified, tests' order is randomized on every iteration.
12412GTEST_DECLARE_bool_(shuffle);
12413
12414// This flag specifies the maximum number of stack frames to be
12415// printed in a failure message.
12416GTEST_DECLARE_int32_(stack_trace_depth);
12417
12418// When this flag is specified, a failed assertion will throw an
12419// exception if exceptions are enabled, or exit the program with a
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012420// non-zero code otherwise. For use with an external test framework.
Austin Schuh70cc9552019-01-21 19:46:48 -080012421GTEST_DECLARE_bool_(throw_on_failure);
12422
12423// When this flag is set with a "host:port" string, on supported
12424// platforms test results are streamed to the specified port on
12425// the specified host machine.
12426GTEST_DECLARE_string_(stream_result_to);
12427
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012428#if GTEST_USE_OWN_FLAGFILE_FLAG_
12429GTEST_DECLARE_string_(flagfile);
12430#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
12431
Austin Schuh70cc9552019-01-21 19:46:48 -080012432// The upper limit for valid stack trace depths.
12433const int kMaxStackTraceDepth = 100;
12434
12435namespace internal {
12436
12437class AssertHelper;
12438class DefaultGlobalTestPartResultReporter;
12439class ExecDeathTest;
12440class NoExecDeathTest;
12441class FinalSuccessChecker;
12442class GTestFlagSaver;
12443class StreamingListenerTest;
12444class TestResultAccessor;
12445class TestEventListenersAccessor;
12446class TestEventRepeater;
12447class UnitTestRecordPropertyTestHelper;
12448class WindowsDeathTest;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012449class FuchsiaDeathTest;
Austin Schuh70cc9552019-01-21 19:46:48 -080012450class UnitTestImpl* GetUnitTestImpl();
12451void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
12452 const std::string& message);
12453
12454} // namespace internal
12455
12456// The friend relationship of some of these classes is cyclic.
12457// If we don't forward declare them the compiler might confuse the classes
12458// in friendship clauses with same named classes on the scope.
12459class Test;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012460class TestSuite;
12461
12462// Old API is still available but deprecated
12463#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
12464using TestCase = TestSuite;
12465#endif
Austin Schuh70cc9552019-01-21 19:46:48 -080012466class TestInfo;
12467class UnitTest;
12468
12469// A class for indicating whether an assertion was successful. When
12470// the assertion wasn't successful, the AssertionResult object
12471// remembers a non-empty message that describes how it failed.
12472//
12473// To create an instance of this class, use one of the factory functions
12474// (AssertionSuccess() and AssertionFailure()).
12475//
12476// This class is useful for two purposes:
12477// 1. Defining predicate functions to be used with Boolean test assertions
12478// EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
12479// 2. Defining predicate-format functions to be
12480// used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
12481//
12482// For example, if you define IsEven predicate:
12483//
12484// testing::AssertionResult IsEven(int n) {
12485// if ((n % 2) == 0)
12486// return testing::AssertionSuccess();
12487// else
12488// return testing::AssertionFailure() << n << " is odd";
12489// }
12490//
12491// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
12492// will print the message
12493//
12494// Value of: IsEven(Fib(5))
12495// Actual: false (5 is odd)
12496// Expected: true
12497//
12498// instead of a more opaque
12499//
12500// Value of: IsEven(Fib(5))
12501// Actual: false
12502// Expected: true
12503//
12504// in case IsEven is a simple Boolean predicate.
12505//
12506// If you expect your predicate to be reused and want to support informative
12507// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
12508// about half as often as positive ones in our tests), supply messages for
12509// both success and failure cases:
12510//
12511// testing::AssertionResult IsEven(int n) {
12512// if ((n % 2) == 0)
12513// return testing::AssertionSuccess() << n << " is even";
12514// else
12515// return testing::AssertionFailure() << n << " is odd";
12516// }
12517//
12518// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
12519//
12520// Value of: IsEven(Fib(6))
12521// Actual: true (8 is even)
12522// Expected: false
12523//
12524// NB: Predicates that support negative Boolean assertions have reduced
12525// performance in positive ones so be careful not to use them in tests
12526// that have lots (tens of thousands) of positive Boolean assertions.
12527//
12528// To use this class with EXPECT_PRED_FORMAT assertions such as:
12529//
12530// // Verifies that Foo() returns an even number.
12531// EXPECT_PRED_FORMAT1(IsEven, Foo());
12532//
12533// you need to define:
12534//
12535// testing::AssertionResult IsEven(const char* expr, int n) {
12536// if ((n % 2) == 0)
12537// return testing::AssertionSuccess();
12538// else
12539// return testing::AssertionFailure()
12540// << "Expected: " << expr << " is even\n Actual: it's " << n;
12541// }
12542//
12543// If Foo() returns 5, you will see the following message:
12544//
12545// Expected: Foo() is even
12546// Actual: it's 5
12547//
12548class GTEST_API_ AssertionResult {
12549 public:
12550 // Copy constructor.
12551 // Used in EXPECT_TRUE/FALSE(assertion_result).
12552 AssertionResult(const AssertionResult& other);
12553
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012554#if defined(_MSC_VER) && _MSC_VER < 1910
Austin Schuh70cc9552019-01-21 19:46:48 -080012555 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012556#endif
Austin Schuh70cc9552019-01-21 19:46:48 -080012557
12558 // Used in the EXPECT_TRUE/FALSE(bool_expression).
12559 //
12560 // T must be contextually convertible to bool.
12561 //
12562 // The second parameter prevents this overload from being considered if
12563 // the argument is implicitly convertible to AssertionResult. In that case
12564 // we want AssertionResult's copy constructor to be used.
12565 template <typename T>
12566 explicit AssertionResult(
12567 const T& success,
12568 typename internal::EnableIf<
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012569 !std::is_convertible<T, AssertionResult>::value>::type*
12570 /*enabler*/
12571 = nullptr)
Austin Schuh70cc9552019-01-21 19:46:48 -080012572 : success_(success) {}
12573
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012574#if defined(_MSC_VER) && _MSC_VER < 1910
Austin Schuh70cc9552019-01-21 19:46:48 -080012575 GTEST_DISABLE_MSC_WARNINGS_POP_()
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012576#endif
Austin Schuh70cc9552019-01-21 19:46:48 -080012577
12578 // Assignment operator.
12579 AssertionResult& operator=(AssertionResult other) {
12580 swap(other);
12581 return *this;
12582 }
12583
12584 // Returns true iff the assertion succeeded.
12585 operator bool() const { return success_; } // NOLINT
12586
12587 // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
12588 AssertionResult operator!() const;
12589
12590 // Returns the text streamed into this AssertionResult. Test assertions
12591 // use it when they fail (i.e., the predicate's outcome doesn't match the
12592 // assertion's expectation). When nothing has been streamed into the
12593 // object, returns an empty string.
12594 const char* message() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012595 return message_.get() != nullptr ? message_->c_str() : "";
Austin Schuh70cc9552019-01-21 19:46:48 -080012596 }
Austin Schuh70cc9552019-01-21 19:46:48 -080012597 // Deprecated; please use message() instead.
12598 const char* failure_message() const { return message(); }
12599
12600 // Streams a custom failure message into this object.
12601 template <typename T> AssertionResult& operator<<(const T& value) {
12602 AppendMessage(Message() << value);
12603 return *this;
12604 }
12605
12606 // Allows streaming basic output manipulators such as endl or flush into
12607 // this object.
12608 AssertionResult& operator<<(
12609 ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
12610 AppendMessage(Message() << basic_manipulator);
12611 return *this;
12612 }
12613
12614 private:
12615 // Appends the contents of message to message_.
12616 void AppendMessage(const Message& a_message) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012617 if (message_.get() == nullptr) message_.reset(new ::std::string);
Austin Schuh70cc9552019-01-21 19:46:48 -080012618 message_->append(a_message.GetString().c_str());
12619 }
12620
12621 // Swap the contents of this AssertionResult with other.
12622 void swap(AssertionResult& other);
12623
12624 // Stores result of the assertion predicate.
12625 bool success_;
12626 // Stores the message describing the condition in case the expectation
12627 // construct is not satisfied with the predicate's outcome.
12628 // Referenced via a pointer to avoid taking too much stack frame space
12629 // with test assertions.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012630 std::unique_ptr< ::std::string> message_;
Austin Schuh70cc9552019-01-21 19:46:48 -080012631};
12632
12633// Makes a successful assertion result.
12634GTEST_API_ AssertionResult AssertionSuccess();
12635
12636// Makes a failed assertion result.
12637GTEST_API_ AssertionResult AssertionFailure();
12638
12639// Makes a failed assertion result with the given failure message.
12640// Deprecated; use AssertionFailure() << msg.
12641GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
12642
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080012643} // namespace testing
12644
12645// Includes the auto-generated header that implements a family of generic
12646// predicate assertion macros. This include comes late because it relies on
12647// APIs declared above.
12648// Copyright 2006, Google Inc.
12649// All rights reserved.
12650//
12651// Redistribution and use in source and binary forms, with or without
12652// modification, are permitted provided that the following conditions are
12653// met:
12654//
12655// * Redistributions of source code must retain the above copyright
12656// notice, this list of conditions and the following disclaimer.
12657// * Redistributions in binary form must reproduce the above
12658// copyright notice, this list of conditions and the following disclaimer
12659// in the documentation and/or other materials provided with the
12660// distribution.
12661// * Neither the name of Google Inc. nor the names of its
12662// contributors may be used to endorse or promote products derived from
12663// this software without specific prior written permission.
12664//
12665// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12666// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
12667// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12668// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12669// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12670// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12671// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12672// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12673// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12674// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12675// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12676
12677// This file is AUTOMATICALLY GENERATED on 01/02/2019 by command
12678// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
12679//
12680// Implements a family of generic predicate assertion macros.
12681// GOOGLETEST_CM0001 DO NOT DELETE
12682
12683#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
12684#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
12685
12686
12687namespace testing {
12688
12689// This header implements a family of generic predicate assertion
12690// macros:
12691//
12692// ASSERT_PRED_FORMAT1(pred_format, v1)
12693// ASSERT_PRED_FORMAT2(pred_format, v1, v2)
12694// ...
12695//
12696// where pred_format is a function or functor that takes n (in the
12697// case of ASSERT_PRED_FORMATn) values and their source expression
12698// text, and returns a testing::AssertionResult. See the definition
12699// of ASSERT_EQ in gtest.h for an example.
12700//
12701// If you don't care about formatting, you can use the more
12702// restrictive version:
12703//
12704// ASSERT_PRED1(pred, v1)
12705// ASSERT_PRED2(pred, v1, v2)
12706// ...
12707//
12708// where pred is an n-ary function or functor that returns bool,
12709// and the values v1, v2, ..., must support the << operator for
12710// streaming to std::ostream.
12711//
12712// We also define the EXPECT_* variations.
12713//
12714// For now we only support predicates whose arity is at most 5.
12715// Please email googletestframework@googlegroups.com if you need
12716// support for higher arities.
12717
12718// GTEST_ASSERT_ is the basic statement to which all of the assertions
12719// in this file reduce. Don't use this in your code.
12720
12721#define GTEST_ASSERT_(expression, on_failure) \
12722 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
12723 if (const ::testing::AssertionResult gtest_ar = (expression)) \
12724 ; \
12725 else \
12726 on_failure(gtest_ar.failure_message())
12727
12728
12729// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
12730// this in your code.
12731template <typename Pred,
12732 typename T1>
12733AssertionResult AssertPred1Helper(const char* pred_text,
12734 const char* e1,
12735 Pred pred,
12736 const T1& v1) {
12737 if (pred(v1)) return AssertionSuccess();
12738
12739 return AssertionFailure()
12740 << pred_text << "(" << e1 << ") evaluates to false, where"
12741 << "\n"
12742 << e1 << " evaluates to " << ::testing::PrintToString(v1);
12743}
12744
12745// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
12746// Don't use this in your code.
12747#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
12748 GTEST_ASSERT_(pred_format(#v1, v1), \
12749 on_failure)
12750
12751// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
12752// this in your code.
12753#define GTEST_PRED1_(pred, v1, on_failure)\
12754 GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
12755 #v1, \
12756 pred, \
12757 v1), on_failure)
12758
12759// Unary predicate assertion macros.
12760#define EXPECT_PRED_FORMAT1(pred_format, v1) \
12761 GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
12762#define EXPECT_PRED1(pred, v1) \
12763 GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
12764#define ASSERT_PRED_FORMAT1(pred_format, v1) \
12765 GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
12766#define ASSERT_PRED1(pred, v1) \
12767 GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
12768
12769
12770
12771// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
12772// this in your code.
12773template <typename Pred,
12774 typename T1,
12775 typename T2>
12776AssertionResult AssertPred2Helper(const char* pred_text,
12777 const char* e1,
12778 const char* e2,
12779 Pred pred,
12780 const T1& v1,
12781 const T2& v2) {
12782 if (pred(v1, v2)) return AssertionSuccess();
12783
12784 return AssertionFailure()
12785 << pred_text << "(" << e1 << ", " << e2
12786 << ") evaluates to false, where"
12787 << "\n"
12788 << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12789 << e2 << " evaluates to " << ::testing::PrintToString(v2);
12790}
12791
12792// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
12793// Don't use this in your code.
12794#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
12795 GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
12796 on_failure)
12797
12798// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
12799// this in your code.
12800#define GTEST_PRED2_(pred, v1, v2, on_failure)\
12801 GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
12802 #v1, \
12803 #v2, \
12804 pred, \
12805 v1, \
12806 v2), on_failure)
12807
12808// Binary predicate assertion macros.
12809#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
12810 GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
12811#define EXPECT_PRED2(pred, v1, v2) \
12812 GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
12813#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
12814 GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
12815#define ASSERT_PRED2(pred, v1, v2) \
12816 GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
12817
12818
12819
12820// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
12821// this in your code.
12822template <typename Pred,
12823 typename T1,
12824 typename T2,
12825 typename T3>
12826AssertionResult AssertPred3Helper(const char* pred_text,
12827 const char* e1,
12828 const char* e2,
12829 const char* e3,
12830 Pred pred,
12831 const T1& v1,
12832 const T2& v2,
12833 const T3& v3) {
12834 if (pred(v1, v2, v3)) return AssertionSuccess();
12835
12836 return AssertionFailure()
12837 << pred_text << "(" << e1 << ", " << e2 << ", " << e3
12838 << ") evaluates to false, where"
12839 << "\n"
12840 << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12841 << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12842 << e3 << " evaluates to " << ::testing::PrintToString(v3);
12843}
12844
12845// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
12846// Don't use this in your code.
12847#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
12848 GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
12849 on_failure)
12850
12851// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
12852// this in your code.
12853#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
12854 GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
12855 #v1, \
12856 #v2, \
12857 #v3, \
12858 pred, \
12859 v1, \
12860 v2, \
12861 v3), on_failure)
12862
12863// Ternary predicate assertion macros.
12864#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
12865 GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
12866#define EXPECT_PRED3(pred, v1, v2, v3) \
12867 GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
12868#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
12869 GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
12870#define ASSERT_PRED3(pred, v1, v2, v3) \
12871 GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
12872
12873
12874
12875// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
12876// this in your code.
12877template <typename Pred,
12878 typename T1,
12879 typename T2,
12880 typename T3,
12881 typename T4>
12882AssertionResult AssertPred4Helper(const char* pred_text,
12883 const char* e1,
12884 const char* e2,
12885 const char* e3,
12886 const char* e4,
12887 Pred pred,
12888 const T1& v1,
12889 const T2& v2,
12890 const T3& v3,
12891 const T4& v4) {
12892 if (pred(v1, v2, v3, v4)) return AssertionSuccess();
12893
12894 return AssertionFailure()
12895 << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
12896 << ") evaluates to false, where"
12897 << "\n"
12898 << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12899 << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12900 << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
12901 << e4 << " evaluates to " << ::testing::PrintToString(v4);
12902}
12903
12904// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
12905// Don't use this in your code.
12906#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
12907 GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
12908 on_failure)
12909
12910// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
12911// this in your code.
12912#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
12913 GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
12914 #v1, \
12915 #v2, \
12916 #v3, \
12917 #v4, \
12918 pred, \
12919 v1, \
12920 v2, \
12921 v3, \
12922 v4), on_failure)
12923
12924// 4-ary predicate assertion macros.
12925#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
12926 GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
12927#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
12928 GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
12929#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
12930 GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
12931#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
12932 GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
12933
12934
12935
12936// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
12937// this in your code.
12938template <typename Pred,
12939 typename T1,
12940 typename T2,
12941 typename T3,
12942 typename T4,
12943 typename T5>
12944AssertionResult AssertPred5Helper(const char* pred_text,
12945 const char* e1,
12946 const char* e2,
12947 const char* e3,
12948 const char* e4,
12949 const char* e5,
12950 Pred pred,
12951 const T1& v1,
12952 const T2& v2,
12953 const T3& v3,
12954 const T4& v4,
12955 const T5& v5) {
12956 if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
12957
12958 return AssertionFailure()
12959 << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
12960 << ", " << e5 << ") evaluates to false, where"
12961 << "\n"
12962 << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
12963 << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
12964 << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
12965 << e4 << " evaluates to " << ::testing::PrintToString(v4) << "\n"
12966 << e5 << " evaluates to " << ::testing::PrintToString(v5);
12967}
12968
12969// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
12970// Don't use this in your code.
12971#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
12972 GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
12973 on_failure)
12974
12975// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
12976// this in your code.
12977#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
12978 GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
12979 #v1, \
12980 #v2, \
12981 #v3, \
12982 #v4, \
12983 #v5, \
12984 pred, \
12985 v1, \
12986 v2, \
12987 v3, \
12988 v4, \
12989 v5), on_failure)
12990
12991// 5-ary predicate assertion macros.
12992#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
12993 GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
12994#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
12995 GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
12996#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
12997 GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
12998#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
12999 GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
13000
13001
13002
13003} // namespace testing
13004
13005#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
13006
13007namespace testing {
13008
Austin Schuh70cc9552019-01-21 19:46:48 -080013009// The abstract class that all tests inherit from.
13010//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013011// In Google Test, a unit test program contains one or many TestSuites, and
13012// each TestSuite contains one or many Tests.
Austin Schuh70cc9552019-01-21 19:46:48 -080013013//
13014// When you define a test using the TEST macro, you don't need to
13015// explicitly derive from Test - the TEST macro automatically does
13016// this for you.
13017//
13018// The only time you derive from Test is when defining a test fixture
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013019// to be used in a TEST_F. For example:
Austin Schuh70cc9552019-01-21 19:46:48 -080013020//
13021// class FooTest : public testing::Test {
13022// protected:
13023// void SetUp() override { ... }
13024// void TearDown() override { ... }
13025// ...
13026// };
13027//
13028// TEST_F(FooTest, Bar) { ... }
13029// TEST_F(FooTest, Baz) { ... }
13030//
13031// Test is not copyable.
13032class GTEST_API_ Test {
13033 public:
13034 friend class TestInfo;
13035
Austin Schuh70cc9552019-01-21 19:46:48 -080013036 // The d'tor is virtual as we intend to inherit from Test.
13037 virtual ~Test();
13038
13039 // Sets up the stuff shared by all tests in this test case.
13040 //
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013041 // Google Test will call Foo::SetUpTestSuite() before running the first
Austin Schuh70cc9552019-01-21 19:46:48 -080013042 // test in test case Foo. Hence a sub-class can define its own
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013043 // SetUpTestSuite() method to shadow the one defined in the super
Austin Schuh70cc9552019-01-21 19:46:48 -080013044 // class.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013045 static void SetUpTestSuite() {}
Austin Schuh70cc9552019-01-21 19:46:48 -080013046
13047 // Tears down the stuff shared by all tests in this test case.
13048 //
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013049 // Google Test will call Foo::TearDownTestSuite() after running the last
Austin Schuh70cc9552019-01-21 19:46:48 -080013050 // test in test case Foo. Hence a sub-class can define its own
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013051 // TearDownTestSuite() method to shadow the one defined in the super
Austin Schuh70cc9552019-01-21 19:46:48 -080013052 // class.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013053 static void TearDownTestSuite() {}
13054
13055 // Legacy API is deprecated but still available
13056#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013057 static void TearDownTestCase() {}
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013058 static void SetUpTestCase() {}
13059#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013060
13061 // Returns true iff the current test has a fatal failure.
13062 static bool HasFatalFailure();
13063
13064 // Returns true iff the current test has a non-fatal failure.
13065 static bool HasNonfatalFailure();
13066
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013067 // Returns true iff the current test was skipped.
13068 static bool IsSkipped();
13069
Austin Schuh70cc9552019-01-21 19:46:48 -080013070 // Returns true iff the current test has a (either fatal or
13071 // non-fatal) failure.
13072 static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
13073
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013074 // Logs a property for the current test, test suite, or for the entire
Austin Schuh70cc9552019-01-21 19:46:48 -080013075 // invocation of the test program when used outside of the context of a
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013076 // test suite. Only the last value for a given key is remembered. These
Austin Schuh70cc9552019-01-21 19:46:48 -080013077 // are public static so they can be called from utility functions that are
13078 // not members of the test fixture. Calls to RecordProperty made during
13079 // lifespan of the test (from the moment its constructor starts to the
13080 // moment its destructor finishes) will be output in XML as attributes of
13081 // the <testcase> element. Properties recorded from fixture's
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013082 // SetUpTestSuite or TearDownTestSuite are logged as attributes of the
Austin Schuh70cc9552019-01-21 19:46:48 -080013083 // corresponding <testsuite> element. Calls to RecordProperty made in the
13084 // global context (before or after invocation of RUN_ALL_TESTS and from
13085 // SetUp/TearDown method of Environment objects registered with Google
13086 // Test) will be output as attributes of the <testsuites> element.
13087 static void RecordProperty(const std::string& key, const std::string& value);
13088 static void RecordProperty(const std::string& key, int value);
13089
13090 protected:
13091 // Creates a Test object.
13092 Test();
13093
13094 // Sets up the test fixture.
13095 virtual void SetUp();
13096
13097 // Tears down the test fixture.
13098 virtual void TearDown();
13099
13100 private:
13101 // Returns true iff the current test has the same fixture class as
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013102 // the first test in the current test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013103 static bool HasSameFixtureClass();
13104
13105 // Runs the test after the test fixture has been set up.
13106 //
13107 // A sub-class must implement this to define the test logic.
13108 //
13109 // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
13110 // Instead, use the TEST or TEST_F macro.
13111 virtual void TestBody() = 0;
13112
13113 // Sets up, executes, and tears down the test.
13114 void Run();
13115
13116 // Deletes self. We deliberately pick an unusual name for this
13117 // internal method to avoid clashing with names used in user TESTs.
13118 void DeleteSelf_() { delete this; }
13119
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013120 const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
Austin Schuh70cc9552019-01-21 19:46:48 -080013121
13122 // Often a user misspells SetUp() as Setup() and spends a long time
13123 // wondering why it is never called by Google Test. The declaration of
13124 // the following method is solely for catching such an error at
13125 // compile time:
13126 //
13127 // - The return type is deliberately chosen to be not void, so it
13128 // will be a conflict if void Setup() is declared in the user's
13129 // test fixture.
13130 //
13131 // - This method is private, so it will be another compiler error
13132 // if the method is called from the user's test fixture.
13133 //
13134 // DO NOT OVERRIDE THIS FUNCTION.
13135 //
13136 // If you see an error about overriding the following function or
13137 // about it being private, you have mis-spelled SetUp() as Setup().
13138 struct Setup_should_be_spelled_SetUp {};
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013139 virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
Austin Schuh70cc9552019-01-21 19:46:48 -080013140
13141 // We disallow copying Tests.
13142 GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
13143};
13144
13145typedef internal::TimeInMillis TimeInMillis;
13146
13147// A copyable object representing a user specified test property which can be
13148// output as a key/value string pair.
13149//
13150// Don't inherit from TestProperty as its destructor is not virtual.
13151class TestProperty {
13152 public:
13153 // C'tor. TestProperty does NOT have a default constructor.
13154 // Always use this constructor (with parameters) to create a
13155 // TestProperty object.
13156 TestProperty(const std::string& a_key, const std::string& a_value) :
13157 key_(a_key), value_(a_value) {
13158 }
13159
13160 // Gets the user supplied key.
13161 const char* key() const {
13162 return key_.c_str();
13163 }
13164
13165 // Gets the user supplied value.
13166 const char* value() const {
13167 return value_.c_str();
13168 }
13169
13170 // Sets a new value, overriding the one supplied in the constructor.
13171 void SetValue(const std::string& new_value) {
13172 value_ = new_value;
13173 }
13174
13175 private:
13176 // The key supplied by the user.
13177 std::string key_;
13178 // The value supplied by the user.
13179 std::string value_;
13180};
13181
13182// The result of a single Test. This includes a list of
13183// TestPartResults, a list of TestProperties, a count of how many
13184// death tests there are in the Test, and how much time it took to run
13185// the Test.
13186//
13187// TestResult is not copyable.
13188class GTEST_API_ TestResult {
13189 public:
13190 // Creates an empty TestResult.
13191 TestResult();
13192
13193 // D'tor. Do not inherit from TestResult.
13194 ~TestResult();
13195
13196 // Gets the number of all test parts. This is the sum of the number
13197 // of successful test parts and the number of failed test parts.
13198 int total_part_count() const;
13199
13200 // Returns the number of the test properties.
13201 int test_property_count() const;
13202
13203 // Returns true iff the test passed (i.e. no test part failed).
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013204 bool Passed() const { return !Skipped() && !Failed(); }
13205
13206 // Returns true iff the test was skipped.
13207 bool Skipped() const;
Austin Schuh70cc9552019-01-21 19:46:48 -080013208
13209 // Returns true iff the test failed.
13210 bool Failed() const;
13211
13212 // Returns true iff the test fatally failed.
13213 bool HasFatalFailure() const;
13214
13215 // Returns true iff the test has a non-fatal failure.
13216 bool HasNonfatalFailure() const;
13217
13218 // Returns the elapsed time, in milliseconds.
13219 TimeInMillis elapsed_time() const { return elapsed_time_; }
13220
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013221 // Returns the i-th test part result among all the results. i can range from 0
13222 // to total_part_count() - 1. If i is not in that range, aborts the program.
Austin Schuh70cc9552019-01-21 19:46:48 -080013223 const TestPartResult& GetTestPartResult(int i) const;
13224
13225 // Returns the i-th test property. i can range from 0 to
13226 // test_property_count() - 1. If i is not in that range, aborts the
13227 // program.
13228 const TestProperty& GetTestProperty(int i) const;
13229
13230 private:
13231 friend class TestInfo;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013232 friend class TestSuite;
Austin Schuh70cc9552019-01-21 19:46:48 -080013233 friend class UnitTest;
13234 friend class internal::DefaultGlobalTestPartResultReporter;
13235 friend class internal::ExecDeathTest;
13236 friend class internal::TestResultAccessor;
13237 friend class internal::UnitTestImpl;
13238 friend class internal::WindowsDeathTest;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013239 friend class internal::FuchsiaDeathTest;
Austin Schuh70cc9552019-01-21 19:46:48 -080013240
13241 // Gets the vector of TestPartResults.
13242 const std::vector<TestPartResult>& test_part_results() const {
13243 return test_part_results_;
13244 }
13245
13246 // Gets the vector of TestProperties.
13247 const std::vector<TestProperty>& test_properties() const {
13248 return test_properties_;
13249 }
13250
13251 // Sets the elapsed time.
13252 void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
13253
13254 // Adds a test property to the list. The property is validated and may add
13255 // a non-fatal failure if invalid (e.g., if it conflicts with reserved
13256 // key names). If a property is already recorded for the same key, the
13257 // value will be updated, rather than storing multiple values for the same
13258 // key. xml_element specifies the element for which the property is being
13259 // recorded and is used for validation.
13260 void RecordProperty(const std::string& xml_element,
13261 const TestProperty& test_property);
13262
13263 // Adds a failure if the key is a reserved attribute of Google Test
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013264 // testsuite tags. Returns true if the property is valid.
13265 // FIXME: Validate attribute names are legal and human readable.
Austin Schuh70cc9552019-01-21 19:46:48 -080013266 static bool ValidateTestProperty(const std::string& xml_element,
13267 const TestProperty& test_property);
13268
13269 // Adds a test part result to the list.
13270 void AddTestPartResult(const TestPartResult& test_part_result);
13271
13272 // Returns the death test count.
13273 int death_test_count() const { return death_test_count_; }
13274
13275 // Increments the death test count, returning the new count.
13276 int increment_death_test_count() { return ++death_test_count_; }
13277
13278 // Clears the test part results.
13279 void ClearTestPartResults();
13280
13281 // Clears the object.
13282 void Clear();
13283
13284 // Protects mutable state of the property vector and of owned
13285 // properties, whose values may be updated.
13286 internal::Mutex test_properites_mutex_;
13287
13288 // The vector of TestPartResults
13289 std::vector<TestPartResult> test_part_results_;
13290 // The vector of TestProperties
13291 std::vector<TestProperty> test_properties_;
13292 // Running count of death tests.
13293 int death_test_count_;
13294 // The elapsed time, in milliseconds.
13295 TimeInMillis elapsed_time_;
13296
13297 // We disallow copying TestResult.
13298 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
13299}; // class TestResult
13300
13301// A TestInfo object stores the following information about a test:
13302//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013303// Test suite name
Austin Schuh70cc9552019-01-21 19:46:48 -080013304// Test name
13305// Whether the test should be run
13306// A function pointer that creates the test object when invoked
13307// Test result
13308//
13309// The constructor of TestInfo registers itself with the UnitTest
13310// singleton such that the RUN_ALL_TESTS() macro knows which tests to
13311// run.
13312class GTEST_API_ TestInfo {
13313 public:
13314 // Destructs a TestInfo object. This function is not virtual, so
13315 // don't inherit from TestInfo.
13316 ~TestInfo();
13317
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013318 // Returns the test suite name.
13319 const char* test_suite_name() const { return test_suite_name_.c_str(); }
13320
13321// Legacy API is deprecated but still available
13322#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13323 const char* test_case_name() const { return test_suite_name(); }
13324#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013325
13326 // Returns the test name.
13327 const char* name() const { return name_.c_str(); }
13328
13329 // Returns the name of the parameter type, or NULL if this is not a typed
13330 // or a type-parameterized test.
13331 const char* type_param() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013332 if (type_param_.get() != nullptr) return type_param_->c_str();
13333 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -080013334 }
13335
13336 // Returns the text representation of the value parameter, or NULL if this
13337 // is not a value-parameterized test.
13338 const char* value_param() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013339 if (value_param_.get() != nullptr) return value_param_->c_str();
13340 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -080013341 }
13342
13343 // Returns the file name where this test is defined.
13344 const char* file() const { return location_.file.c_str(); }
13345
13346 // Returns the line where this test is defined.
13347 int line() const { return location_.line; }
13348
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013349 // Return true if this test should not be run because it's in another shard.
13350 bool is_in_another_shard() const { return is_in_another_shard_; }
13351
Austin Schuh70cc9552019-01-21 19:46:48 -080013352 // Returns true if this test should run, that is if the test is not
13353 // disabled (or it is disabled but the also_run_disabled_tests flag has
13354 // been specified) and its full name matches the user-specified filter.
13355 //
13356 // Google Test allows the user to filter the tests by their full names.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013357 // The full name of a test Bar in test suite Foo is defined as
Austin Schuh70cc9552019-01-21 19:46:48 -080013358 // "Foo.Bar". Only the tests that match the filter will run.
13359 //
13360 // A filter is a colon-separated list of glob (not regex) patterns,
13361 // optionally followed by a '-' and a colon-separated list of
13362 // negative patterns (tests to exclude). A test is run if it
13363 // matches one of the positive patterns and does not match any of
13364 // the negative patterns.
13365 //
13366 // For example, *A*:Foo.* is a filter that matches any string that
13367 // contains the character 'A' or starts with "Foo.".
13368 bool should_run() const { return should_run_; }
13369
13370 // Returns true iff this test will appear in the XML report.
13371 bool is_reportable() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013372 // The XML report includes tests matching the filter, excluding those
13373 // run in other shards.
13374 return matches_filter_ && !is_in_another_shard_;
Austin Schuh70cc9552019-01-21 19:46:48 -080013375 }
13376
13377 // Returns the result of the test.
13378 const TestResult* result() const { return &result_; }
13379
13380 private:
13381#if GTEST_HAS_DEATH_TEST
13382 friend class internal::DefaultDeathTestFactory;
13383#endif // GTEST_HAS_DEATH_TEST
13384 friend class Test;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013385 friend class TestSuite;
Austin Schuh70cc9552019-01-21 19:46:48 -080013386 friend class internal::UnitTestImpl;
13387 friend class internal::StreamingListenerTest;
13388 friend TestInfo* internal::MakeAndRegisterTestInfo(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013389 const char* test_suite_name, const char* name, const char* type_param,
13390 const char* value_param, internal::CodeLocation code_location,
13391 internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
13392 internal::TearDownTestSuiteFunc tear_down_tc,
Austin Schuh70cc9552019-01-21 19:46:48 -080013393 internal::TestFactoryBase* factory);
13394
13395 // Constructs a TestInfo object. The newly constructed instance assumes
13396 // ownership of the factory object.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013397 TestInfo(const std::string& test_suite_name, const std::string& name,
Austin Schuh70cc9552019-01-21 19:46:48 -080013398 const char* a_type_param, // NULL if not a type-parameterized test
13399 const char* a_value_param, // NULL if not a value-parameterized test
13400 internal::CodeLocation a_code_location,
13401 internal::TypeId fixture_class_id,
13402 internal::TestFactoryBase* factory);
13403
13404 // Increments the number of death tests encountered in this test so
13405 // far.
13406 int increment_death_test_count() {
13407 return result_.increment_death_test_count();
13408 }
13409
13410 // Creates the test object, runs it, records its result, and then
13411 // deletes it.
13412 void Run();
13413
13414 static void ClearTestResult(TestInfo* test_info) {
13415 test_info->result_.Clear();
13416 }
13417
13418 // These fields are immutable properties of the test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013419 const std::string test_suite_name_; // test suite name
Austin Schuh70cc9552019-01-21 19:46:48 -080013420 const std::string name_; // Test name
13421 // Name of the parameter type, or NULL if this is not a typed or a
13422 // type-parameterized test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013423 const std::unique_ptr<const ::std::string> type_param_;
Austin Schuh70cc9552019-01-21 19:46:48 -080013424 // Text representation of the value parameter, or NULL if this is not a
13425 // value-parameterized test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013426 const std::unique_ptr<const ::std::string> value_param_;
Austin Schuh70cc9552019-01-21 19:46:48 -080013427 internal::CodeLocation location_;
13428 const internal::TypeId fixture_class_id_; // ID of the test fixture class
13429 bool should_run_; // True iff this test should run
13430 bool is_disabled_; // True iff this test is disabled
13431 bool matches_filter_; // True if this test matches the
13432 // user-specified filter.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013433 bool is_in_another_shard_; // Will be run in another shard.
Austin Schuh70cc9552019-01-21 19:46:48 -080013434 internal::TestFactoryBase* const factory_; // The factory that creates
13435 // the test object
13436
13437 // This field is mutable and needs to be reset before running the
13438 // test for the second time.
13439 TestResult result_;
13440
13441 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
13442};
13443
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013444// A test suite, which consists of a vector of TestInfos.
Austin Schuh70cc9552019-01-21 19:46:48 -080013445//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013446// TestSuite is not copyable.
13447class GTEST_API_ TestSuite {
Austin Schuh70cc9552019-01-21 19:46:48 -080013448 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013449 // Creates a TestSuite with the given name.
Austin Schuh70cc9552019-01-21 19:46:48 -080013450 //
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013451 // TestSuite does NOT have a default constructor. Always use this
13452 // constructor to create a TestSuite object.
Austin Schuh70cc9552019-01-21 19:46:48 -080013453 //
13454 // Arguments:
13455 //
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013456 // name: name of the test suite
Austin Schuh70cc9552019-01-21 19:46:48 -080013457 // a_type_param: the name of the test's type parameter, or NULL if
13458 // this is not a type-parameterized test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013459 // set_up_tc: pointer to the function that sets up the test suite
13460 // tear_down_tc: pointer to the function that tears down the test suite
13461 TestSuite(const char* name, const char* a_type_param,
13462 internal::SetUpTestSuiteFunc set_up_tc,
13463 internal::TearDownTestSuiteFunc tear_down_tc);
Austin Schuh70cc9552019-01-21 19:46:48 -080013464
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013465 // Destructor of TestSuite.
13466 virtual ~TestSuite();
Austin Schuh70cc9552019-01-21 19:46:48 -080013467
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013468 // Gets the name of the TestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013469 const char* name() const { return name_.c_str(); }
13470
13471 // Returns the name of the parameter type, or NULL if this is not a
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013472 // type-parameterized test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013473 const char* type_param() const {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013474 if (type_param_.get() != nullptr) return type_param_->c_str();
13475 return nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -080013476 }
13477
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013478 // Returns true if any test in this test suite should run.
Austin Schuh70cc9552019-01-21 19:46:48 -080013479 bool should_run() const { return should_run_; }
13480
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013481 // Gets the number of successful tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013482 int successful_test_count() const;
13483
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013484 // Gets the number of skipped tests in this test suite.
13485 int skipped_test_count() const;
13486
13487 // Gets the number of failed tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013488 int failed_test_count() const;
13489
13490 // Gets the number of disabled tests that will be reported in the XML report.
13491 int reportable_disabled_test_count() const;
13492
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013493 // Gets the number of disabled tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013494 int disabled_test_count() const;
13495
13496 // Gets the number of tests to be printed in the XML report.
13497 int reportable_test_count() const;
13498
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013499 // Get the number of tests in this test suite that should run.
Austin Schuh70cc9552019-01-21 19:46:48 -080013500 int test_to_run_count() const;
13501
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013502 // Gets the number of all tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013503 int total_test_count() const;
13504
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013505 // Returns true iff the test suite passed.
Austin Schuh70cc9552019-01-21 19:46:48 -080013506 bool Passed() const { return !Failed(); }
13507
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013508 // Returns true iff the test suite failed.
Austin Schuh70cc9552019-01-21 19:46:48 -080013509 bool Failed() const { return failed_test_count() > 0; }
13510
13511 // Returns the elapsed time, in milliseconds.
13512 TimeInMillis elapsed_time() const { return elapsed_time_; }
13513
13514 // Returns the i-th test among all the tests. i can range from 0 to
13515 // total_test_count() - 1. If i is not in that range, returns NULL.
13516 const TestInfo* GetTestInfo(int i) const;
13517
13518 // Returns the TestResult that holds test properties recorded during
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013519 // execution of SetUpTestSuite and TearDownTestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013520 const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
13521
13522 private:
13523 friend class Test;
13524 friend class internal::UnitTestImpl;
13525
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013526 // Gets the (mutable) vector of TestInfos in this TestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013527 std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
13528
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013529 // Gets the (immutable) vector of TestInfos in this TestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013530 const std::vector<TestInfo*>& test_info_list() const {
13531 return test_info_list_;
13532 }
13533
13534 // Returns the i-th test among all the tests. i can range from 0 to
13535 // total_test_count() - 1. If i is not in that range, returns NULL.
13536 TestInfo* GetMutableTestInfo(int i);
13537
13538 // Sets the should_run member.
13539 void set_should_run(bool should) { should_run_ = should; }
13540
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013541 // Adds a TestInfo to this test suite. Will delete the TestInfo upon
13542 // destruction of the TestSuite object.
Austin Schuh70cc9552019-01-21 19:46:48 -080013543 void AddTestInfo(TestInfo * test_info);
13544
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013545 // Clears the results of all tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013546 void ClearResult();
13547
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013548 // Clears the results of all tests in the given test suite.
13549 static void ClearTestSuiteResult(TestSuite* test_suite) {
13550 test_suite->ClearResult();
Austin Schuh70cc9552019-01-21 19:46:48 -080013551 }
13552
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013553 // Runs every test in this TestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013554 void Run();
13555
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013556 // Runs SetUpTestSuite() for this TestSuite. This wrapper is needed
13557 // for catching exceptions thrown from SetUpTestSuite().
13558 void RunSetUpTestSuite() {
13559 if (set_up_tc_ != nullptr) {
13560 (*set_up_tc_)();
13561 }
13562 }
Austin Schuh70cc9552019-01-21 19:46:48 -080013563
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013564 // Runs TearDownTestSuite() for this TestSuite. This wrapper is
13565 // needed for catching exceptions thrown from TearDownTestSuite().
13566 void RunTearDownTestSuite() {
13567 if (tear_down_tc_ != nullptr) {
13568 (*tear_down_tc_)();
13569 }
13570 }
Austin Schuh70cc9552019-01-21 19:46:48 -080013571
13572 // Returns true iff test passed.
13573 static bool TestPassed(const TestInfo* test_info) {
13574 return test_info->should_run() && test_info->result()->Passed();
13575 }
13576
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013577 // Returns true iff test skipped.
13578 static bool TestSkipped(const TestInfo* test_info) {
13579 return test_info->should_run() && test_info->result()->Skipped();
13580 }
13581
Austin Schuh70cc9552019-01-21 19:46:48 -080013582 // Returns true iff test failed.
13583 static bool TestFailed(const TestInfo* test_info) {
13584 return test_info->should_run() && test_info->result()->Failed();
13585 }
13586
13587 // Returns true iff the test is disabled and will be reported in the XML
13588 // report.
13589 static bool TestReportableDisabled(const TestInfo* test_info) {
13590 return test_info->is_reportable() && test_info->is_disabled_;
13591 }
13592
13593 // Returns true iff test is disabled.
13594 static bool TestDisabled(const TestInfo* test_info) {
13595 return test_info->is_disabled_;
13596 }
13597
13598 // Returns true iff this test will appear in the XML report.
13599 static bool TestReportable(const TestInfo* test_info) {
13600 return test_info->is_reportable();
13601 }
13602
13603 // Returns true if the given test should run.
13604 static bool ShouldRunTest(const TestInfo* test_info) {
13605 return test_info->should_run();
13606 }
13607
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013608 // Shuffles the tests in this test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013609 void ShuffleTests(internal::Random* random);
13610
13611 // Restores the test order to before the first shuffle.
13612 void UnshuffleTests();
13613
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013614 // Name of the test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013615 std::string name_;
13616 // Name of the parameter type, or NULL if this is not a typed or a
13617 // type-parameterized test.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013618 const std::unique_ptr<const ::std::string> type_param_;
Austin Schuh70cc9552019-01-21 19:46:48 -080013619 // The vector of TestInfos in their original order. It owns the
13620 // elements in the vector.
13621 std::vector<TestInfo*> test_info_list_;
13622 // Provides a level of indirection for the test list to allow easy
13623 // shuffling and restoring the test order. The i-th element in this
13624 // vector is the index of the i-th test in the shuffled test list.
13625 std::vector<int> test_indices_;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013626 // Pointer to the function that sets up the test suite.
13627 internal::SetUpTestSuiteFunc set_up_tc_;
13628 // Pointer to the function that tears down the test suite.
13629 internal::TearDownTestSuiteFunc tear_down_tc_;
13630 // True iff any test in this test suite should run.
Austin Schuh70cc9552019-01-21 19:46:48 -080013631 bool should_run_;
13632 // Elapsed time, in milliseconds.
13633 TimeInMillis elapsed_time_;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013634 // Holds test properties recorded during execution of SetUpTestSuite and
13635 // TearDownTestSuite.
Austin Schuh70cc9552019-01-21 19:46:48 -080013636 TestResult ad_hoc_test_result_;
13637
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013638 // We disallow copying TestSuites.
13639 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
Austin Schuh70cc9552019-01-21 19:46:48 -080013640};
13641
13642// An Environment object is capable of setting up and tearing down an
13643// environment. You should subclass this to define your own
13644// environment(s).
13645//
13646// An Environment object does the set-up and tear-down in virtual
13647// methods SetUp() and TearDown() instead of the constructor and the
13648// destructor, as:
13649//
13650// 1. You cannot safely throw from a destructor. This is a problem
13651// as in some cases Google Test is used where exceptions are enabled, and
13652// we may want to implement ASSERT_* using exceptions where they are
13653// available.
13654// 2. You cannot use ASSERT_* directly in a constructor or
13655// destructor.
13656class Environment {
13657 public:
13658 // The d'tor is virtual as we need to subclass Environment.
13659 virtual ~Environment() {}
13660
13661 // Override this to define how to set up the environment.
13662 virtual void SetUp() {}
13663
13664 // Override this to define how to tear down the environment.
13665 virtual void TearDown() {}
13666 private:
13667 // If you see an error about overriding the following function or
13668 // about it being private, you have mis-spelled SetUp() as Setup().
13669 struct Setup_should_be_spelled_SetUp {};
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013670 virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
Austin Schuh70cc9552019-01-21 19:46:48 -080013671};
13672
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013673#if GTEST_HAS_EXCEPTIONS
13674
13675// Exception which can be thrown from TestEventListener::OnTestPartResult.
13676class GTEST_API_ AssertionException
13677 : public internal::GoogleTestFailureException {
13678 public:
13679 explicit AssertionException(const TestPartResult& result)
13680 : GoogleTestFailureException(result) {}
13681};
13682
13683#endif // GTEST_HAS_EXCEPTIONS
13684
Austin Schuh70cc9552019-01-21 19:46:48 -080013685// The interface for tracing execution of tests. The methods are organized in
13686// the order the corresponding events are fired.
13687class TestEventListener {
13688 public:
13689 virtual ~TestEventListener() {}
13690
13691 // Fired before any test activity starts.
13692 virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
13693
13694 // Fired before each iteration of tests starts. There may be more than
13695 // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
13696 // index, starting from 0.
13697 virtual void OnTestIterationStart(const UnitTest& unit_test,
13698 int iteration) = 0;
13699
13700 // Fired before environment set-up for each iteration of tests starts.
13701 virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
13702
13703 // Fired after environment set-up for each iteration of tests ends.
13704 virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
13705
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013706 // Fired before the test suite starts.
13707 virtual void OnTestSuiteStart(const TestSuite& /*test_suite*/) {}
13708
13709 // Legacy API is deprecated but still available
13710#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13711 virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
13712#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013713
13714 // Fired before the test starts.
13715 virtual void OnTestStart(const TestInfo& test_info) = 0;
13716
13717 // Fired after a failed assertion or a SUCCEED() invocation.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013718 // If you want to throw an exception from this function to skip to the next
13719 // TEST, it must be AssertionException defined above, or inherited from it.
Austin Schuh70cc9552019-01-21 19:46:48 -080013720 virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
13721
13722 // Fired after the test ends.
13723 virtual void OnTestEnd(const TestInfo& test_info) = 0;
13724
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013725 // Fired after the test suite ends.
13726 virtual void OnTestSuiteEnd(const TestSuite& /*test_suite*/) {}
13727
13728// Legacy API is deprecated but still available
13729#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13730 virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
13731#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013732
13733 // Fired before environment tear-down for each iteration of tests starts.
13734 virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
13735
13736 // Fired after environment tear-down for each iteration of tests ends.
13737 virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
13738
13739 // Fired after each iteration of tests finishes.
13740 virtual void OnTestIterationEnd(const UnitTest& unit_test,
13741 int iteration) = 0;
13742
13743 // Fired after all test activities have ended.
13744 virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
13745};
13746
13747// The convenience class for users who need to override just one or two
13748// methods and are not concerned that a possible change to a signature of
13749// the methods they override will not be caught during the build. For
13750// comments about each method please see the definition of TestEventListener
13751// above.
13752class EmptyTestEventListener : public TestEventListener {
13753 public:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013754 void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
13755 void OnTestIterationStart(const UnitTest& /*unit_test*/,
13756 int /*iteration*/) override {}
13757 void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
13758 void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
13759 void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}
13760// Legacy API is deprecated but still available
13761#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13762 void OnTestCaseStart(const TestCase& /*test_case*/) override {}
13763#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13764
13765 void OnTestStart(const TestInfo& /*test_info*/) override {}
13766 void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
13767 void OnTestEnd(const TestInfo& /*test_info*/) override {}
13768 void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}
13769#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13770 void OnTestCaseEnd(const TestCase& /*test_case*/) override {}
13771#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13772
13773 void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
13774 void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
13775 void OnTestIterationEnd(const UnitTest& /*unit_test*/,
13776 int /*iteration*/) override {}
13777 void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
Austin Schuh70cc9552019-01-21 19:46:48 -080013778};
13779
13780// TestEventListeners lets users add listeners to track events in Google Test.
13781class GTEST_API_ TestEventListeners {
13782 public:
13783 TestEventListeners();
13784 ~TestEventListeners();
13785
13786 // Appends an event listener to the end of the list. Google Test assumes
13787 // the ownership of the listener (i.e. it will delete the listener when
13788 // the test program finishes).
13789 void Append(TestEventListener* listener);
13790
13791 // Removes the given event listener from the list and returns it. It then
13792 // becomes the caller's responsibility to delete the listener. Returns
13793 // NULL if the listener is not found in the list.
13794 TestEventListener* Release(TestEventListener* listener);
13795
13796 // Returns the standard listener responsible for the default console
13797 // output. Can be removed from the listeners list to shut down default
13798 // console output. Note that removing this object from the listener list
13799 // with Release transfers its ownership to the caller and makes this
13800 // function return NULL the next time.
13801 TestEventListener* default_result_printer() const {
13802 return default_result_printer_;
13803 }
13804
13805 // Returns the standard listener responsible for the default XML output
13806 // controlled by the --gtest_output=xml flag. Can be removed from the
13807 // listeners list by users who want to shut down the default XML output
13808 // controlled by this flag and substitute it with custom one. Note that
13809 // removing this object from the listener list with Release transfers its
13810 // ownership to the caller and makes this function return NULL the next
13811 // time.
13812 TestEventListener* default_xml_generator() const {
13813 return default_xml_generator_;
13814 }
13815
13816 private:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013817 friend class TestSuite;
Austin Schuh70cc9552019-01-21 19:46:48 -080013818 friend class TestInfo;
13819 friend class internal::DefaultGlobalTestPartResultReporter;
13820 friend class internal::NoExecDeathTest;
13821 friend class internal::TestEventListenersAccessor;
13822 friend class internal::UnitTestImpl;
13823
13824 // Returns repeater that broadcasts the TestEventListener events to all
13825 // subscribers.
13826 TestEventListener* repeater();
13827
13828 // Sets the default_result_printer attribute to the provided listener.
13829 // The listener is also added to the listener list and previous
13830 // default_result_printer is removed from it and deleted. The listener can
13831 // also be NULL in which case it will not be added to the list. Does
13832 // nothing if the previous and the current listener objects are the same.
13833 void SetDefaultResultPrinter(TestEventListener* listener);
13834
13835 // Sets the default_xml_generator attribute to the provided listener. The
13836 // listener is also added to the listener list and previous
13837 // default_xml_generator is removed from it and deleted. The listener can
13838 // also be NULL in which case it will not be added to the list. Does
13839 // nothing if the previous and the current listener objects are the same.
13840 void SetDefaultXmlGenerator(TestEventListener* listener);
13841
13842 // Controls whether events will be forwarded by the repeater to the
13843 // listeners in the list.
13844 bool EventForwardingEnabled() const;
13845 void SuppressEventForwarding();
13846
13847 // The actual list of listeners.
13848 internal::TestEventRepeater* repeater_;
13849 // Listener responsible for the standard result output.
13850 TestEventListener* default_result_printer_;
13851 // Listener responsible for the creation of the XML output file.
13852 TestEventListener* default_xml_generator_;
13853
13854 // We disallow copying TestEventListeners.
13855 GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
13856};
13857
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013858// A UnitTest consists of a vector of TestSuites.
Austin Schuh70cc9552019-01-21 19:46:48 -080013859//
13860// This is a singleton class. The only instance of UnitTest is
13861// created when UnitTest::GetInstance() is first called. This
13862// instance is never deleted.
13863//
13864// UnitTest is not copyable.
13865//
13866// This class is thread-safe as long as the methods are called
13867// according to their specification.
13868class GTEST_API_ UnitTest {
13869 public:
13870 // Gets the singleton UnitTest object. The first time this method
13871 // is called, a UnitTest object is constructed and returned.
13872 // Consecutive calls will return the same object.
13873 static UnitTest* GetInstance();
13874
13875 // Runs all tests in this UnitTest object and prints the result.
13876 // Returns 0 if successful, or 1 otherwise.
13877 //
13878 // This method can only be called from the main thread.
13879 //
13880 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
13881 int Run() GTEST_MUST_USE_RESULT_;
13882
13883 // Returns the working directory when the first TEST() or TEST_F()
13884 // was executed. The UnitTest object owns the string.
13885 const char* original_working_dir() const;
13886
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013887 // Returns the TestSuite object for the test that's currently running,
Austin Schuh70cc9552019-01-21 19:46:48 -080013888 // or NULL if no test is running.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013889 const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
13890
13891// Legacy API is still available but deprecated
13892#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13893 const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);
13894#endif
Austin Schuh70cc9552019-01-21 19:46:48 -080013895
13896 // Returns the TestInfo object for the test that's currently running,
13897 // or NULL if no test is running.
13898 const TestInfo* current_test_info() const
13899 GTEST_LOCK_EXCLUDED_(mutex_);
13900
13901 // Returns the random seed used at the start of the current test run.
13902 int random_seed() const;
13903
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013904 // Returns the ParameterizedTestSuiteRegistry object used to keep track of
Austin Schuh70cc9552019-01-21 19:46:48 -080013905 // value-parameterized tests and instantiate and register them.
13906 //
13907 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013908 internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
Austin Schuh70cc9552019-01-21 19:46:48 -080013909 GTEST_LOCK_EXCLUDED_(mutex_);
Austin Schuh70cc9552019-01-21 19:46:48 -080013910
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013911 // Gets the number of successful test suites.
13912 int successful_test_suite_count() const;
Austin Schuh70cc9552019-01-21 19:46:48 -080013913
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013914 // Gets the number of failed test suites.
13915 int failed_test_suite_count() const;
Austin Schuh70cc9552019-01-21 19:46:48 -080013916
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013917 // Gets the number of all test suites.
13918 int total_test_suite_count() const;
Austin Schuh70cc9552019-01-21 19:46:48 -080013919
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013920 // Gets the number of all test suites that contain at least one test
Austin Schuh70cc9552019-01-21 19:46:48 -080013921 // that should run.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013922 int test_suite_to_run_count() const;
13923
13924 // Legacy API is deprecated but still available
13925#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
13926 int successful_test_case_count() const;
13927 int failed_test_case_count() const;
13928 int total_test_case_count() const;
Austin Schuh70cc9552019-01-21 19:46:48 -080013929 int test_case_to_run_count() const;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013930#endif // EMOVE_LEGACY_TEST_CASEAPI
Austin Schuh70cc9552019-01-21 19:46:48 -080013931
13932 // Gets the number of successful tests.
13933 int successful_test_count() const;
13934
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013935 // Gets the number of skipped tests.
13936 int skipped_test_count() const;
13937
Austin Schuh70cc9552019-01-21 19:46:48 -080013938 // Gets the number of failed tests.
13939 int failed_test_count() const;
13940
13941 // Gets the number of disabled tests that will be reported in the XML report.
13942 int reportable_disabled_test_count() const;
13943
13944 // Gets the number of disabled tests.
13945 int disabled_test_count() const;
13946
13947 // Gets the number of tests to be printed in the XML report.
13948 int reportable_test_count() const;
13949
13950 // Gets the number of all tests.
13951 int total_test_count() const;
13952
13953 // Gets the number of tests that should run.
13954 int test_to_run_count() const;
13955
13956 // Gets the time of the test program start, in ms from the start of the
13957 // UNIX epoch.
13958 TimeInMillis start_timestamp() const;
13959
13960 // Gets the elapsed time, in milliseconds.
13961 TimeInMillis elapsed_time() const;
13962
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013963 // Returns true iff the unit test passed (i.e. all test suites passed).
Austin Schuh70cc9552019-01-21 19:46:48 -080013964 bool Passed() const;
13965
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013966 // Returns true iff the unit test failed (i.e. some test suite failed
Austin Schuh70cc9552019-01-21 19:46:48 -080013967 // or something outside of all tests failed).
13968 bool Failed() const;
13969
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013970 // Gets the i-th test suite among all the test suites. i can range from 0 to
13971 // total_test_suite_count() - 1. If i is not in that range, returns NULL.
13972 const TestSuite* GetTestSuite(int i) const;
13973
13974// Legacy API is deprecated but still available
13975#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013976 const TestCase* GetTestCase(int i) const;
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013977#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
Austin Schuh70cc9552019-01-21 19:46:48 -080013978
13979 // Returns the TestResult containing information on test failures and
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080013980 // properties logged outside of individual test suites.
Austin Schuh70cc9552019-01-21 19:46:48 -080013981 const TestResult& ad_hoc_test_result() const;
13982
13983 // Returns the list of event listeners that can be used to track events
13984 // inside Google Test.
13985 TestEventListeners& listeners();
13986
13987 private:
13988 // Registers and returns a global test environment. When a test
13989 // program is run, all global test environments will be set-up in
13990 // the order they were registered. After all tests in the program
13991 // have finished, all global test environments will be torn-down in
13992 // the *reverse* order they were registered.
13993 //
13994 // The UnitTest object takes ownership of the given environment.
13995 //
13996 // This method can only be called from the main thread.
13997 Environment* AddEnvironment(Environment* env);
13998
13999 // Adds a TestPartResult to the current TestResult object. All
14000 // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
14001 // eventually call this to report their results. The user code
14002 // should use the assertion macros instead of calling this directly.
14003 void AddTestPartResult(TestPartResult::Type result_type,
14004 const char* file_name,
14005 int line_number,
14006 const std::string& message,
14007 const std::string& os_stack_trace)
14008 GTEST_LOCK_EXCLUDED_(mutex_);
14009
14010 // Adds a TestProperty to the current TestResult object when invoked from
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014011 // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked
14012 // from SetUpTestSuite or TearDownTestSuite, or to the global property set
Austin Schuh70cc9552019-01-21 19:46:48 -080014013 // when invoked elsewhere. If the result already contains a property with
14014 // the same key, the value will be updated.
14015 void RecordProperty(const std::string& key, const std::string& value);
14016
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014017 // Gets the i-th test suite among all the test suites. i can range from 0 to
14018 // total_test_suite_count() - 1. If i is not in that range, returns NULL.
14019 TestSuite* GetMutableTestSuite(int i);
Austin Schuh70cc9552019-01-21 19:46:48 -080014020
14021 // Accessors for the implementation object.
14022 internal::UnitTestImpl* impl() { return impl_; }
14023 const internal::UnitTestImpl* impl() const { return impl_; }
14024
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014025 // These classes and functions are friends as they need to access private
Austin Schuh70cc9552019-01-21 19:46:48 -080014026 // members of UnitTest.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014027 friend class ScopedTrace;
Austin Schuh70cc9552019-01-21 19:46:48 -080014028 friend class Test;
14029 friend class internal::AssertHelper;
Austin Schuh70cc9552019-01-21 19:46:48 -080014030 friend class internal::StreamingListenerTest;
14031 friend class internal::UnitTestRecordPropertyTestHelper;
14032 friend Environment* AddGlobalTestEnvironment(Environment* env);
14033 friend internal::UnitTestImpl* internal::GetUnitTestImpl();
14034 friend void internal::ReportFailureInUnknownLocation(
14035 TestPartResult::Type result_type,
14036 const std::string& message);
14037
14038 // Creates an empty UnitTest.
14039 UnitTest();
14040
14041 // D'tor
14042 virtual ~UnitTest();
14043
14044 // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
14045 // Google Test trace stack.
14046 void PushGTestTrace(const internal::TraceInfo& trace)
14047 GTEST_LOCK_EXCLUDED_(mutex_);
14048
14049 // Pops a trace from the per-thread Google Test trace stack.
14050 void PopGTestTrace()
14051 GTEST_LOCK_EXCLUDED_(mutex_);
14052
14053 // Protects mutable state in *impl_. This is mutable as some const
14054 // methods need to lock it too.
14055 mutable internal::Mutex mutex_;
14056
14057 // Opaque implementation object. This field is never changed once
14058 // the object is constructed. We don't mark it as const here, as
14059 // doing so will cause a warning in the constructor of UnitTest.
14060 // Mutable state in *impl_ is protected by mutex_.
14061 internal::UnitTestImpl* impl_;
14062
14063 // We disallow copying UnitTest.
14064 GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
14065};
14066
14067// A convenient wrapper for adding an environment for the test
14068// program.
14069//
14070// You should call this before RUN_ALL_TESTS() is called, probably in
14071// main(). If you use gtest_main, you need to call this before main()
14072// starts for it to take effect. For example, you can define a global
14073// variable like this:
14074//
14075// testing::Environment* const foo_env =
14076// testing::AddGlobalTestEnvironment(new FooEnvironment);
14077//
14078// However, we strongly recommend you to write your own main() and
14079// call AddGlobalTestEnvironment() there, as relying on initialization
14080// of global variables makes the code harder to read and may cause
14081// problems when you register multiple environments from different
14082// translation units and the environments have dependencies among them
14083// (remember that the compiler doesn't guarantee the order in which
14084// global variables from different translation units are initialized).
14085inline Environment* AddGlobalTestEnvironment(Environment* env) {
14086 return UnitTest::GetInstance()->AddEnvironment(env);
14087}
14088
14089// Initializes Google Test. This must be called before calling
14090// RUN_ALL_TESTS(). In particular, it parses a command line for the
14091// flags that Google Test recognizes. Whenever a Google Test flag is
14092// seen, it is removed from argv, and *argc is decremented.
14093//
14094// No value is returned. Instead, the Google Test flag variables are
14095// updated.
14096//
14097// Calling the function for the second time has no user-visible effect.
14098GTEST_API_ void InitGoogleTest(int* argc, char** argv);
14099
14100// This overloaded version can be used in Windows programs compiled in
14101// UNICODE mode.
14102GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
14103
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014104// This overloaded version can be used on Arduino/embedded platforms where
14105// there is no argc/argv.
14106GTEST_API_ void InitGoogleTest();
14107
Austin Schuh70cc9552019-01-21 19:46:48 -080014108namespace internal {
14109
14110// Separate the error generating code from the code path to reduce the stack
14111// frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers
14112// when calling EXPECT_* in a tight loop.
14113template <typename T1, typename T2>
14114AssertionResult CmpHelperEQFailure(const char* lhs_expression,
14115 const char* rhs_expression,
14116 const T1& lhs, const T2& rhs) {
14117 return EqFailure(lhs_expression,
14118 rhs_expression,
14119 FormatForComparisonFailureMessage(lhs, rhs),
14120 FormatForComparisonFailureMessage(rhs, lhs),
14121 false);
14122}
14123
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014124// This block of code defines operator==/!=
14125// to block lexical scope lookup.
14126// It prevents using invalid operator==/!= defined at namespace scope.
14127struct faketype {};
14128inline bool operator==(faketype, faketype) { return true; }
14129inline bool operator!=(faketype, faketype) { return false; }
14130
Austin Schuh70cc9552019-01-21 19:46:48 -080014131// The helper function for {ASSERT|EXPECT}_EQ.
14132template <typename T1, typename T2>
14133AssertionResult CmpHelperEQ(const char* lhs_expression,
14134 const char* rhs_expression,
14135 const T1& lhs,
14136 const T2& rhs) {
Austin Schuh70cc9552019-01-21 19:46:48 -080014137 if (lhs == rhs) {
14138 return AssertionSuccess();
14139 }
Austin Schuh70cc9552019-01-21 19:46:48 -080014140
14141 return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
14142}
14143
14144// With this overloaded version, we allow anonymous enums to be used
14145// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
14146// can be implicitly cast to BiggestInt.
14147GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
14148 const char* rhs_expression,
14149 BiggestInt lhs,
14150 BiggestInt rhs);
14151
14152// The helper class for {ASSERT|EXPECT}_EQ. The template argument
14153// lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
14154// is a null pointer literal. The following default implementation is
14155// for lhs_is_null_literal being false.
14156template <bool lhs_is_null_literal>
14157class EqHelper {
14158 public:
14159 // This templatized version is for the general case.
14160 template <typename T1, typename T2>
14161 static AssertionResult Compare(const char* lhs_expression,
14162 const char* rhs_expression,
14163 const T1& lhs,
14164 const T2& rhs) {
14165 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
14166 }
14167
14168 // With this overloaded version, we allow anonymous enums to be used
14169 // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
14170 // enums can be implicitly cast to BiggestInt.
14171 //
14172 // Even though its body looks the same as the above version, we
14173 // cannot merge the two, as it will make anonymous enums unhappy.
14174 static AssertionResult Compare(const char* lhs_expression,
14175 const char* rhs_expression,
14176 BiggestInt lhs,
14177 BiggestInt rhs) {
14178 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
14179 }
14180};
14181
14182// This specialization is used when the first argument to ASSERT_EQ()
14183// is a null pointer literal, like NULL, false, or 0.
14184template <>
14185class EqHelper<true> {
14186 public:
14187 // We define two overloaded versions of Compare(). The first
14188 // version will be picked when the second argument to ASSERT_EQ() is
14189 // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
14190 // EXPECT_EQ(false, a_bool).
14191 template <typename T1, typename T2>
14192 static AssertionResult Compare(
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014193 const char* lhs_expression, const char* rhs_expression, const T1& lhs,
Austin Schuh70cc9552019-01-21 19:46:48 -080014194 const T2& rhs,
14195 // The following line prevents this overload from being considered if T2
14196 // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)
14197 // expands to Compare("", "", NULL, my_ptr), which requires a conversion
14198 // to match the Secret* in the other overload, which would otherwise make
14199 // this template match better.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014200 typename EnableIf<!std::is_pointer<T2>::value>::type* = nullptr) {
Austin Schuh70cc9552019-01-21 19:46:48 -080014201 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
14202 }
14203
14204 // This version will be picked when the second argument to ASSERT_EQ() is a
14205 // pointer, e.g. ASSERT_EQ(NULL, a_pointer).
14206 template <typename T>
14207 static AssertionResult Compare(
14208 const char* lhs_expression,
14209 const char* rhs_expression,
14210 // We used to have a second template parameter instead of Secret*. That
14211 // template parameter would deduce to 'long', making this a better match
14212 // than the first overload even without the first overload's EnableIf.
14213 // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
14214 // non-pointer argument" (even a deduced integral argument), so the old
14215 // implementation caused warnings in user code.
14216 Secret* /* lhs (NULL) */,
14217 T* rhs) {
14218 // We already know that 'lhs' is a null pointer.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014219 return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
14220 rhs);
Austin Schuh70cc9552019-01-21 19:46:48 -080014221 }
14222};
14223
14224// Separate the error generating code from the code path to reduce the stack
14225// frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers
14226// when calling EXPECT_OP in a tight loop.
14227template <typename T1, typename T2>
14228AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
14229 const T1& val1, const T2& val2,
14230 const char* op) {
14231 return AssertionFailure()
14232 << "Expected: (" << expr1 << ") " << op << " (" << expr2
14233 << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
14234 << " vs " << FormatForComparisonFailureMessage(val2, val1);
14235}
14236
14237// A macro for implementing the helper functions needed to implement
14238// ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste
14239// of similar code.
14240//
14241// For each templatized helper function, we also define an overloaded
14242// version for BiggestInt in order to reduce code bloat and allow
14243// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
14244// with gcc 4.
14245//
14246// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14247
14248#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
14249template <typename T1, typename T2>\
14250AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
14251 const T1& val1, const T2& val2) {\
14252 if (val1 op val2) {\
14253 return AssertionSuccess();\
14254 } else {\
14255 return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
14256 }\
14257}\
14258GTEST_API_ AssertionResult CmpHelper##op_name(\
14259 const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
14260
14261// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14262
14263// Implements the helper function for {ASSERT|EXPECT}_NE
14264GTEST_IMPL_CMP_HELPER_(NE, !=);
14265// Implements the helper function for {ASSERT|EXPECT}_LE
14266GTEST_IMPL_CMP_HELPER_(LE, <=);
14267// Implements the helper function for {ASSERT|EXPECT}_LT
14268GTEST_IMPL_CMP_HELPER_(LT, <);
14269// Implements the helper function for {ASSERT|EXPECT}_GE
14270GTEST_IMPL_CMP_HELPER_(GE, >=);
14271// Implements the helper function for {ASSERT|EXPECT}_GT
14272GTEST_IMPL_CMP_HELPER_(GT, >);
14273
14274#undef GTEST_IMPL_CMP_HELPER_
14275
14276// The helper function for {ASSERT|EXPECT}_STREQ.
14277//
14278// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14279GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
14280 const char* s2_expression,
14281 const char* s1,
14282 const char* s2);
14283
14284// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
14285//
14286// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14287GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
14288 const char* s2_expression,
14289 const char* s1,
14290 const char* s2);
14291
14292// The helper function for {ASSERT|EXPECT}_STRNE.
14293//
14294// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14295GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
14296 const char* s2_expression,
14297 const char* s1,
14298 const char* s2);
14299
14300// The helper function for {ASSERT|EXPECT}_STRCASENE.
14301//
14302// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14303GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
14304 const char* s2_expression,
14305 const char* s1,
14306 const char* s2);
14307
14308
14309// Helper function for *_STREQ on wide strings.
14310//
14311// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14312GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
14313 const char* s2_expression,
14314 const wchar_t* s1,
14315 const wchar_t* s2);
14316
14317// Helper function for *_STRNE on wide strings.
14318//
14319// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14320GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
14321 const char* s2_expression,
14322 const wchar_t* s1,
14323 const wchar_t* s2);
14324
14325} // namespace internal
14326
14327// IsSubstring() and IsNotSubstring() are intended to be used as the
14328// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
14329// themselves. They check whether needle is a substring of haystack
14330// (NULL is considered a substring of itself only), and return an
14331// appropriate error message when they fail.
14332//
14333// The {needle,haystack}_expr arguments are the stringified
14334// expressions that generated the two real arguments.
14335GTEST_API_ AssertionResult IsSubstring(
14336 const char* needle_expr, const char* haystack_expr,
14337 const char* needle, const char* haystack);
14338GTEST_API_ AssertionResult IsSubstring(
14339 const char* needle_expr, const char* haystack_expr,
14340 const wchar_t* needle, const wchar_t* haystack);
14341GTEST_API_ AssertionResult IsNotSubstring(
14342 const char* needle_expr, const char* haystack_expr,
14343 const char* needle, const char* haystack);
14344GTEST_API_ AssertionResult IsNotSubstring(
14345 const char* needle_expr, const char* haystack_expr,
14346 const wchar_t* needle, const wchar_t* haystack);
14347GTEST_API_ AssertionResult IsSubstring(
14348 const char* needle_expr, const char* haystack_expr,
14349 const ::std::string& needle, const ::std::string& haystack);
14350GTEST_API_ AssertionResult IsNotSubstring(
14351 const char* needle_expr, const char* haystack_expr,
14352 const ::std::string& needle, const ::std::string& haystack);
14353
14354#if GTEST_HAS_STD_WSTRING
14355GTEST_API_ AssertionResult IsSubstring(
14356 const char* needle_expr, const char* haystack_expr,
14357 const ::std::wstring& needle, const ::std::wstring& haystack);
14358GTEST_API_ AssertionResult IsNotSubstring(
14359 const char* needle_expr, const char* haystack_expr,
14360 const ::std::wstring& needle, const ::std::wstring& haystack);
14361#endif // GTEST_HAS_STD_WSTRING
14362
14363namespace internal {
14364
14365// Helper template function for comparing floating-points.
14366//
14367// Template parameter:
14368//
14369// RawType: the raw floating-point type (either float or double)
14370//
14371// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14372template <typename RawType>
14373AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
14374 const char* rhs_expression,
14375 RawType lhs_value,
14376 RawType rhs_value) {
14377 const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
14378
14379 if (lhs.AlmostEquals(rhs)) {
14380 return AssertionSuccess();
14381 }
14382
14383 ::std::stringstream lhs_ss;
14384 lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
14385 << lhs_value;
14386
14387 ::std::stringstream rhs_ss;
14388 rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
14389 << rhs_value;
14390
14391 return EqFailure(lhs_expression,
14392 rhs_expression,
14393 StringStreamToString(&lhs_ss),
14394 StringStreamToString(&rhs_ss),
14395 false);
14396}
14397
14398// Helper function for implementing ASSERT_NEAR.
14399//
14400// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
14401GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
14402 const char* expr2,
14403 const char* abs_error_expr,
14404 double val1,
14405 double val2,
14406 double abs_error);
14407
14408// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
14409// A class that enables one to stream messages to assertion macros
14410class GTEST_API_ AssertHelper {
14411 public:
14412 // Constructor.
14413 AssertHelper(TestPartResult::Type type,
14414 const char* file,
14415 int line,
14416 const char* message);
14417 ~AssertHelper();
14418
14419 // Message assignment is a semantic trick to enable assertion
14420 // streaming; see the GTEST_MESSAGE_ macro below.
14421 void operator=(const Message& message) const;
14422
14423 private:
14424 // We put our data in a struct so that the size of the AssertHelper class can
14425 // be as small as possible. This is important because gcc is incapable of
14426 // re-using stack space even for temporary variables, so every EXPECT_EQ
14427 // reserves stack space for another AssertHelper.
14428 struct AssertHelperData {
14429 AssertHelperData(TestPartResult::Type t,
14430 const char* srcfile,
14431 int line_num,
14432 const char* msg)
14433 : type(t), file(srcfile), line(line_num), message(msg) { }
14434
14435 TestPartResult::Type const type;
14436 const char* const file;
14437 int const line;
14438 std::string const message;
14439
14440 private:
14441 GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
14442 };
14443
14444 AssertHelperData* const data_;
14445
14446 GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
14447};
14448
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014449enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW };
14450
14451GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color,
14452 const char* fmt,
14453 ...);
14454
Austin Schuh70cc9552019-01-21 19:46:48 -080014455} // namespace internal
14456
Austin Schuh70cc9552019-01-21 19:46:48 -080014457// The pure interface class that all value-parameterized tests inherit from.
14458// A value-parameterized class must inherit from both ::testing::Test and
14459// ::testing::WithParamInterface. In most cases that just means inheriting
14460// from ::testing::TestWithParam, but more complicated test hierarchies
14461// may need to inherit from Test and WithParamInterface at different levels.
14462//
14463// This interface has support for accessing the test parameter value via
14464// the GetParam() method.
14465//
14466// Use it with one of the parameter generator defining functions, like Range(),
14467// Values(), ValuesIn(), Bool(), and Combine().
14468//
14469// class FooTest : public ::testing::TestWithParam<int> {
14470// protected:
14471// FooTest() {
14472// // Can use GetParam() here.
14473// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014474// ~FooTest() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080014475// // Can use GetParam() here.
14476// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014477// void SetUp() override {
Austin Schuh70cc9552019-01-21 19:46:48 -080014478// // Can use GetParam() here.
14479// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014480// void TearDown override {
Austin Schuh70cc9552019-01-21 19:46:48 -080014481// // Can use GetParam() here.
14482// }
14483// };
14484// TEST_P(FooTest, DoesBar) {
14485// // Can use GetParam() method here.
14486// Foo foo;
14487// ASSERT_TRUE(foo.DoesBar(GetParam()));
14488// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014489// INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
Austin Schuh70cc9552019-01-21 19:46:48 -080014490
14491template <typename T>
14492class WithParamInterface {
14493 public:
14494 typedef T ParamType;
14495 virtual ~WithParamInterface() {}
14496
14497 // The current parameter value. Is also available in the test fixture's
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014498 // constructor.
14499 static const ParamType& GetParam() {
14500 GTEST_CHECK_(parameter_ != nullptr)
Austin Schuh70cc9552019-01-21 19:46:48 -080014501 << "GetParam() can only be called inside a value-parameterized test "
14502 << "-- did you intend to write TEST_P instead of TEST_F?";
14503 return *parameter_;
14504 }
14505
14506 private:
14507 // Sets parameter value. The caller is responsible for making sure the value
14508 // remains alive and unchanged throughout the current test.
14509 static void SetParam(const ParamType* parameter) {
14510 parameter_ = parameter;
14511 }
14512
14513 // Static value used for accessing parameter during a test lifetime.
14514 static const ParamType* parameter_;
14515
14516 // TestClass must be a subclass of WithParamInterface<T> and Test.
14517 template <class TestClass> friend class internal::ParameterizedTestFactory;
14518};
14519
14520template <typename T>
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014521const T* WithParamInterface<T>::parameter_ = nullptr;
Austin Schuh70cc9552019-01-21 19:46:48 -080014522
14523// Most value-parameterized classes can ignore the existence of
14524// WithParamInterface, and can just inherit from ::testing::TestWithParam.
14525
14526template <typename T>
14527class TestWithParam : public Test, public WithParamInterface<T> {
14528};
14529
Austin Schuh70cc9552019-01-21 19:46:48 -080014530// Macros for indicating success/failure in test code.
14531
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014532// Skips test in runtime.
14533// Skipping test aborts current function.
14534// Skipped tests are neither successful nor failed.
14535#define GTEST_SKIP() GTEST_SKIP_("Skipped")
14536
Austin Schuh70cc9552019-01-21 19:46:48 -080014537// ADD_FAILURE unconditionally adds a failure to the current test.
14538// SUCCEED generates a success - it doesn't automatically make the
14539// current test successful, as a test is only successful when it has
14540// no failure.
14541//
14542// EXPECT_* verifies that a certain condition is satisfied. If not,
14543// it behaves like ADD_FAILURE. In particular:
14544//
14545// EXPECT_TRUE verifies that a Boolean condition is true.
14546// EXPECT_FALSE verifies that a Boolean condition is false.
14547//
14548// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
14549// that they will also abort the current function on failure. People
14550// usually want the fail-fast behavior of FAIL and ASSERT_*, but those
14551// writing data-driven tests often find themselves using ADD_FAILURE
14552// and EXPECT_* more.
14553
14554// Generates a nonfatal failure with a generic message.
14555#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
14556
14557// Generates a nonfatal failure at the given source file location with
14558// a generic message.
14559#define ADD_FAILURE_AT(file, line) \
14560 GTEST_MESSAGE_AT_(file, line, "Failed", \
14561 ::testing::TestPartResult::kNonFatalFailure)
14562
14563// Generates a fatal failure with a generic message.
14564#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
14565
14566// Define this macro to 1 to omit the definition of FAIL(), which is a
14567// generic name and clashes with some other libraries.
14568#if !GTEST_DONT_DEFINE_FAIL
14569# define FAIL() GTEST_FAIL()
14570#endif
14571
14572// Generates a success with a generic message.
14573#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
14574
14575// Define this macro to 1 to omit the definition of SUCCEED(), which
14576// is a generic name and clashes with some other libraries.
14577#if !GTEST_DONT_DEFINE_SUCCEED
14578# define SUCCEED() GTEST_SUCCEED()
14579#endif
14580
14581// Macros for testing exceptions.
14582//
14583// * {ASSERT|EXPECT}_THROW(statement, expected_exception):
14584// Tests that the statement throws the expected exception.
14585// * {ASSERT|EXPECT}_NO_THROW(statement):
14586// Tests that the statement doesn't throw any exception.
14587// * {ASSERT|EXPECT}_ANY_THROW(statement):
14588// Tests that the statement throws an exception.
14589
14590#define EXPECT_THROW(statement, expected_exception) \
14591 GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
14592#define EXPECT_NO_THROW(statement) \
14593 GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
14594#define EXPECT_ANY_THROW(statement) \
14595 GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
14596#define ASSERT_THROW(statement, expected_exception) \
14597 GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
14598#define ASSERT_NO_THROW(statement) \
14599 GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
14600#define ASSERT_ANY_THROW(statement) \
14601 GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
14602
14603// Boolean assertions. Condition can be either a Boolean expression or an
14604// AssertionResult. For more information on how to use AssertionResult with
14605// these macros see comments on that class.
14606#define EXPECT_TRUE(condition) \
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014607 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
Austin Schuh70cc9552019-01-21 19:46:48 -080014608 GTEST_NONFATAL_FAILURE_)
14609#define EXPECT_FALSE(condition) \
14610 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
14611 GTEST_NONFATAL_FAILURE_)
14612#define ASSERT_TRUE(condition) \
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014613 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
Austin Schuh70cc9552019-01-21 19:46:48 -080014614 GTEST_FATAL_FAILURE_)
14615#define ASSERT_FALSE(condition) \
14616 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
14617 GTEST_FATAL_FAILURE_)
14618
Austin Schuh70cc9552019-01-21 19:46:48 -080014619// Macros for testing equalities and inequalities.
14620//
14621// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
14622// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
14623// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
14624// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
14625// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
14626// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
14627//
14628// When they are not, Google Test prints both the tested expressions and
14629// their actual values. The values must be compatible built-in types,
14630// or you will get a compiler error. By "compatible" we mean that the
14631// values can be compared by the respective operator.
14632//
14633// Note:
14634//
14635// 1. It is possible to make a user-defined type work with
14636// {ASSERT|EXPECT}_??(), but that requires overloading the
14637// comparison operators and is thus discouraged by the Google C++
14638// Usage Guide. Therefore, you are advised to use the
14639// {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
14640// equal.
14641//
14642// 2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
14643// pointers (in particular, C strings). Therefore, if you use it
14644// with two C strings, you are testing how their locations in memory
14645// are related, not how their content is related. To compare two C
14646// strings by content, use {ASSERT|EXPECT}_STR*().
14647//
14648// 3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to
14649// {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you
14650// what the actual value is when it fails, and similarly for the
14651// other comparisons.
14652//
14653// 4. Do not depend on the order in which {ASSERT|EXPECT}_??()
14654// evaluate their arguments, which is undefined.
14655//
14656// 5. These macros evaluate their arguments exactly once.
14657//
14658// Examples:
14659//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014660// EXPECT_NE(Foo(), 5);
14661// EXPECT_EQ(a_pointer, NULL);
Austin Schuh70cc9552019-01-21 19:46:48 -080014662// ASSERT_LT(i, array_size);
14663// ASSERT_GT(records.size(), 0) << "There is no record left.";
14664
14665#define EXPECT_EQ(val1, val2) \
14666 EXPECT_PRED_FORMAT2(::testing::internal:: \
14667 EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
14668 val1, val2)
14669#define EXPECT_NE(val1, val2) \
14670 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
14671#define EXPECT_LE(val1, val2) \
14672 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
14673#define EXPECT_LT(val1, val2) \
14674 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
14675#define EXPECT_GE(val1, val2) \
14676 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
14677#define EXPECT_GT(val1, val2) \
14678 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
14679
14680#define GTEST_ASSERT_EQ(val1, val2) \
14681 ASSERT_PRED_FORMAT2(::testing::internal:: \
14682 EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
14683 val1, val2)
14684#define GTEST_ASSERT_NE(val1, val2) \
14685 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
14686#define GTEST_ASSERT_LE(val1, val2) \
14687 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
14688#define GTEST_ASSERT_LT(val1, val2) \
14689 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
14690#define GTEST_ASSERT_GE(val1, val2) \
14691 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
14692#define GTEST_ASSERT_GT(val1, val2) \
14693 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
14694
14695// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
14696// ASSERT_XY(), which clashes with some users' own code.
14697
14698#if !GTEST_DONT_DEFINE_ASSERT_EQ
14699# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
14700#endif
14701
14702#if !GTEST_DONT_DEFINE_ASSERT_NE
14703# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
14704#endif
14705
14706#if !GTEST_DONT_DEFINE_ASSERT_LE
14707# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
14708#endif
14709
14710#if !GTEST_DONT_DEFINE_ASSERT_LT
14711# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
14712#endif
14713
14714#if !GTEST_DONT_DEFINE_ASSERT_GE
14715# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
14716#endif
14717
14718#if !GTEST_DONT_DEFINE_ASSERT_GT
14719# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
14720#endif
14721
14722// C-string Comparisons. All tests treat NULL and any non-NULL string
14723// as different. Two NULLs are equal.
14724//
14725// * {ASSERT|EXPECT}_STREQ(s1, s2): Tests that s1 == s2
14726// * {ASSERT|EXPECT}_STRNE(s1, s2): Tests that s1 != s2
14727// * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
14728// * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
14729//
14730// For wide or narrow string objects, you can use the
14731// {ASSERT|EXPECT}_??() macros.
14732//
14733// Don't depend on the order in which the arguments are evaluated,
14734// which is undefined.
14735//
14736// These macros evaluate their arguments exactly once.
14737
14738#define EXPECT_STREQ(s1, s2) \
14739 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
14740#define EXPECT_STRNE(s1, s2) \
14741 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
14742#define EXPECT_STRCASEEQ(s1, s2) \
14743 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
14744#define EXPECT_STRCASENE(s1, s2)\
14745 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
14746
14747#define ASSERT_STREQ(s1, s2) \
14748 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
14749#define ASSERT_STRNE(s1, s2) \
14750 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
14751#define ASSERT_STRCASEEQ(s1, s2) \
14752 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
14753#define ASSERT_STRCASENE(s1, s2)\
14754 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
14755
14756// Macros for comparing floating-point numbers.
14757//
14758// * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):
14759// Tests that two float values are almost equal.
14760// * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):
14761// Tests that two double values are almost equal.
14762// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
14763// Tests that v1 and v2 are within the given distance to each other.
14764//
14765// Google Test uses ULP-based comparison to automatically pick a default
14766// error bound that is appropriate for the operands. See the
14767// FloatingPoint template class in gtest-internal.h if you are
14768// interested in the implementation details.
14769
14770#define EXPECT_FLOAT_EQ(val1, val2)\
14771 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
14772 val1, val2)
14773
14774#define EXPECT_DOUBLE_EQ(val1, val2)\
14775 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
14776 val1, val2)
14777
14778#define ASSERT_FLOAT_EQ(val1, val2)\
14779 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
14780 val1, val2)
14781
14782#define ASSERT_DOUBLE_EQ(val1, val2)\
14783 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
14784 val1, val2)
14785
14786#define EXPECT_NEAR(val1, val2, abs_error)\
14787 EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
14788 val1, val2, abs_error)
14789
14790#define ASSERT_NEAR(val1, val2, abs_error)\
14791 ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
14792 val1, val2, abs_error)
14793
14794// These predicate format functions work on floating-point values, and
14795// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
14796//
14797// EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
14798
14799// Asserts that val1 is less than, or almost equal to, val2. Fails
14800// otherwise. In particular, it fails if either val1 or val2 is NaN.
14801GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
14802 float val1, float val2);
14803GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
14804 double val1, double val2);
14805
14806
14807#if GTEST_OS_WINDOWS
14808
14809// Macros that test for HRESULT failure and success, these are only useful
14810// on Windows, and rely on Windows SDK macros and APIs to compile.
14811//
14812// * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
14813//
14814// When expr unexpectedly fails or succeeds, Google Test prints the
14815// expected result and the actual result with both a human-readable
14816// string representation of the error, if available, as well as the
14817// hex result code.
14818# define EXPECT_HRESULT_SUCCEEDED(expr) \
14819 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
14820
14821# define ASSERT_HRESULT_SUCCEEDED(expr) \
14822 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
14823
14824# define EXPECT_HRESULT_FAILED(expr) \
14825 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
14826
14827# define ASSERT_HRESULT_FAILED(expr) \
14828 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
14829
14830#endif // GTEST_OS_WINDOWS
14831
14832// Macros that execute statement and check that it doesn't generate new fatal
14833// failures in the current thread.
14834//
14835// * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
14836//
14837// Examples:
14838//
14839// EXPECT_NO_FATAL_FAILURE(Process());
14840// ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
14841//
14842#define ASSERT_NO_FATAL_FAILURE(statement) \
14843 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
14844#define EXPECT_NO_FATAL_FAILURE(statement) \
14845 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
14846
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014847// Causes a trace (including the given source file path and line number,
14848// and the given message) to be included in every test failure message generated
14849// by code in the scope of the lifetime of an instance of this class. The effect
14850// is undone with the destruction of the instance.
14851//
14852// The message argument can be anything streamable to std::ostream.
14853//
14854// Example:
14855// testing::ScopedTrace trace("file.cc", 123, "message");
14856//
14857class GTEST_API_ ScopedTrace {
14858 public:
14859 // The c'tor pushes the given source file location and message onto
14860 // a trace stack maintained by Google Test.
14861
14862 // Template version. Uses Message() to convert the values into strings.
14863 // Slow, but flexible.
14864 template <typename T>
14865 ScopedTrace(const char* file, int line, const T& message) {
14866 PushTrace(file, line, (Message() << message).GetString());
14867 }
14868
14869 // Optimize for some known types.
14870 ScopedTrace(const char* file, int line, const char* message) {
14871 PushTrace(file, line, message ? message : "(null)");
14872 }
14873
14874#if GTEST_HAS_GLOBAL_STRING
14875 ScopedTrace(const char* file, int line, const ::string& message) {
14876 PushTrace(file, line, message);
14877 }
14878#endif
14879
14880 ScopedTrace(const char* file, int line, const std::string& message) {
14881 PushTrace(file, line, message);
14882 }
14883
14884 // The d'tor pops the info pushed by the c'tor.
14885 //
14886 // Note that the d'tor is not virtual in order to be efficient.
14887 // Don't inherit from ScopedTrace!
14888 ~ScopedTrace();
14889
14890 private:
14891 void PushTrace(const char* file, int line, std::string message);
14892
14893 GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
14894} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
14895 // c'tor and d'tor. Therefore it doesn't
14896 // need to be used otherwise.
14897
Austin Schuh70cc9552019-01-21 19:46:48 -080014898// Causes a trace (including the source file path, the current line
14899// number, and the given message) to be included in every test failure
14900// message generated by code in the current scope. The effect is
14901// undone when the control leaves the current scope.
14902//
14903// The message argument can be anything streamable to std::ostream.
14904//
14905// In the implementation, we include the current line number as part
14906// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
14907// to appear in the same block - as long as they are on different
14908// lines.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014909//
14910// Assuming that each thread maintains its own stack of traces.
14911// Therefore, a SCOPED_TRACE() would (correctly) only affect the
14912// assertions in its own thread.
Austin Schuh70cc9552019-01-21 19:46:48 -080014913#define SCOPED_TRACE(message) \
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014914 ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
14915 __FILE__, __LINE__, (message))
14916
Austin Schuh70cc9552019-01-21 19:46:48 -080014917
14918// Compile-time assertion for type equality.
14919// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
14920// the same type. The value it returns is not interesting.
14921//
14922// Instead of making StaticAssertTypeEq a class template, we make it a
14923// function template that invokes a helper class template. This
14924// prevents a user from misusing StaticAssertTypeEq<T1, T2> by
14925// defining objects of that type.
14926//
14927// CAVEAT:
14928//
14929// When used inside a method of a class template,
14930// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
14931// instantiated. For example, given:
14932//
14933// template <typename T> class Foo {
14934// public:
14935// void Bar() { testing::StaticAssertTypeEq<int, T>(); }
14936// };
14937//
14938// the code:
14939//
14940// void Test1() { Foo<bool> foo; }
14941//
14942// will NOT generate a compiler error, as Foo<bool>::Bar() is never
14943// actually instantiated. Instead, you need:
14944//
14945// void Test2() { Foo<bool> foo; foo.Bar(); }
14946//
14947// to cause a compiler error.
14948template <typename T1, typename T2>
14949bool StaticAssertTypeEq() {
14950 (void)internal::StaticAssertTypeEqHelper<T1, T2>();
14951 return true;
14952}
14953
14954// Defines a test.
14955//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014956// The first parameter is the name of the test suite, and the second
14957// parameter is the name of the test within the test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080014958//
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014959// The convention is to end the test suite name with "Test". For
14960// example, a test suite for the Foo class can be named FooTest.
Austin Schuh70cc9552019-01-21 19:46:48 -080014961//
14962// Test code should appear between braces after an invocation of
14963// this macro. Example:
14964//
14965// TEST(FooTest, InitializesCorrectly) {
14966// Foo foo;
14967// EXPECT_TRUE(foo.StatusIsOK());
14968// }
14969
14970// Note that we call GetTestTypeId() instead of GetTypeId<
14971// ::testing::Test>() here to get the type ID of testing::Test. This
14972// is to work around a suspected linker bug when using Google Test as
14973// a framework on Mac OS X. The bug causes GetTypeId<
14974// ::testing::Test>() to return different values depending on whether
14975// the call is from the Google Test framework itself or from user test
14976// code. GetTestTypeId() is guaranteed to always return the same
14977// value, as it always calls GetTypeId<>() from the Google Test
14978// framework.
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014979#define GTEST_TEST(test_suite_name, test_name) \
14980 GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
14981 ::testing::internal::GetTestTypeId())
Austin Schuh70cc9552019-01-21 19:46:48 -080014982
14983// Define this macro to 1 to omit the definition of TEST(), which
14984// is a generic name and clashes with some other libraries.
14985#if !GTEST_DONT_DEFINE_TEST
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014986#define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
Austin Schuh70cc9552019-01-21 19:46:48 -080014987#endif
14988
14989// Defines a test that uses a test fixture.
14990//
14991// The first parameter is the name of the test fixture class, which
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014992// also doubles as the test suite name. The second parameter is the
14993// name of the test within the test suite.
Austin Schuh70cc9552019-01-21 19:46:48 -080014994//
14995// A test fixture class must be declared earlier. The user should put
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080014996// the test code between braces after using this macro. Example:
Austin Schuh70cc9552019-01-21 19:46:48 -080014997//
14998// class FooTest : public testing::Test {
14999// protected:
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080015000// void SetUp() override { b_.AddElement(3); }
Austin Schuh70cc9552019-01-21 19:46:48 -080015001//
15002// Foo a_;
15003// Foo b_;
15004// };
15005//
15006// TEST_F(FooTest, InitializesCorrectly) {
15007// EXPECT_TRUE(a_.StatusIsOK());
15008// }
15009//
15010// TEST_F(FooTest, ReturnsElementCountCorrectly) {
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080015011// EXPECT_EQ(a_.size(), 0);
15012// EXPECT_EQ(b_.size(), 1);
Austin Schuh70cc9552019-01-21 19:46:48 -080015013// }
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080015014//
15015// GOOGLETEST_CM0011 DO NOT DELETE
Austin Schuh70cc9552019-01-21 19:46:48 -080015016#define TEST_F(test_fixture, test_name)\
15017 GTEST_TEST_(test_fixture, test_name, test_fixture, \
15018 ::testing::internal::GetTypeId<test_fixture>())
15019
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080015020// Returns a path to temporary directory.
15021// Tries to determine an appropriate directory for the platform.
15022GTEST_API_ std::string TempDir();
15023
15024#ifdef _MSC_VER
15025# pragma warning(pop)
15026#endif
15027
15028// Dynamically registers a test with the framework.
15029//
15030// This is an advanced API only to be used when the `TEST` macros are
15031// insufficient. The macros should be preferred when possible, as they avoid
15032// most of the complexity of calling this function.
15033//
15034// The `factory` argument is a factory callable (move-constructible) object or
15035// function pointer that creates a new instance of the Test object. It
15036// handles ownership to the caller. The signature of the callable is
15037// `Fixture*()`, where `Fixture` is the test fixture class for the test. All
15038// tests registered with the same `test_suite_name` must return the same
15039// fixture type. This is checked at runtime.
15040//
15041// The framework will infer the fixture class from the factory and will call
15042// the `SetUpTestSuite` and `TearDownTestSuite` for it.
15043//
15044// Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is
15045// undefined.
15046//
15047// Use case example:
15048//
15049// class MyFixture : public ::testing::Test {
15050// public:
15051// // All of these optional, just like in regular macro usage.
15052// static void SetUpTestSuite() { ... }
15053// static void TearDownTestSuite() { ... }
15054// void SetUp() override { ... }
15055// void TearDown() override { ... }
15056// };
15057//
15058// class MyTest : public MyFixture {
15059// public:
15060// explicit MyTest(int data) : data_(data) {}
15061// void TestBody() override { ... }
15062//
15063// private:
15064// int data_;
15065// };
15066//
15067// void RegisterMyTests(const std::vector<int>& values) {
15068// for (int v : values) {
15069// ::testing::RegisterTest(
15070// "MyFixture", ("Test" + std::to_string(v)).c_str(), nullptr,
15071// std::to_string(v).c_str(),
15072// __FILE__, __LINE__,
15073// // Important to use the fixture type as the return type here.
15074// [=]() -> MyFixture* { return new MyTest(v); });
15075// }
15076// }
15077// ...
15078// int main(int argc, char** argv) {
15079// std::vector<int> values_to_test = LoadValuesFromConfig();
15080// RegisterMyTests(values_to_test);
15081// ...
15082// return RUN_ALL_TESTS();
15083// }
15084//
15085template <int&... ExplicitParameterBarrier, typename Factory>
15086TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
15087 const char* type_param, const char* value_param,
15088 const char* file, int line, Factory factory) {
15089 using TestT = typename std::remove_pointer<decltype(factory())>::type;
15090
15091 class FactoryImpl : public internal::TestFactoryBase {
15092 public:
15093 explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
15094 Test* CreateTest() override { return factory_(); }
15095
15096 private:
15097 Factory factory_;
15098 };
15099
15100 return internal::MakeAndRegisterTestInfo(
15101 test_suite_name, test_name, type_param, value_param,
15102 internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),
15103 internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(),
15104 internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(),
15105 new FactoryImpl{std::move(factory)});
15106}
15107
Austin Schuh70cc9552019-01-21 19:46:48 -080015108} // namespace testing
15109
15110// Use this function in main() to run all tests. It returns 0 if all
15111// tests are successful, or 1 otherwise.
15112//
15113// RUN_ALL_TESTS() should be invoked after the command line has been
15114// parsed by InitGoogleTest().
15115//
15116// This function was formerly a macro; thus, it is in the global
15117// namespace and has an all-caps name.
15118int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
15119
15120inline int RUN_ALL_TESTS() {
15121 return ::testing::UnitTest::GetInstance()->Run();
15122}
15123
Austin Schuh1d1e6ea2020-12-23 21:56:30 -080015124GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
15125
Austin Schuh70cc9552019-01-21 19:46:48 -080015126#endif // GTEST_INCLUDE_GTEST_GTEST_H_