commit
4d50ab75a7
41 changed files with 1510 additions and 4628 deletions
@ -1,126 +0,0 @@ |
|||||||
Changes for 1.7.0: |
|
||||||
|
|
||||||
* All new improvements in Google Test 1.7.0. |
|
||||||
* New feature: matchers DoubleNear(), FloatNear(), |
|
||||||
NanSensitiveDoubleNear(), NanSensitiveFloatNear(), |
|
||||||
UnorderedElementsAre(), UnorderedElementsAreArray(), WhenSorted(), |
|
||||||
WhenSortedBy(), IsEmpty(), and SizeIs(). |
|
||||||
* Improvement: Google Mock can now be built as a DLL. |
|
||||||
* Improvement: when compiled by a C++11 compiler, matchers AllOf() |
|
||||||
and AnyOf() can accept an arbitrary number of matchers. |
|
||||||
* Improvement: when compiled by a C++11 compiler, matchers |
|
||||||
ElementsAreArray() can accept an initializer list. |
|
||||||
* Improvement: when exceptions are enabled, a mock method with no |
|
||||||
default action now throws instead crashing the test. |
|
||||||
* Improvement: added class testing::StringMatchResultListener to aid |
|
||||||
definition of composite matchers. |
|
||||||
* Improvement: function return types used in MOCK_METHOD*() macros can |
|
||||||
now contain unprotected commas. |
|
||||||
* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT() |
|
||||||
are now more strict in ensuring that the value type and the matcher |
|
||||||
type are compatible, catching potential bugs in tests. |
|
||||||
* Improvement: Pointee() now works on an optional<T>. |
|
||||||
* Improvement: the ElementsAreArray() matcher can now take a vector or |
|
||||||
iterator range as input, and makes a copy of its input elements |
|
||||||
before the conversion to a Matcher. |
|
||||||
* Improvement: the Google Mock Generator can now generate mocks for |
|
||||||
some class templates. |
|
||||||
* Bug fix: mock object destruction triggerred by another mock object's |
|
||||||
destruction no longer hangs. |
|
||||||
* Improvement: Google Mock Doctor works better with newer Clang and |
|
||||||
GCC now. |
|
||||||
* Compatibility fixes. |
|
||||||
* Bug/warning fixes. |
|
||||||
|
|
||||||
Changes for 1.6.0: |
|
||||||
|
|
||||||
* Compilation is much faster and uses much less memory, especially |
|
||||||
when the constructor and destructor of a mock class are moved out of |
|
||||||
the class body. |
|
||||||
* New matchers: Pointwise(), Each(). |
|
||||||
* New actions: ReturnPointee() and ReturnRefOfCopy(). |
|
||||||
* CMake support. |
|
||||||
* Project files for Visual Studio 2010. |
|
||||||
* AllOf() and AnyOf() can handle up-to 10 arguments now. |
|
||||||
* Google Mock doctor understands Clang error messages now. |
|
||||||
* SetArgPointee<> now accepts string literals. |
|
||||||
* gmock_gen.py handles storage specifier macros and template return |
|
||||||
types now. |
|
||||||
* Compatibility fixes. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
* Potentially incompatible changes: disables the harmful 'make install' |
|
||||||
command in autotools. |
|
||||||
|
|
||||||
Potentially breaking changes: |
|
||||||
|
|
||||||
* The description string for MATCHER*() changes from Python-style |
|
||||||
interpolation to an ordinary C++ string expression. |
|
||||||
* SetArgumentPointee is deprecated in favor of SetArgPointee. |
|
||||||
* Some non-essential project files for Visual Studio 2005 are removed. |
|
||||||
|
|
||||||
Changes for 1.5.0: |
|
||||||
|
|
||||||
* New feature: Google Mock can be safely used in multi-threaded tests |
|
||||||
on platforms having pthreads. |
|
||||||
* New feature: function for printing a value of arbitrary type. |
|
||||||
* New feature: function ExplainMatchResult() for easy definition of |
|
||||||
composite matchers. |
|
||||||
* The new matcher API lets user-defined matchers generate custom |
|
||||||
explanations more directly and efficiently. |
|
||||||
* Better failure messages all around. |
|
||||||
* NotNull() and IsNull() now work with smart pointers. |
|
||||||
* Field() and Property() now work when the matcher argument is a pointer |
|
||||||
passed by reference. |
|
||||||
* Regular expression matchers on all platforms. |
|
||||||
* Added GCC 4.0 support for Google Mock Doctor. |
|
||||||
* Added gmock_all_test.cc for compiling most Google Mock tests |
|
||||||
in a single file. |
|
||||||
* Significantly cleaned up compiler warnings. |
|
||||||
* Bug fixes, better test coverage, and implementation clean-ups. |
|
||||||
|
|
||||||
Potentially breaking changes: |
|
||||||
|
|
||||||
* Custom matchers defined using MatcherInterface or MakePolymorphicMatcher() |
|
||||||
need to be updated after upgrading to Google Mock 1.5.0; matchers defined |
|
||||||
using MATCHER or MATCHER_P* aren't affected. |
|
||||||
* Dropped support for 'make install'. |
|
||||||
|
|
||||||
Changes for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of |
|
||||||
Google Test): |
|
||||||
|
|
||||||
* Works in more environments: Symbian and minGW, Visual C++ 7.1. |
|
||||||
* Lighter weight: comes with our own implementation of TR1 tuple (no |
|
||||||
more dependency on Boost!). |
|
||||||
* New feature: --gmock_catch_leaked_mocks for detecting leaked mocks. |
|
||||||
* New feature: ACTION_TEMPLATE for defining templatized actions. |
|
||||||
* New feature: the .After() clause for specifying expectation order. |
|
||||||
* New feature: the .With() clause for specifying inter-argument |
|
||||||
constraints. |
|
||||||
* New feature: actions ReturnArg<k>(), ReturnNew<T>(...), and |
|
||||||
DeleteArg<k>(). |
|
||||||
* New feature: matchers Key(), Pair(), Args<...>(), AllArgs(), IsNull(), |
|
||||||
and Contains(). |
|
||||||
* New feature: utility class MockFunction<F>, useful for checkpoints, etc. |
|
||||||
* New feature: functions Value(x, m) and SafeMatcherCast<T>(m). |
|
||||||
* New feature: copying a mock object is rejected at compile time. |
|
||||||
* New feature: a script for fusing all Google Mock and Google Test |
|
||||||
source files for easy deployment. |
|
||||||
* Improved the Google Mock doctor to diagnose more diseases. |
|
||||||
* Improved the Google Mock generator script. |
|
||||||
* Compatibility fixes for Mac OS X and gcc. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
|
|
||||||
Changes for 1.1.0: |
|
||||||
|
|
||||||
* New feature: ability to use Google Mock with any testing framework. |
|
||||||
* New feature: macros for easily defining new matchers |
|
||||||
* New feature: macros for easily defining new actions. |
|
||||||
* New feature: more container matchers. |
|
||||||
* New feature: actions for accessing function arguments and throwing |
|
||||||
exceptions. |
|
||||||
* Improved the Google Mock doctor script for diagnosing compiler errors. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
|
|
||||||
Changes for 1.0.0: |
|
||||||
|
|
||||||
* Initial Open Source release of Google Mock |
|
File diff suppressed because it is too large
Load Diff
@ -1,157 +0,0 @@ |
|||||||
Changes for 1.7.0: |
|
||||||
|
|
||||||
* New feature: death tests are supported on OpenBSD and in iOS |
|
||||||
simulator now. |
|
||||||
* New feature: Google Test now implements a protocol to allow |
|
||||||
a test runner to detect that a test program has exited |
|
||||||
prematurely and report it as a failure (before it would be |
|
||||||
falsely reported as a success if the exit code is 0). |
|
||||||
* New feature: Test::RecordProperty() can now be used outside of the |
|
||||||
lifespan of a test method, in which case it will be attributed to |
|
||||||
the current test case or the test program in the XML report. |
|
||||||
* New feature (potentially breaking): --gtest_list_tests now prints |
|
||||||
the type parameters and value parameters for each test. |
|
||||||
* Improvement: char pointers and char arrays are now escaped properly |
|
||||||
in failure messages. |
|
||||||
* Improvement: failure summary in XML reports now includes file and |
|
||||||
line information. |
|
||||||
* Improvement: the <testsuites> XML element now has a timestamp attribute. |
|
||||||
* Improvement: When --gtest_filter is specified, XML report now doesn't |
|
||||||
contain information about tests that are filtered out. |
|
||||||
* Fixed the bug where long --gtest_filter flag values are truncated in |
|
||||||
death tests. |
|
||||||
* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a |
|
||||||
function instead of a macro in order to work better with Clang. |
|
||||||
* Compatibility fixes with C++ 11 and various platforms. |
|
||||||
* Bug/warning fixes. |
|
||||||
|
|
||||||
Changes for 1.6.0: |
|
||||||
|
|
||||||
* New feature: ADD_FAILURE_AT() for reporting a test failure at the |
|
||||||
given source location -- useful for writing testing utilities. |
|
||||||
* New feature: the universal value printer is moved from Google Mock |
|
||||||
to Google Test. |
|
||||||
* New feature: type parameters and value parameters are reported in |
|
||||||
the XML report now. |
|
||||||
* A gtest_disable_pthreads CMake option. |
|
||||||
* Colored output works in GNU Screen sessions now. |
|
||||||
* Parameters of value-parameterized tests are now printed in the |
|
||||||
textual output. |
|
||||||
* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are |
|
||||||
now correctly reported. |
|
||||||
* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to |
|
||||||
ostream. |
|
||||||
* More complete handling of exceptions. |
|
||||||
* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter |
|
||||||
name is already used by another library. |
|
||||||
* --gtest_catch_exceptions is now true by default, allowing a test |
|
||||||
program to continue after an exception is thrown. |
|
||||||
* Value-parameterized test fixtures can now derive from Test and |
|
||||||
WithParamInterface<T> separately, easing conversion of legacy tests. |
|
||||||
* Death test messages are clearly marked to make them more |
|
||||||
distinguishable from other messages. |
|
||||||
* Compatibility fixes for Android, Google Native Client, MinGW, HP UX, |
|
||||||
PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear), |
|
||||||
IBM XL C++ (Visual Age C++), and C++0x. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
* Potentially incompatible changes: disables the harmful 'make install' |
|
||||||
command in autotools. |
|
||||||
|
|
||||||
Changes for 1.5.0: |
|
||||||
|
|
||||||
* New feature: assertions can be safely called in multiple threads |
|
||||||
where the pthreads library is available. |
|
||||||
* New feature: predicates used inside EXPECT_TRUE() and friends |
|
||||||
can now generate custom failure messages. |
|
||||||
* New feature: Google Test can now be compiled as a DLL. |
|
||||||
* New feature: fused source files are included. |
|
||||||
* New feature: prints help when encountering unrecognized Google Test flags. |
|
||||||
* Experimental feature: CMake build script (requires CMake 2.6.4+). |
|
||||||
* Experimental feature: the Pump script for meta programming. |
|
||||||
* double values streamed to an assertion are printed with enough precision |
|
||||||
to differentiate any two different values. |
|
||||||
* Google Test now works on Solaris and AIX. |
|
||||||
* Build and test script improvements. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
|
|
||||||
Potentially breaking changes: |
|
||||||
|
|
||||||
* Stopped supporting VC++ 7.1 with exceptions disabled. |
|
||||||
* Dropped support for 'make install'. |
|
||||||
|
|
||||||
Changes for 1.4.0: |
|
||||||
|
|
||||||
* New feature: the event listener API |
|
||||||
* New feature: test shuffling |
|
||||||
* New feature: the XML report format is closer to junitreport and can |
|
||||||
be parsed by Hudson now. |
|
||||||
* New feature: when a test runs under Visual Studio, its failures are |
|
||||||
integrated in the IDE. |
|
||||||
* New feature: /MD(d) versions of VC++ projects. |
|
||||||
* New feature: elapsed time for the tests is printed by default. |
|
||||||
* New feature: comes with a TR1 tuple implementation such that Boost |
|
||||||
is no longer needed for Combine(). |
|
||||||
* New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends. |
|
||||||
* New feature: the Xcode project can now produce static gtest |
|
||||||
libraries in addition to a framework. |
|
||||||
* Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile, |
|
||||||
Symbian, gcc, and C++Builder. |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
|
|
||||||
Changes for 1.3.0: |
|
||||||
|
|
||||||
* New feature: death tests on Windows, Cygwin, and Mac. |
|
||||||
* New feature: ability to use Google Test assertions in other testing |
|
||||||
frameworks. |
|
||||||
* New feature: ability to run disabled test via |
|
||||||
--gtest_also_run_disabled_tests. |
|
||||||
* New feature: the --help flag for printing the usage. |
|
||||||
* New feature: access to Google Test flag values in user code. |
|
||||||
* New feature: a script that packs Google Test into one .h and one |
|
||||||
.cc file for easy deployment. |
|
||||||
* New feature: support for distributing test functions to multiple |
|
||||||
machines (requires support from the test runner). |
|
||||||
* Bug fixes and implementation clean-ups. |
|
||||||
|
|
||||||
Changes for 1.2.1: |
|
||||||
|
|
||||||
* Compatibility fixes for Linux IA-64 and IBM z/OS. |
|
||||||
* Added support for using Boost and other TR1 implementations. |
|
||||||
* Changes to the build scripts to support upcoming release of Google C++ |
|
||||||
Mocking Framework. |
|
||||||
* Added Makefile to the distribution package. |
|
||||||
* Improved build instructions in README. |
|
||||||
|
|
||||||
Changes for 1.2.0: |
|
||||||
|
|
||||||
* New feature: value-parameterized tests. |
|
||||||
* New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS) |
|
||||||
macros. |
|
||||||
* Changed the XML report format to match JUnit/Ant's. |
|
||||||
* Added tests to the Xcode project. |
|
||||||
* Added scons/SConscript for building with SCons. |
|
||||||
* Added src/gtest-all.cc for building Google Test from a single file. |
|
||||||
* Fixed compatibility with Solaris and z/OS. |
|
||||||
* Enabled running Python tests on systems with python 2.3 installed, |
|
||||||
e.g. Mac OS X 10.4. |
|
||||||
* Bug fixes. |
|
||||||
|
|
||||||
Changes for 1.1.0: |
|
||||||
|
|
||||||
* New feature: type-parameterized tests. |
|
||||||
* New feature: exception assertions. |
|
||||||
* New feature: printing elapsed time of tests. |
|
||||||
* Improved the robustness of death tests. |
|
||||||
* Added an Xcode project and samples. |
|
||||||
* Adjusted the output format on Windows to be understandable by Visual Studio. |
|
||||||
* Minor bug fixes. |
|
||||||
|
|
||||||
Changes for 1.0.1: |
|
||||||
|
|
||||||
* Added project files for Visual Studio 7.1. |
|
||||||
* Fixed issues with compiling on Mac OS X. |
|
||||||
* Fixed issues with compiling on Cygwin. |
|
||||||
|
|
||||||
Changes for 1.0.0: |
|
||||||
|
|
||||||
* Initial Open Source release of Google Test |
|
File diff suppressed because it is too large
Load Diff
@ -1,348 +0,0 @@ |
|||||||
$$ -*- mode: c++; -*- |
|
||||||
$var n = 10 $$ Maximum number of tuple fields we want to support. |
|
||||||
$$ This meta comment fixes auto-indentation in Emacs. }} |
|
||||||
// Copyright 2009 Google Inc. |
|
||||||
// All Rights Reserved. |
|
||||||
// |
|
||||||
// Redistribution and use in source and binary forms, with or without |
|
||||||
// modification, are permitted provided that the following conditions are |
|
||||||
// met: |
|
||||||
// |
|
||||||
// * Redistributions of source code must retain the above copyright |
|
||||||
// notice, this list of conditions and the following disclaimer. |
|
||||||
// * Redistributions in binary form must reproduce the above |
|
||||||
// copyright notice, this list of conditions and the following disclaimer |
|
||||||
// in the documentation and/or other materials provided with the |
|
||||||
// distribution. |
|
||||||
// * Neither the name of Google Inc. nor the names of its |
|
||||||
// contributors may be used to endorse or promote products derived from |
|
||||||
// this software without specific prior written permission. |
|
||||||
// |
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
||||||
// Implements a subset of TR1 tuple needed by Google Test and Google Mock. |
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE |
|
||||||
|
|
||||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ |
|
||||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ |
|
||||||
|
|
||||||
#include <utility> // For ::std::pair. |
|
||||||
|
|
||||||
// The compiler used in Symbian has a bug that prevents us from declaring the |
|
||||||
// tuple template as a friend (it complains that tuple is redefined). This |
|
||||||
// bypasses the bug by declaring the members that should otherwise be |
|
||||||
// private as public. |
|
||||||
// Sun Studio versions < 12 also have the above bug. |
|
||||||
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) |
|
||||||
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: |
|
||||||
#else |
|
||||||
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ |
|
||||||
template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \ |
|
||||||
private: |
|
||||||
#endif |
|
||||||
|
|
||||||
// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict |
|
||||||
// with our own definitions. Therefore using our own tuple does not work on |
|
||||||
// those compilers. |
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */ |
|
||||||
# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \ |
|
||||||
GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers." |
|
||||||
#endif |
|
||||||
|
|
||||||
|
|
||||||
$range i 0..n-1 |
|
||||||
$range j 0..n |
|
||||||
$range k 1..n |
|
||||||
// GTEST_n_TUPLE_(T) is the type of an n-tuple. |
|
||||||
#define GTEST_0_TUPLE_(T) tuple<> |
|
||||||
|
|
||||||
$for k [[ |
|
||||||
$range m 0..k-1 |
|
||||||
$range m2 k..n-1 |
|
||||||
#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]> |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
// GTEST_n_TYPENAMES_(T) declares a list of n typenames. |
|
||||||
|
|
||||||
$for j [[ |
|
||||||
$range m 0..j-1 |
|
||||||
#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]] |
|
||||||
|
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
// In theory, defining stuff in the ::std namespace is undefined |
|
||||||
// behavior. We can do this as we are playing the role of a standard |
|
||||||
// library vendor. |
|
||||||
namespace std { |
|
||||||
namespace tr1 { |
|
||||||
|
|
||||||
template <$for i, [[typename T$i = void]]> |
|
||||||
class tuple; |
|
||||||
|
|
||||||
// Anything in namespace gtest_internal is Google Test's INTERNAL |
|
||||||
// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code. |
|
||||||
namespace gtest_internal { |
|
||||||
|
|
||||||
// ByRef<T>::type is T if T is a reference; otherwise it's const T&. |
|
||||||
template <typename T> |
|
||||||
struct ByRef { typedef const T& type; }; // NOLINT |
|
||||||
template <typename T> |
|
||||||
struct ByRef<T&> { typedef T& type; }; // NOLINT |
|
||||||
|
|
||||||
// A handy wrapper for ByRef. |
|
||||||
#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type |
|
||||||
|
|
||||||
// AddRef<T>::type is T if T is a reference; otherwise it's T&. This |
|
||||||
// is the same as tr1::add_reference<T>::type. |
|
||||||
template <typename T> |
|
||||||
struct AddRef { typedef T& type; }; // NOLINT |
|
||||||
template <typename T> |
|
||||||
struct AddRef<T&> { typedef T& type; }; // NOLINT |
|
||||||
|
|
||||||
// A handy wrapper for AddRef. |
|
||||||
#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type |
|
||||||
|
|
||||||
// A helper for implementing get<k>(). |
|
||||||
template <int k> class Get; |
|
||||||
|
|
||||||
// A helper for implementing tuple_element<k, T>. kIndexValid is true |
|
||||||
// iff k < the number of fields in tuple type T. |
|
||||||
template <bool kIndexValid, int kIndex, class Tuple> |
|
||||||
struct TupleElement; |
|
||||||
|
|
||||||
|
|
||||||
$for i [[ |
|
||||||
template <GTEST_$(n)_TYPENAMES_(T)> |
|
||||||
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T) > { |
|
||||||
typedef T$i type; |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
]] |
|
||||||
} // namespace gtest_internal |
|
||||||
|
|
||||||
template <> |
|
||||||
class tuple<> { |
|
||||||
public: |
|
||||||
tuple() {} |
|
||||||
tuple(const tuple& /* t */) {} |
|
||||||
tuple& operator=(const tuple& /* t */) { return *this; } |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
$for k [[ |
|
||||||
$range m 0..k-1 |
|
||||||
template <GTEST_$(k)_TYPENAMES_(T)> |
|
||||||
class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] { |
|
||||||
public: |
|
||||||
template <int k> friend class gtest_internal::Get; |
|
||||||
|
|
||||||
tuple() : $for m, [[f$(m)_()]] {} |
|
||||||
|
|
||||||
explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]] |
|
||||||
$for m, [[f$(m)_(f$m)]] {} |
|
||||||
|
|
||||||
tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {} |
|
||||||
|
|
||||||
template <GTEST_$(k)_TYPENAMES_(U)> |
|
||||||
tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {} |
|
||||||
|
|
||||||
$if k == 2 [[ |
|
||||||
template <typename U0, typename U1> |
|
||||||
tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {} |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
tuple& operator=(const tuple& t) { return CopyFrom(t); } |
|
||||||
|
|
||||||
template <GTEST_$(k)_TYPENAMES_(U)> |
|
||||||
tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) { |
|
||||||
return CopyFrom(t); |
|
||||||
} |
|
||||||
|
|
||||||
$if k == 2 [[ |
|
||||||
template <typename U0, typename U1> |
|
||||||
tuple& operator=(const ::std::pair<U0, U1>& p) { |
|
||||||
f0_ = p.first; |
|
||||||
f1_ = p.second; |
|
||||||
return *this; |
|
||||||
} |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
GTEST_DECLARE_TUPLE_AS_FRIEND_ |
|
||||||
|
|
||||||
template <GTEST_$(k)_TYPENAMES_(U)> |
|
||||||
tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) { |
|
||||||
|
|
||||||
$for m [[ |
|
||||||
f$(m)_ = t.f$(m)_; |
|
||||||
|
|
||||||
]] |
|
||||||
return *this; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
$for m [[ |
|
||||||
T$m f$(m)_; |
|
||||||
|
|
||||||
]] |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
]] |
|
||||||
// 6.1.3.2 Tuple creation functions. |
|
||||||
|
|
||||||
// Known limitations: we don't support passing an |
|
||||||
// std::tr1::reference_wrapper<T> to make_tuple(). And we don't |
|
||||||
// implement tie(). |
|
||||||
|
|
||||||
inline tuple<> make_tuple() { return tuple<>(); } |
|
||||||
|
|
||||||
$for k [[ |
|
||||||
$range m 0..k-1 |
|
||||||
|
|
||||||
template <GTEST_$(k)_TYPENAMES_(T)> |
|
||||||
inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) { |
|
||||||
return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]); |
|
||||||
} |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
// 6.1.3.3 Tuple helper classes. |
|
||||||
|
|
||||||
template <typename Tuple> struct tuple_size; |
|
||||||
|
|
||||||
|
|
||||||
$for j [[ |
|
||||||
template <GTEST_$(j)_TYPENAMES_(T)> |
|
||||||
struct tuple_size<GTEST_$(j)_TUPLE_(T) > { |
|
||||||
static const int value = $j; |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
]] |
|
||||||
template <int k, class Tuple> |
|
||||||
struct tuple_element { |
|
||||||
typedef typename gtest_internal::TupleElement< |
|
||||||
k < (tuple_size<Tuple>::value), k, Tuple>::type type; |
|
||||||
}; |
|
||||||
|
|
||||||
#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type |
|
||||||
|
|
||||||
// 6.1.3.4 Element access. |
|
||||||
|
|
||||||
namespace gtest_internal { |
|
||||||
|
|
||||||
|
|
||||||
$for i [[ |
|
||||||
template <> |
|
||||||
class Get<$i> { |
|
||||||
public: |
|
||||||
template <class Tuple> |
|
||||||
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple)) |
|
||||||
Field(Tuple& t) { return t.f$(i)_; } // NOLINT |
|
||||||
|
|
||||||
template <class Tuple> |
|
||||||
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple)) |
|
||||||
ConstField(const Tuple& t) { return t.f$(i)_; } |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
]] |
|
||||||
} // namespace gtest_internal |
|
||||||
|
|
||||||
template <int k, GTEST_$(n)_TYPENAMES_(T)> |
|
||||||
GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T))) |
|
||||||
get(GTEST_$(n)_TUPLE_(T)& t) { |
|
||||||
return gtest_internal::Get<k>::Field(t); |
|
||||||
} |
|
||||||
|
|
||||||
template <int k, GTEST_$(n)_TYPENAMES_(T)> |
|
||||||
GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T))) |
|
||||||
get(const GTEST_$(n)_TUPLE_(T)& t) { |
|
||||||
return gtest_internal::Get<k>::ConstField(t); |
|
||||||
} |
|
||||||
|
|
||||||
// 6.1.3.5 Relational operators |
|
||||||
|
|
||||||
// We only implement == and !=, as we don't have a need for the rest yet. |
|
||||||
|
|
||||||
namespace gtest_internal { |
|
||||||
|
|
||||||
// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the |
|
||||||
// first k fields of t1 equals the first k fields of t2. |
|
||||||
// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if |
|
||||||
// k1 != k2. |
|
||||||
template <int kSize1, int kSize2> |
|
||||||
struct SameSizeTuplePrefixComparator; |
|
||||||
|
|
||||||
template <> |
|
||||||
struct SameSizeTuplePrefixComparator<0, 0> { |
|
||||||
template <class Tuple1, class Tuple2> |
|
||||||
static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
template <int k> |
|
||||||
struct SameSizeTuplePrefixComparator<k, k> { |
|
||||||
template <class Tuple1, class Tuple2> |
|
||||||
static bool Eq(const Tuple1& t1, const Tuple2& t2) { |
|
||||||
return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) && |
|
||||||
::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace gtest_internal |
|
||||||
|
|
||||||
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)> |
|
||||||
inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t, |
|
||||||
const GTEST_$(n)_TUPLE_(U)& u) { |
|
||||||
return gtest_internal::SameSizeTuplePrefixComparator< |
|
||||||
tuple_size<GTEST_$(n)_TUPLE_(T) >::value, |
|
||||||
tuple_size<GTEST_$(n)_TUPLE_(U) >::value>::Eq(t, u); |
|
||||||
} |
|
||||||
|
|
||||||
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)> |
|
||||||
inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t, |
|
||||||
const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); } |
|
||||||
|
|
||||||
// 6.1.4 Pairs. |
|
||||||
// Unimplemented. |
|
||||||
|
|
||||||
} // namespace tr1 |
|
||||||
} // namespace std |
|
||||||
|
|
||||||
|
|
||||||
$for j [[ |
|
||||||
#undef GTEST_$(j)_TUPLE_ |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
|
|
||||||
$for j [[ |
|
||||||
#undef GTEST_$(j)_TYPENAMES_ |
|
||||||
|
|
||||||
]] |
|
||||||
|
|
||||||
#undef GTEST_DECLARE_TUPLE_AS_FRIEND_ |
|
||||||
#undef GTEST_BY_REF_ |
|
||||||
#undef GTEST_ADD_REF_ |
|
||||||
#undef GTEST_TUPLE_ELEMENT_ |
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ |
|
@ -1,319 +0,0 @@ |
|||||||
// Copyright 2007, Google Inc.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived from
|
|
||||||
// this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
#include "gtest/internal/gtest-tuple.h" |
|
||||||
#include <utility> |
|
||||||
#include "gtest/gtest.h" |
|
||||||
|
|
||||||
namespace { |
|
||||||
|
|
||||||
using ::std::tr1::get; |
|
||||||
using ::std::tr1::make_tuple; |
|
||||||
using ::std::tr1::tuple; |
|
||||||
using ::std::tr1::tuple_element; |
|
||||||
using ::std::tr1::tuple_size; |
|
||||||
using ::testing::StaticAssertTypeEq; |
|
||||||
|
|
||||||
// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.
|
|
||||||
TEST(tuple_element_Test, ReturnsElementType) { |
|
||||||
StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>(); |
|
||||||
StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>(); |
|
||||||
StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>(); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests that tuple_size<T>::value gives the number of fields in tuple
|
|
||||||
// type T.
|
|
||||||
TEST(tuple_size_Test, ReturnsNumberOfFields) { |
|
||||||
EXPECT_EQ(0, +tuple_size<tuple<> >::value); |
|
||||||
EXPECT_EQ(1, +tuple_size<tuple<void*> >::value); |
|
||||||
EXPECT_EQ(1, +tuple_size<tuple<char> >::value); |
|
||||||
EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value)); |
|
||||||
EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value)); |
|
||||||
EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests comparing a tuple with itself.
|
|
||||||
TEST(ComparisonTest, ComparesWithSelf) { |
|
||||||
const tuple<int, char, bool> a(5, 'a', false); |
|
||||||
|
|
||||||
EXPECT_TRUE(a == a); |
|
||||||
EXPECT_FALSE(a != a); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests comparing two tuples with the same value.
|
|
||||||
TEST(ComparisonTest, ComparesEqualTuples) { |
|
||||||
const tuple<int, bool> a(5, true), b(5, true); |
|
||||||
|
|
||||||
EXPECT_TRUE(a == b); |
|
||||||
EXPECT_FALSE(a != b); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests comparing two different tuples that have no reference fields.
|
|
||||||
TEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) { |
|
||||||
typedef tuple<const int, char> FooTuple; |
|
||||||
|
|
||||||
const FooTuple a(0, 'x'); |
|
||||||
const FooTuple b(1, 'a'); |
|
||||||
|
|
||||||
EXPECT_TRUE(a != b); |
|
||||||
EXPECT_FALSE(a == b); |
|
||||||
|
|
||||||
const FooTuple c(1, 'b'); |
|
||||||
|
|
||||||
EXPECT_TRUE(b != c); |
|
||||||
EXPECT_FALSE(b == c); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests comparing two different tuples that have reference fields.
|
|
||||||
TEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) { |
|
||||||
typedef tuple<int&, const char&> FooTuple; |
|
||||||
|
|
||||||
int i = 5; |
|
||||||
const char ch = 'a'; |
|
||||||
const FooTuple a(i, ch); |
|
||||||
|
|
||||||
int j = 6; |
|
||||||
const FooTuple b(j, ch); |
|
||||||
|
|
||||||
EXPECT_TRUE(a != b); |
|
||||||
EXPECT_FALSE(a == b); |
|
||||||
|
|
||||||
j = 5; |
|
||||||
const char ch2 = 'b'; |
|
||||||
const FooTuple c(j, ch2); |
|
||||||
|
|
||||||
EXPECT_TRUE(b != c); |
|
||||||
EXPECT_FALSE(b == c); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests that a tuple field with a reference type is an alias of the
|
|
||||||
// variable it's supposed to reference.
|
|
||||||
TEST(ReferenceFieldTest, IsAliasOfReferencedVariable) { |
|
||||||
int n = 0; |
|
||||||
tuple<bool, int&> t(true, n); |
|
||||||
|
|
||||||
n = 1; |
|
||||||
EXPECT_EQ(n, get<1>(t)) |
|
||||||
<< "Changing a underlying variable should update the reference field."; |
|
||||||
|
|
||||||
// Makes sure that the implementation doesn't do anything funny with
|
|
||||||
// the & operator for the return type of get<>().
|
|
||||||
EXPECT_EQ(&n, &(get<1>(t))) |
|
||||||
<< "The address of a reference field should equal the address of " |
|
||||||
<< "the underlying variable."; |
|
||||||
|
|
||||||
get<1>(t) = 2; |
|
||||||
EXPECT_EQ(2, n) |
|
||||||
<< "Changing a reference field should update the underlying variable."; |
|
||||||
} |
|
||||||
|
|
||||||
// Tests that tuple's default constructor default initializes each field.
|
|
||||||
// This test needs to compile without generating warnings.
|
|
||||||
TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) { |
|
||||||
// The TR1 report requires that tuple's default constructor default
|
|
||||||
// initializes each field, even if it's a primitive type. If the
|
|
||||||
// implementation forgets to do this, this test will catch it by
|
|
||||||
// generating warnings about using uninitialized variables (assuming
|
|
||||||
// a decent compiler).
|
|
||||||
|
|
||||||
tuple<> empty; |
|
||||||
|
|
||||||
tuple<int> a1, b1; |
|
||||||
b1 = a1; |
|
||||||
EXPECT_EQ(0, get<0>(b1)); |
|
||||||
|
|
||||||
tuple<int, double> a2, b2; |
|
||||||
b2 = a2; |
|
||||||
EXPECT_EQ(0, get<0>(b2)); |
|
||||||
EXPECT_EQ(0.0, get<1>(b2)); |
|
||||||
|
|
||||||
tuple<double, char, bool*> a3, b3; |
|
||||||
b3 = a3; |
|
||||||
EXPECT_EQ(0.0, get<0>(b3)); |
|
||||||
EXPECT_EQ('\0', get<1>(b3)); |
|
||||||
EXPECT_TRUE(get<2>(b3) == nullptr); |
|
||||||
|
|
||||||
tuple<int, int, int, int, int, int, int, int, int, int> a10, b10; |
|
||||||
b10 = a10; |
|
||||||
EXPECT_EQ(0, get<0>(b10)); |
|
||||||
EXPECT_EQ(0, get<1>(b10)); |
|
||||||
EXPECT_EQ(0, get<2>(b10)); |
|
||||||
EXPECT_EQ(0, get<3>(b10)); |
|
||||||
EXPECT_EQ(0, get<4>(b10)); |
|
||||||
EXPECT_EQ(0, get<5>(b10)); |
|
||||||
EXPECT_EQ(0, get<6>(b10)); |
|
||||||
EXPECT_EQ(0, get<7>(b10)); |
|
||||||
EXPECT_EQ(0, get<8>(b10)); |
|
||||||
EXPECT_EQ(0, get<9>(b10)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests constructing a tuple from its fields.
|
|
||||||
TEST(TupleConstructorTest, ConstructsFromFields) { |
|
||||||
int n = 1; |
|
||||||
// Reference field.
|
|
||||||
tuple<int&> a(n); |
|
||||||
EXPECT_EQ(&n, &(get<0>(a))); |
|
||||||
|
|
||||||
// Non-reference fields.
|
|
||||||
tuple<int, char> b(5, 'a'); |
|
||||||
EXPECT_EQ(5, get<0>(b)); |
|
||||||
EXPECT_EQ('a', get<1>(b)); |
|
||||||
|
|
||||||
// Const reference field.
|
|
||||||
const int m = 2; |
|
||||||
tuple<bool, const int&> c(true, m); |
|
||||||
EXPECT_TRUE(get<0>(c)); |
|
||||||
EXPECT_EQ(&m, &(get<1>(c))); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests tuple's copy constructor.
|
|
||||||
TEST(TupleConstructorTest, CopyConstructor) { |
|
||||||
tuple<double, bool> a(0.0, true); |
|
||||||
tuple<double, bool> b(a); |
|
||||||
|
|
||||||
EXPECT_DOUBLE_EQ(0.0, get<0>(b)); |
|
||||||
EXPECT_TRUE(get<1>(b)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests constructing a tuple from another tuple that has a compatible
|
|
||||||
// but different type.
|
|
||||||
TEST(TupleConstructorTest, ConstructsFromDifferentTupleType) { |
|
||||||
tuple<int, int, char> a(0, 1, 'a'); |
|
||||||
tuple<double, long, int> b(a); |
|
||||||
|
|
||||||
EXPECT_DOUBLE_EQ(0.0, get<0>(b)); |
|
||||||
EXPECT_EQ(1, get<1>(b)); |
|
||||||
EXPECT_EQ('a', get<2>(b)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests constructing a 2-tuple from an std::pair.
|
|
||||||
TEST(TupleConstructorTest, ConstructsFromPair) { |
|
||||||
::std::pair<int, char> a(1, 'a'); |
|
||||||
tuple<int, char> b(a); |
|
||||||
tuple<int, const char&> c(a); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests assigning a tuple to another tuple with the same type.
|
|
||||||
TEST(TupleAssignmentTest, AssignsToSameTupleType) { |
|
||||||
const tuple<int, long> a(5, 7L); |
|
||||||
tuple<int, long> b; |
|
||||||
b = a; |
|
||||||
EXPECT_EQ(5, get<0>(b)); |
|
||||||
EXPECT_EQ(7L, get<1>(b)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests assigning a tuple to another tuple with a different but
|
|
||||||
// compatible type.
|
|
||||||
TEST(TupleAssignmentTest, AssignsToDifferentTupleType) { |
|
||||||
const tuple<int, long, bool> a(1, 7L, true); |
|
||||||
tuple<long, int, bool> b; |
|
||||||
b = a; |
|
||||||
EXPECT_EQ(1L, get<0>(b)); |
|
||||||
EXPECT_EQ(7, get<1>(b)); |
|
||||||
EXPECT_TRUE(get<2>(b)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests assigning an std::pair to a 2-tuple.
|
|
||||||
TEST(TupleAssignmentTest, AssignsFromPair) { |
|
||||||
const ::std::pair<int, bool> a(5, true); |
|
||||||
tuple<int, bool> b; |
|
||||||
b = a; |
|
||||||
EXPECT_EQ(5, get<0>(b)); |
|
||||||
EXPECT_TRUE(get<1>(b)); |
|
||||||
|
|
||||||
tuple<long, bool> c; |
|
||||||
c = a; |
|
||||||
EXPECT_EQ(5L, get<0>(c)); |
|
||||||
EXPECT_TRUE(get<1>(c)); |
|
||||||
} |
|
||||||
|
|
||||||
// A fixture for testing big tuples.
|
|
||||||
class BigTupleTest : public testing::Test { |
|
||||||
protected: |
|
||||||
typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple; |
|
||||||
|
|
||||||
BigTupleTest() : |
|
||||||
a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2), |
|
||||||
b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {} |
|
||||||
|
|
||||||
BigTuple a_, b_; |
|
||||||
}; |
|
||||||
|
|
||||||
// Tests constructing big tuples.
|
|
||||||
TEST_F(BigTupleTest, Construction) { |
|
||||||
BigTuple a; |
|
||||||
BigTuple b(b_); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.
|
|
||||||
TEST_F(BigTupleTest, get) { |
|
||||||
EXPECT_EQ(1, get<0>(a_)); |
|
||||||
EXPECT_EQ(2, get<9>(a_)); |
|
||||||
|
|
||||||
// Tests that get() works on a const tuple too.
|
|
||||||
const BigTuple a(a_); |
|
||||||
EXPECT_EQ(1, get<0>(a)); |
|
||||||
EXPECT_EQ(2, get<9>(a)); |
|
||||||
} |
|
||||||
|
|
||||||
// Tests comparing big tuples.
|
|
||||||
TEST_F(BigTupleTest, Comparisons) { |
|
||||||
EXPECT_TRUE(a_ == a_); |
|
||||||
EXPECT_FALSE(a_ != a_); |
|
||||||
|
|
||||||
EXPECT_TRUE(a_ != b_); |
|
||||||
EXPECT_FALSE(a_ == b_); |
|
||||||
} |
|
||||||
|
|
||||||
TEST(MakeTupleTest, WorksForScalarTypes) { |
|
||||||
tuple<bool, int> a; |
|
||||||
a = make_tuple(true, 5); |
|
||||||
EXPECT_TRUE(get<0>(a)); |
|
||||||
EXPECT_EQ(5, get<1>(a)); |
|
||||||
|
|
||||||
tuple<char, int, long> b; |
|
||||||
b = make_tuple('a', 'b', 5); |
|
||||||
EXPECT_EQ('a', get<0>(b)); |
|
||||||
EXPECT_EQ('b', get<1>(b)); |
|
||||||
EXPECT_EQ(5, get<2>(b)); |
|
||||||
} |
|
||||||
|
|
||||||
TEST(MakeTupleTest, WorksForPointers) { |
|
||||||
int a[] = { 1, 2, 3, 4 }; |
|
||||||
const char* const str = "hi"; |
|
||||||
int* const p = a; |
|
||||||
|
|
||||||
tuple<const char*, int*> t; |
|
||||||
t = make_tuple(str, p); |
|
||||||
EXPECT_EQ(str, get<0>(t)); |
|
||||||
EXPECT_EQ(p, get<1>(t)); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace
|
|
Loading…
Reference in new issue