googletest/googlemock/include/gmock/gmock-more-matchers.h

93 lines
3.3 KiB
C
Raw Normal View History

// Copyright 2013, 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.
// Google Mock - a framework for writing C++ mock classes.
//
// This file implements some matchers that depend on gmock-generated-matchers.h.
//
// Note that tests are implemented in gmock-matchers_test.cc rather than
// gmock-more-matchers-test.cc.
// GOOGLETEST_CM0002 DO NOT DELETE
googletest export - 208874130 Copybara tweaks, testing various round-trip sutuations(fu... by misterg <misterg@google.com> - 208880646 Fix header guards and remove special case copybara by misterg <misterg@google.com> - 208874252 Copybara tweaks for googletest reversible transform by misterg <misterg@google.com> - 208853103 Adding a flow to export PR from GitHub into Google3 and a... by misterg <misterg@google.com> - 208708150 Removing leakr-sensitive words. by misterg <misterg@google.com> - 208672083 Import of OSS PR 1665 by misterg <misterg@google.com> - 208663904 Remove LEAKR "author" warnings for googletest copybara ex... by misterg <misterg@google.com> - 208646244 Incrementally finalizing OSS<->google3 transforms by misterg <misterg@google.com> - 208548323 Move custom google3 only code to custom/ by misterg <misterg@google.com> - 208234974 Removed scrubs, replaced with reversible transforms by misterg <misterg@google.com> - 208211213 Move custom tests under custom by misterg <misterg@google.com> - 208082996 Replace of OSS insert with reversible replace by misterg <misterg@google.com> - 208072299 Replace scrubs with reversible replaces, incrementally ge... by misterg <misterg@google.com> - 208059357 Replace scrub with reversible replace by misterg <misterg@google.com> - 208055415 Fixing GCC brace warning that shows up in OSS with GCC8 a... by misterg <misterg@google.com> - 207933728 Incrementally getting close to the reversible transformat... by misterg <misterg@google.com> - 207917581 Removing stripping with replace dictionary entries to eas... by misterg <misterg@google.com> - 207911026 Incremental Tweaks, on the way to reversible google3<-> g... by misterg <misterg@google.com> - 207905179 Removing unnecessary comments stripping by misterg <misterg@google.com> - 207901741 Fix typo in Fuchsia death-test implementation. by Abseil Team <absl-team@google.com> - 207776408 Move custom tests into /custom by misterg <misterg@google.com> - 207746583 Remove stripping for printer for absl:variant by misterg <misterg@google.com> - 207733597 Suppress default exception handling for death-test proces... by Abseil Team <absl-team@google.com> - 207719598 Import of googletest from Github. by misterg <misterg@google.com> - 207283991 PR1673, extra parentheses in declaration cause GCC 8.1.1 ... by misterg <misterg@google.com> - 206986279 Fix Duplicate definition, (original in googletest-test_te... by misterg <misterg@google.com> - 206980794 Allow googletest-json-output unitest to handle supporting... by misterg <misterg@google.com> - 206957064 Refactor to avoid OSS round-trip transformation problems ... by misterg <misterg@google.com> - 206760733 Fixed weird syntax in these tests that was causing OSS tr... by misterg <misterg@google.com> - 206750694 Tweak copybara, by misterg <misterg@google.com> - 206611945 Make files consistent to enable copybara round-trip trans... by misterg <misterg@google.com> - 206589404 OSS changes to open source two more tests by misterg <misterg@google.com> - 206355044 Fixing copybara (was missing comment) by misterg <misterg@google.com> - 206323492 Make reversible transforms possible for Copybara OSS<->go... by misterg <misterg@google.com> - 206011852 Consolidate various copybara files into one file. by misterg <misterg@google.com> - 205999518 remove weird char, should be space. pump and generated .h... by misterg <misterg@google.com> - 205897244 Small cleanups to avoid potentially hard-to-reverse OSS t... by misterg <misterg@google.com> - 205894405 Simplifying include path for tests. by misterg <misterg@google.com> - 205892873 Removing obsolete files by misterg <misterg@google.com> - 205873647 Simplifying include path for samples. by misterg <misterg@google.com> - 205712910 Continue restructuring, will have common copybara file to... by misterg <misterg@google.com> - 205711819 Removing non-ASCII chars by misterg <misterg@google.com> - 205702635 Refactor internal googletest name to match OSS Name by misterg <misterg@google.com> - 205403311 Comments change by misterg <misterg@google.com> - 205246538 OSS community (https://github.com/google/googletest/pull/... by misterg <misterg@google.com> - 205242422 Moving RE2 into custom where it rightfully belongs by misterg <misterg@google.com> - 205138666 Add a 3-ary Property() matcher overload for ref-qualified... by Abseil Team <absl-team@google.com> - 205128154 Automated g4 rollback of changelist 205108639. by misterg <misterg@google.com> - 205108639 Moving RE2 into custom where it rightfully belongs by misterg <misterg@google.com> - 205102342 Comment link fix by misterg <misterg@google.com> - 205097052 OSS sync, still need to worry about not C++11 by misterg <misterg@google.com> - 205080271 Keeping up with the changes, ensure that the code still t... by misterg <misterg@google.com> - 204815384 Mark the various RE legacy versions of the matchers as de... by Abseil Team <absl-team@google.com> - 204744294 OSS, someone noticed that if GTEST_HAS_EXCEPTIONS is set ... by misterg <misterg@google.com> - 204363541 Add stacktrace support to the non-Google3 version of Goog... by Abseil Team <absl-team@google.com> - 204330832 Google Test: absl::variant is now open source, so add the by Abseil Team <absl-team@google.com> - 204130690 Bringing in OSS PR 1647 by misterg <misterg@google.com> - 203979061 Set 'reason' field for leakr.disable_check() transformati... by Abseil Team <absl-team@google.com> - 203954557 Fixing comments, otherwise copybara leaves extra "//" in ... by misterg <misterg@google.com> - 203487065 Correctly handle legacy regular expressions in googletest... by Abseil Team <absl-team@google.com> - 201997367 Remove references to GTEST_HAS_PROTOBUF_. by Abseil Team <absl-team@google.com> - 201735597 Upgrade gUnit from RE to RE2 -- Step 3/4 by Abseil Team <absl-team@google.com> - 201229160 Upgrade gUnit from RE to RE2 -- Step 1/4 by Abseil Team <absl-team@google.com> - 201228020 Remove extra copy of gunit samples - there should really ... by misterg <misterg@google.com> - 200602156 Eliminate GTEST_TEST_FILTER_ENV_VAR_. by Abseil Team <absl-team@google.com> - 200500026 Make RegisterTasks faster by Abseil Team <absl-team@google.com> - 200361990 Add IWYU pragmas to gmock headers. by Abseil Team <absl-team@google.com> - 200292286 Fix speling by Abseil Team <absl-team@google.com> - 200222319 Adding docs to copybara. by misterg <misterg@google.com> - 199815917 Fuchsia: Change fdio include path. by Abseil Team <absl-team@google.com> - 199195290 Remove launchpad dependency from Fuchsia. by Abseil Team <absl-team@google.com> - 199134849 Add printer for std::nullptr_t. by Abseil Team <absl-team@google.com> - 198710999 Properly decay variadic matchers by Abseil Team <absl-team@google.com> - 197733704 WIP - copybara script capable of google3-to-github by misterg <misterg@google.com> - 197166689 Keeping up, sync cl/197012432 to combined "googletest" di... by misterg <misterg@google.com> - 196253300 Keep up with changes,cl/196162435 by misterg <misterg@google.com> - 195816901 go/googletest-plan by misterg <misterg@google.com> - 195816542 Moving http://cl/167016557 and http://cl/195690905 into c... by misterg <misterg@google.com> - 195712930 Following up for http://cl/195677772 More fixing typos, p... by misterg <misterg@google.com> - 195702162 Moving http://cl/195020996 into combined dir by misterg <misterg@google.com> - 195677772 Fix typos, the original IWYU was by misterg <misterg@google.com> - 195249681 go/googletest-plan , Combine gUnit and gMock into third_p... by misterg <misterg@google.com> PiperOrigin-RevId: 208874130
2018-08-15 22:38:42 +02:00
#ifndef GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_
#include "gmock/gmock-generated-matchers.h"
namespace testing {
2018-04-05 20:41:16 +02:00
// Silence C4100 (unreferenced formal
// parameter) for MSVC
2018-04-05 20:00:14 +02:00
#ifdef _MSC_VER
2018-04-12 15:12:02 +02:00
# pragma warning(push)
2018-04-05 20:00:14 +02:00
# pragma warning(disable:4100)
2018-04-05 20:24:12 +02:00
#if (_MSC_VER == 1900)
2018-04-12 15:12:02 +02:00
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
2018-04-05 20:24:12 +02:00
# pragma warning(disable:4800)
#endif
2018-04-05 20:00:14 +02:00
#endif
// Defines a matcher that matches an empty container. The container must
// support both size() and empty(), which all STL-like containers provide.
MATCHER(IsEmpty, negation ? "isn't empty" : "is empty") {
if (arg.empty()) {
return true;
}
*result_listener << "whose size is " << arg.size();
return false;
}
2018-01-26 17:57:58 +01:00
// Define a matcher that matches a value that evaluates in boolean
// context to true. Useful for types that define "explicit operator
// bool" operators and so can't be compared for equality with true
// and false.
MATCHER(IsTrue, negation ? "is false" : "is true") {
return static_cast<bool>(arg);
}
// Define a matcher that matches a value that evaluates in boolean
// context to false. Useful for types that define "explicit operator
// bool" operators and so can't be compared for equality with true
// and false.
MATCHER(IsFalse, negation ? "is true" : "is false") {
return !static_cast<bool>(arg);
}
2018-04-12 15:12:02 +02:00
#ifdef _MSC_VER
# pragma warning(pop)
#endif
} // namespace testing
googletest export - 208874130 Copybara tweaks, testing various round-trip sutuations(fu... by misterg <misterg@google.com> - 208880646 Fix header guards and remove special case copybara by misterg <misterg@google.com> - 208874252 Copybara tweaks for googletest reversible transform by misterg <misterg@google.com> - 208853103 Adding a flow to export PR from GitHub into Google3 and a... by misterg <misterg@google.com> - 208708150 Removing leakr-sensitive words. by misterg <misterg@google.com> - 208672083 Import of OSS PR 1665 by misterg <misterg@google.com> - 208663904 Remove LEAKR "author" warnings for googletest copybara ex... by misterg <misterg@google.com> - 208646244 Incrementally finalizing OSS<->google3 transforms by misterg <misterg@google.com> - 208548323 Move custom google3 only code to custom/ by misterg <misterg@google.com> - 208234974 Removed scrubs, replaced with reversible transforms by misterg <misterg@google.com> - 208211213 Move custom tests under custom by misterg <misterg@google.com> - 208082996 Replace of OSS insert with reversible replace by misterg <misterg@google.com> - 208072299 Replace scrubs with reversible replaces, incrementally ge... by misterg <misterg@google.com> - 208059357 Replace scrub with reversible replace by misterg <misterg@google.com> - 208055415 Fixing GCC brace warning that shows up in OSS with GCC8 a... by misterg <misterg@google.com> - 207933728 Incrementally getting close to the reversible transformat... by misterg <misterg@google.com> - 207917581 Removing stripping with replace dictionary entries to eas... by misterg <misterg@google.com> - 207911026 Incremental Tweaks, on the way to reversible google3<-> g... by misterg <misterg@google.com> - 207905179 Removing unnecessary comments stripping by misterg <misterg@google.com> - 207901741 Fix typo in Fuchsia death-test implementation. by Abseil Team <absl-team@google.com> - 207776408 Move custom tests into /custom by misterg <misterg@google.com> - 207746583 Remove stripping for printer for absl:variant by misterg <misterg@google.com> - 207733597 Suppress default exception handling for death-test proces... by Abseil Team <absl-team@google.com> - 207719598 Import of googletest from Github. by misterg <misterg@google.com> - 207283991 PR1673, extra parentheses in declaration cause GCC 8.1.1 ... by misterg <misterg@google.com> - 206986279 Fix Duplicate definition, (original in googletest-test_te... by misterg <misterg@google.com> - 206980794 Allow googletest-json-output unitest to handle supporting... by misterg <misterg@google.com> - 206957064 Refactor to avoid OSS round-trip transformation problems ... by misterg <misterg@google.com> - 206760733 Fixed weird syntax in these tests that was causing OSS tr... by misterg <misterg@google.com> - 206750694 Tweak copybara, by misterg <misterg@google.com> - 206611945 Make files consistent to enable copybara round-trip trans... by misterg <misterg@google.com> - 206589404 OSS changes to open source two more tests by misterg <misterg@google.com> - 206355044 Fixing copybara (was missing comment) by misterg <misterg@google.com> - 206323492 Make reversible transforms possible for Copybara OSS<->go... by misterg <misterg@google.com> - 206011852 Consolidate various copybara files into one file. by misterg <misterg@google.com> - 205999518 remove weird char, should be space. pump and generated .h... by misterg <misterg@google.com> - 205897244 Small cleanups to avoid potentially hard-to-reverse OSS t... by misterg <misterg@google.com> - 205894405 Simplifying include path for tests. by misterg <misterg@google.com> - 205892873 Removing obsolete files by misterg <misterg@google.com> - 205873647 Simplifying include path for samples. by misterg <misterg@google.com> - 205712910 Continue restructuring, will have common copybara file to... by misterg <misterg@google.com> - 205711819 Removing non-ASCII chars by misterg <misterg@google.com> - 205702635 Refactor internal googletest name to match OSS Name by misterg <misterg@google.com> - 205403311 Comments change by misterg <misterg@google.com> - 205246538 OSS community (https://github.com/google/googletest/pull/... by misterg <misterg@google.com> - 205242422 Moving RE2 into custom where it rightfully belongs by misterg <misterg@google.com> - 205138666 Add a 3-ary Property() matcher overload for ref-qualified... by Abseil Team <absl-team@google.com> - 205128154 Automated g4 rollback of changelist 205108639. by misterg <misterg@google.com> - 205108639 Moving RE2 into custom where it rightfully belongs by misterg <misterg@google.com> - 205102342 Comment link fix by misterg <misterg@google.com> - 205097052 OSS sync, still need to worry about not C++11 by misterg <misterg@google.com> - 205080271 Keeping up with the changes, ensure that the code still t... by misterg <misterg@google.com> - 204815384 Mark the various RE legacy versions of the matchers as de... by Abseil Team <absl-team@google.com> - 204744294 OSS, someone noticed that if GTEST_HAS_EXCEPTIONS is set ... by misterg <misterg@google.com> - 204363541 Add stacktrace support to the non-Google3 version of Goog... by Abseil Team <absl-team@google.com> - 204330832 Google Test: absl::variant is now open source, so add the by Abseil Team <absl-team@google.com> - 204130690 Bringing in OSS PR 1647 by misterg <misterg@google.com> - 203979061 Set 'reason' field for leakr.disable_check() transformati... by Abseil Team <absl-team@google.com> - 203954557 Fixing comments, otherwise copybara leaves extra "//" in ... by misterg <misterg@google.com> - 203487065 Correctly handle legacy regular expressions in googletest... by Abseil Team <absl-team@google.com> - 201997367 Remove references to GTEST_HAS_PROTOBUF_. by Abseil Team <absl-team@google.com> - 201735597 Upgrade gUnit from RE to RE2 -- Step 3/4 by Abseil Team <absl-team@google.com> - 201229160 Upgrade gUnit from RE to RE2 -- Step 1/4 by Abseil Team <absl-team@google.com> - 201228020 Remove extra copy of gunit samples - there should really ... by misterg <misterg@google.com> - 200602156 Eliminate GTEST_TEST_FILTER_ENV_VAR_. by Abseil Team <absl-team@google.com> - 200500026 Make RegisterTasks faster by Abseil Team <absl-team@google.com> - 200361990 Add IWYU pragmas to gmock headers. by Abseil Team <absl-team@google.com> - 200292286 Fix speling by Abseil Team <absl-team@google.com> - 200222319 Adding docs to copybara. by misterg <misterg@google.com> - 199815917 Fuchsia: Change fdio include path. by Abseil Team <absl-team@google.com> - 199195290 Remove launchpad dependency from Fuchsia. by Abseil Team <absl-team@google.com> - 199134849 Add printer for std::nullptr_t. by Abseil Team <absl-team@google.com> - 198710999 Properly decay variadic matchers by Abseil Team <absl-team@google.com> - 197733704 WIP - copybara script capable of google3-to-github by misterg <misterg@google.com> - 197166689 Keeping up, sync cl/197012432 to combined "googletest" di... by misterg <misterg@google.com> - 196253300 Keep up with changes,cl/196162435 by misterg <misterg@google.com> - 195816901 go/googletest-plan by misterg <misterg@google.com> - 195816542 Moving http://cl/167016557 and http://cl/195690905 into c... by misterg <misterg@google.com> - 195712930 Following up for http://cl/195677772 More fixing typos, p... by misterg <misterg@google.com> - 195702162 Moving http://cl/195020996 into combined dir by misterg <misterg@google.com> - 195677772 Fix typos, the original IWYU was by misterg <misterg@google.com> - 195249681 go/googletest-plan , Combine gUnit and gMock into third_p... by misterg <misterg@google.com> PiperOrigin-RevId: 208874130
2018-08-15 22:38:42 +02:00
#endif // GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_