Warning, /JETSCAPE/external_packages/googletest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump is written in an unsupported language. File is not indexed.
0001 $$ -*- mode: c++; -*-
0002 $$ This is a Pump source file. Please use Pump to convert it to
0003 $$ gmock-generated-nice-strict.h.
0004 $$
0005 $var n = 10 $$ The maximum arity we support.
0006 // Copyright 2008, Google Inc.
0007 // All rights reserved.
0008 //
0009 // Redistribution and use in source and binary forms, with or without
0010 // modification, are permitted provided that the following conditions are
0011 // met:
0012 //
0013 // * Redistributions of source code must retain the above copyright
0014 // notice, this list of conditions and the following disclaimer.
0015 // * Redistributions in binary form must reproduce the above
0016 // copyright notice, this list of conditions and the following disclaimer
0017 // in the documentation and/or other materials provided with the
0018 // distribution.
0019 // * Neither the name of Google Inc. nor the names of its
0020 // contributors may be used to endorse or promote products derived from
0021 // this software without specific prior written permission.
0022 //
0023 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0024 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0025 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0026 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0027 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0028 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0029 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0030 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0031 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0032 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0033 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0034 //
0035 // Author: wan@google.com (Zhanyong Wan)
0036
0037 // Implements class templates NiceMock, NaggyMock, and StrictMock.
0038 //
0039 // Given a mock class MockFoo that is created using Google Mock,
0040 // NiceMock<MockFoo> is a subclass of MockFoo that allows
0041 // uninteresting calls (i.e. calls to mock methods that have no
0042 // EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
0043 // that prints a warning when an uninteresting call occurs, and
0044 // StrictMock<MockFoo> is a subclass of MockFoo that treats all
0045 // uninteresting calls as errors.
0046 //
0047 // Currently a mock is naggy by default, so MockFoo and
0048 // NaggyMock<MockFoo> behave like the same. However, we will soon
0049 // switch the default behavior of mocks to be nice, as that in general
0050 // leads to more maintainable tests. When that happens, MockFoo will
0051 // stop behaving like NaggyMock<MockFoo> and start behaving like
0052 // NiceMock<MockFoo>.
0053 //
0054 // NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
0055 // their respective base class, with up-to $n arguments. Therefore
0056 // you can write NiceMock<MockFoo>(5, "a") to construct a nice mock
0057 // where MockFoo has a constructor that accepts (int, const char*),
0058 // for example.
0059 //
0060 // A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
0061 // and StrictMock<MockFoo> only works for mock methods defined using
0062 // the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
0063 // If a mock method is defined in a base class of MockFoo, the "nice"
0064 // or "strict" modifier may not affect it, depending on the compiler.
0065 // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
0066 // supported.
0067 //
0068 // Another known limitation is that the constructors of the base mock
0069 // cannot have arguments passed by non-const reference, which are
0070 // banned by the Google C++ style guide anyway.
0071
0072 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
0073 #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
0074
0075 #include "gmock/gmock-spec-builders.h"
0076 #include "gmock/internal/gmock-port.h"
0077
0078 namespace testing {
0079
0080 $range kind 0..2
0081 $for kind [[
0082
0083 $var clazz=[[$if kind==0 [[NiceMock]]
0084 $elif kind==1 [[NaggyMock]]
0085 $else [[StrictMock]]]]
0086
0087 $var method=[[$if kind==0 [[AllowUninterestingCalls]]
0088 $elif kind==1 [[WarnUninterestingCalls]]
0089 $else [[FailUninterestingCalls]]]]
0090
0091 template <class MockClass>
0092 class $clazz : public MockClass {
0093 public:
0094 // We don't factor out the constructor body to a common method, as
0095 // we have to avoid a possible clash with members of MockClass.
0096 $clazz() {
0097 ::testing::Mock::$method(
0098 internal::ImplicitCast_<MockClass*>(this));
0099 }
0100
0101 // C++ doesn't (yet) allow inheritance of constructors, so we have
0102 // to define it for each arity.
0103 template <typename A1>
0104 explicit $clazz(const A1& a1) : MockClass(a1) {
0105 ::testing::Mock::$method(
0106 internal::ImplicitCast_<MockClass*>(this));
0107 }
0108
0109 $range i 2..n
0110 $for i [[
0111 $range j 1..i
0112 template <$for j, [[typename A$j]]>
0113 $clazz($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) {
0114 ::testing::Mock::$method(
0115 internal::ImplicitCast_<MockClass*>(this));
0116 }
0117
0118
0119 ]]
0120 virtual ~$clazz() {
0121 ::testing::Mock::UnregisterCallReaction(
0122 internal::ImplicitCast_<MockClass*>(this));
0123 }
0124
0125 private:
0126 GTEST_DISALLOW_COPY_AND_ASSIGN_($clazz);
0127 };
0128
0129 ]]
0130
0131 // The following specializations catch some (relatively more common)
0132 // user errors of nesting nice and strict mocks. They do NOT catch
0133 // all possible errors.
0134
0135 // These specializations are declared but not defined, as NiceMock,
0136 // NaggyMock, and StrictMock cannot be nested.
0137
0138 template <typename MockClass>
0139 class NiceMock<NiceMock<MockClass> >;
0140 template <typename MockClass>
0141 class NiceMock<NaggyMock<MockClass> >;
0142 template <typename MockClass>
0143 class NiceMock<StrictMock<MockClass> >;
0144
0145 template <typename MockClass>
0146 class NaggyMock<NiceMock<MockClass> >;
0147 template <typename MockClass>
0148 class NaggyMock<NaggyMock<MockClass> >;
0149 template <typename MockClass>
0150 class NaggyMock<StrictMock<MockClass> >;
0151
0152 template <typename MockClass>
0153 class StrictMock<NiceMock<MockClass> >;
0154 template <typename MockClass>
0155 class StrictMock<NaggyMock<MockClass> >;
0156 template <typename MockClass>
0157 class StrictMock<StrictMock<MockClass> >;
0158
0159 } // namespace testing
0160
0161 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_