Unverified Commit 7e7e3a6f authored by Gennadiy Civil's avatar Gennadiy Civil Committed by GitHub
Browse files

Merge branch 'master' into patch-1

parents b50b2f77 997d343d
...@@ -38,3 +38,6 @@ googletest/m4/lt~obsolete.m4 ...@@ -38,3 +38,6 @@ googletest/m4/lt~obsolete.m4
# Ignore generated directories. # Ignore generated directories.
googlemock/fused-src/ googlemock/fused-src/
googletest/fused-src/ googletest/fused-src/
# macOS files
.DS_Store
# Build matrix / environment variable are explained on: # Build matrix / environment variable are explained on:
# http://about.travis-ci.org/docs/user/build-configuration/ # https://docs.travis-ci.com/user/customizing-the-build/
# This file can be validated on: # This file can be validated on:
# http://lint.travis-ci.org/ # http://lint.travis-ci.org/
......
...@@ -38,7 +38,7 @@ licenses(["notice"]) ...@@ -38,7 +38,7 @@ licenses(["notice"])
config_setting( config_setting(
name = "windows", name = "windows",
values = { "cpu": "x64_windows" }, values = {"cpu": "x64_windows"},
) )
config_setting( config_setting(
...@@ -51,7 +51,6 @@ config_setting( ...@@ -51,7 +51,6 @@ config_setting(
values = {"define": "absl=1"}, values = {"define": "absl=1"},
) )
# Google Test including Google Mock # Google Test including Google Mock
cc_library( cc_library(
name = "gtest", name = "gtest",
...@@ -70,7 +69,7 @@ cc_library( ...@@ -70,7 +69,7 @@ cc_library(
"googlemock/src/gmock_main.cc", "googlemock/src/gmock_main.cc",
], ],
), ),
hdrs =glob([ hdrs = glob([
"googletest/include/gtest/*.h", "googletest/include/gtest/*.h",
"googlemock/include/gmock/*.h", "googlemock/include/gmock/*.h",
]), ]),
...@@ -81,6 +80,14 @@ cc_library( ...@@ -81,6 +80,14 @@ cc_library(
"//conditions:default": ["-pthread"], "//conditions:default": ["-pthread"],
}, },
), ),
defines = select(
{
":has_absl": [
"GTEST_HAS_ABSL=1",
],
"//conditions:default": [],
},
),
includes = [ includes = [
"googlemock", "googlemock",
"googlemock/include", "googlemock/include",
...@@ -94,21 +101,19 @@ cc_library( ...@@ -94,21 +101,19 @@ cc_library(
"-pthread", "-pthread",
], ],
}), }),
defines = select ({ deps = select(
":has_absl": [ {
"GTEST_HAS_ABSL=1", ":has_absl": [
], "@com_google_absl//absl/debugging:failure_signal_handler",
"//conditions:default": [], "@com_google_absl//absl/debugging:stacktrace",
} "@com_google_absl//absl/debugging:symbolize",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:variant",
],
"//conditions:default": [],
},
), ),
deps = select ({
":has_absl": [
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/strings"
],
"//conditions:default": [],
}
)
) )
cc_library( cc_library(
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
[![Build Status](https://travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest) [![Build Status](https://travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest)
[![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master) [![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)
**Future Plans**:
* 1.8.x Release - the 1.8.x will be the last release that works with pre-C++11 compilers. The 1.8.1 will not accept any requests for any new features and any bugfix requests will only be accepted if proven "critical"
* Post 1.8.x - work to improve/cleanup/pay technical debt. When this work is completed there will be a 1.9.x tagged release
* Post 1.9.x googletest will follow [Abseil Live at Head philosophy](https://abseil.io/about/philosophy)
Welcome to **Google Test**, Google's C++ test framework! Welcome to **Google Test**, Google's C++ test framework!
This repository is a merger of the formerly separate GoogleTest and This repository is a merger of the formerly separate GoogleTest and
......
...@@ -128,13 +128,13 @@ if(INSTALL_GMOCK) ...@@ -128,13 +128,13 @@ if(INSTALL_GMOCK)
# configure and install pkgconfig files # configure and install pkgconfig files
configure_file( configure_file(
cmake/gmock.pc.in cmake/gmock.pc.in
"${CMAKE_BINARY_DIR}/gmock.pc" "${gmock_BINARY_DIR}/gmock.pc"
@ONLY) @ONLY)
configure_file( configure_file(
cmake/gmock_main.pc.in cmake/gmock_main.pc.in
"${CMAKE_BINARY_DIR}/gmock_main.pc" "${gmock_BINARY_DIR}/gmock_main.pc"
@ONLY) @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/gmock.pc" "${CMAKE_BINARY_DIR}/gmock_main.pc" install(FILES "${gmock_BINARY_DIR}/gmock.pc" "${gmock_BINARY_DIR}/gmock_main.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif() endif()
......
...@@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic }; ...@@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
class Buzz { class Buzz {
public: public:
explicit Buzz(AccessLevel access) { } explicit Buzz(AccessLevel access) { ... }
... ...
}; };
...@@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil ...@@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil
Quiz time! What do you think will happen if a `Return(ByMove(...))` action is Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
performed more than once (e.g. you write performed more than once (e.g. you write
`.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first `.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
time the action runs, the source value will be consumed (since it’s a move-only time the action runs, the source value will be consumed (since it’s a move-only
value), so the next time around, there’s no value to move from -- you’ll get a value), so the next time around, there’s no value to move from -- you’ll get a
run-time error that `Return(ByMove(...))` can only be run once. run-time error that `Return(ByMove(...))` can only be run once.
......
...@@ -170,7 +170,7 @@ Admittedly, this test is contrived and doesn't do much. You can easily achieve t ...@@ -170,7 +170,7 @@ Admittedly, this test is contrived and doesn't do much. You can easily achieve t
## Using Google Mock with Any Testing Framework ## ## Using Google Mock with Any Testing Framework ##
If you want to use something other than Google Test (e.g. [CppUnit](http://sourceforge.net/projects/cppunit/) or If you want to use something other than Google Test (e.g. [CppUnit](http://sourceforge.net/projects/cppunit/) or
[CxxTest](http://cxxtest.tigris.org/)) as your testing framework, just change the `main()` function in the previous section to: [CxxTest](https://cxxtest.com/)) as your testing framework, just change the `main()` function in the previous section to:
``` ```
int main(int argc, char** argv) { int main(int argc, char** argv) {
// The following line causes Google Mock to throw an exception on failure, // The following line causes Google Mock to throw an exception on failure,
......
...@@ -528,7 +528,7 @@ interface, which then can be easily mocked. It's a bit of work ...@@ -528,7 +528,7 @@ interface, which then can be easily mocked. It's a bit of work
initially, but usually pays for itself quickly. initially, but usually pays for itself quickly.
This Google Testing Blog This Google Testing Blog
[post](http://googletesting.blogspot.com/2008/06/defeat-static-cling.html) [post](https://testing.googleblog.com/2008/06/defeat-static-cling.html)
says it excellently. Check it out. says it excellently. Check it out.
## My mock object needs to do complex stuff. It's a lot of pain to specify the actions. Google Mock sucks! ## ## My mock object needs to do complex stuff. It's a lot of pain to specify the actions. Google Mock sucks! ##
......
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some commonly used actions. // This file implements some commonly used actions.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
...@@ -35,6 +34,8 @@ ...@@ -35,6 +34,8 @@
// cardinalities can be defined by the user implementing the // cardinalities can be defined by the user implementing the
// CardinalityInterface interface if necessary. // CardinalityInterface interface if necessary.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some commonly used variadic actions. // This file implements some commonly used variadic actions.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
...@@ -213,8 +214,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > { ...@@ -213,8 +214,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
get<2>(args), get<3>(args), get<4>(args), get<5>(args)); get<2>(args), get<3>(args), get<4>(args), get<5>(args));
} }
// There is no InvokeCallback() for 6-tuples, as google3 callbacks // There is no InvokeCallback() for 6-tuples
// support 5 arguments at most.
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
...@@ -238,8 +238,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > { ...@@ -238,8 +238,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
get<6>(args)); get<6>(args));
} }
// There is no InvokeCallback() for 7-tuples, as google3 callbacks // There is no InvokeCallback() for 7-tuples
// support 5 arguments at most.
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
...@@ -264,8 +263,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > { ...@@ -264,8 +263,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
get<6>(args), get<7>(args)); get<6>(args), get<7>(args));
} }
// There is no InvokeCallback() for 8-tuples, as google3 callbacks // There is no InvokeCallback() for 8-tuples
// support 5 arguments at most.
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
...@@ -290,8 +288,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > { ...@@ -290,8 +288,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
get<6>(args), get<7>(args), get<8>(args)); get<6>(args), get<7>(args), get<8>(args));
} }
// There is no InvokeCallback() for 9-tuples, as google3 callbacks // There is no InvokeCallback() for 9-tuples
// support 5 arguments at most.
}; };
template <typename R, typename A1, typename A2, typename A3, typename A4, template <typename R, typename A1, typename A2, typename A3, typename A4,
...@@ -318,8 +315,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, ...@@ -318,8 +315,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
get<6>(args), get<7>(args), get<8>(args), get<9>(args)); get<6>(args), get<7>(args), get<8>(args), get<9>(args));
} }
// There is no InvokeCallback() for 10-tuples, as google3 callbacks // There is no InvokeCallback() for 10-tuples
// support 5 arguments at most.
}; };
// Implements the Invoke(callback) action. // Implements the Invoke(callback) action.
......
...@@ -32,13 +32,14 @@ $$}} This meta comment fixes auto-indentation in editors. ...@@ -32,13 +32,14 @@ $$}} This meta comment fixes auto-indentation in editors.
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some commonly used variadic actions. // This file implements some commonly used variadic actions.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
...@@ -86,8 +87,7 @@ $if i <= max_callback_arity [[ ...@@ -86,8 +87,7 @@ $if i <= max_callback_arity [[
return callback->Run($gets); return callback->Run($gets);
} }
]] $else [[ ]] $else [[
// There is no InvokeCallback() for $i-tuples, as google3 callbacks // There is no InvokeCallback() for $i-tuples
// support $max_callback_arity arguments at most.
]] ]]
}; };
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements function mockers of various arities. // This file implements function mockers of various arities.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
...@@ -352,21 +353,21 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public ...@@ -352,21 +353,21 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
// //
// class MockClass { // class MockClass {
// // Overload 1 // // Overload 1
// MockSpec<string&()> gmock_GetName() { } // MockSpec<string&()> gmock_GetName() { ... }
// // Overload 2. Declared const so that the compiler will generate an // // Overload 2. Declared const so that the compiler will generate an
// // error when trying to resolve between this and overload 4 in // // error when trying to resolve between this and overload 4 in
// // 'gmock_GetName(WithoutMatchers(), nullptr)'. // // 'gmock_GetName(WithoutMatchers(), nullptr)'.
// MockSpec<string&()> gmock_GetName( // MockSpec<string&()> gmock_GetName(
// const WithoutMatchers&, const Function<string&()>*) const { // const WithoutMatchers&, const Function<string&()>*) const {
// // Removes const from this, calls overload 1 // // Removes const from this, calls overload 1
// return AdjustConstness_(this)->gmock_GetName(); // return AdjustConstness_(this)->gmock_GetName();
// } // }
// //
// // Overload 3 // // Overload 3
// const string& gmock_GetName() const { } // const string& gmock_GetName() const { ... }
// // Overload 4 // // Overload 4
// MockSpec<const string&()> gmock_GetName( // MockSpec<const string&()> gmock_GetName(
// const WithoutMatchers&, const Function<const string&()>*) const { // const WithoutMatchers&, const Function<const string&()>*) const {
// // Does not remove const, calls overload 3 // // Does not remove const, calls overload 3
// return AdjustConstness_const(this)->gmock_GetName(); // return AdjustConstness_const(this)->gmock_GetName();
// } // }
......
...@@ -31,13 +31,14 @@ $var n = 10 $$ The maximum arity we support. ...@@ -31,13 +31,14 @@ $var n = 10 $$ The maximum arity we support.
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements function mockers of various arities. // This file implements function mockers of various arities.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
...@@ -114,21 +115,21 @@ class FunctionMocker<R($As)> : public ...@@ -114,21 +115,21 @@ class FunctionMocker<R($As)> : public
// //
// class MockClass { // class MockClass {
// // Overload 1 // // Overload 1
// MockSpec<string&()> gmock_GetName() { } // MockSpec<string&()> gmock_GetName() { ... }
// // Overload 2. Declared const so that the compiler will generate an // // Overload 2. Declared const so that the compiler will generate an
// // error when trying to resolve between this and overload 4 in // // error when trying to resolve between this and overload 4 in
// // 'gmock_GetName(WithoutMatchers(), nullptr)'. // // 'gmock_GetName(WithoutMatchers(), nullptr)'.
// MockSpec<string&()> gmock_GetName( // MockSpec<string&()> gmock_GetName(
// const WithoutMatchers&, const Function<string&()>*) const { // const WithoutMatchers&, const Function<string&()>*) const {
// // Removes const from this, calls overload 1 // // Removes const from this, calls overload 1
// return AdjustConstness_(this)->gmock_GetName(); // return AdjustConstness_(this)->gmock_GetName();
// } // }
// //
// // Overload 3 // // Overload 3
// const string& gmock_GetName() const { } // const string& gmock_GetName() const { ... }
// // Overload 4 // // Overload 4
// MockSpec<const string&()> gmock_GetName( // MockSpec<const string&()> gmock_GetName(
// const WithoutMatchers&, const Function<const string&()>*) const { // const WithoutMatchers&, const Function<const string&()>*) const {
// // Does not remove const, calls overload 3 // // Does not remove const, calls overload 3
// return AdjustConstness_const(this)->gmock_GetName(); // return AdjustConstness_const(this)->gmock_GetName();
// } // }
...@@ -139,7 +140,7 @@ const MockType* AdjustConstness_const(const MockType* mock) { ...@@ -139,7 +140,7 @@ const MockType* AdjustConstness_const(const MockType* mock) {
return mock; return mock;
} }
// Removes const from and returns the given pointer; this is a helper for the // Removes const from and returns the given pointer; this is a helper for the
// expectation setter method for parameterless matchers. // expectation setter method for parameterless matchers.
template <typename MockType> template <typename MockType>
MockType* AdjustConstness_(const MockType* mock) { MockType* AdjustConstness_(const MockType* mock) {
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
// //
// This file implements some commonly used variadic matchers. // This file implements some commonly used variadic matchers.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
......
...@@ -37,6 +37,8 @@ $$ }} This line fixes auto-indentation of the following code in Emacs. ...@@ -37,6 +37,8 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
// //
// This file implements some commonly used variadic matchers. // This file implements some commonly used variadic matchers.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements class templates NiceMock, NaggyMock, and StrictMock. // Implements class templates NiceMock, NaggyMock, and StrictMock.
// //
...@@ -63,6 +62,8 @@ ...@@ -63,6 +62,8 @@
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
// supported. // supported.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
......
...@@ -31,8 +31,7 @@ $var n = 10 $$ The maximum arity we support. ...@@ -31,8 +31,7 @@ $var n = 10 $$ The maximum arity we support.
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements class templates NiceMock, NaggyMock, and StrictMock. // Implements class templates NiceMock, NaggyMock, and StrictMock.
// //
...@@ -64,6 +63,8 @@ $var n = 10 $$ The maximum arity we support. ...@@ -64,6 +63,8 @@ $var n = 10 $$ The maximum arity we support.
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT // In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
// supported. // supported.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
...@@ -35,6 +34,8 @@ ...@@ -35,6 +34,8 @@
// matchers can be defined by the user implementing the // matchers can be defined by the user implementing the
// MatcherInterface<T> interface if necessary. // MatcherInterface<T> interface if necessary.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
...@@ -72,7 +73,7 @@ namespace testing { ...@@ -72,7 +73,7 @@ namespace testing {
// MatchResultListener is an abstract class. Its << operator can be // MatchResultListener is an abstract class. Its << operator can be
// used by a matcher to explain why a value matches or doesn't match. // used by a matcher to explain why a value matches or doesn't match.
// //
// TODO(wan@google.com): add method // FIXME: add method
// bool InterestedInWhy(bool result) const; // bool InterestedInWhy(bool result) const;
// to indicate whether the listener is interested in why the match // to indicate whether the listener is interested in why the match
// result is 'result'. // result is 'result'.
...@@ -921,7 +922,7 @@ class TuplePrefix { ...@@ -921,7 +922,7 @@ class TuplePrefix {
GTEST_REFERENCE_TO_CONST_(Value) value = get<N - 1>(values); GTEST_REFERENCE_TO_CONST_(Value) value = get<N - 1>(values);
StringMatchResultListener listener; StringMatchResultListener listener;
if (!matcher.MatchAndExplain(value, &listener)) { if (!matcher.MatchAndExplain(value, &listener)) {
// TODO(wan): include in the message the name of the parameter // FIXME: include in the message the name of the parameter
// as used in MOCK_METHOD*() when possible. // as used in MOCK_METHOD*() when possible.
*os << " Expected arg #" << N - 1 << ": "; *os << " Expected arg #" << N - 1 << ": ";
get<N - 1>(matchers).DescribeTo(os); get<N - 1>(matchers).DescribeTo(os);
...@@ -2419,7 +2420,7 @@ class WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> { ...@@ -2419,7 +2420,7 @@ class WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> {
template <typename From> template <typename From>
bool MatchAndExplain(From from, MatchResultListener* listener) const { bool MatchAndExplain(From from, MatchResultListener* listener) const {
// TODO(sbenza): Add more detail on failures. ie did the dyn_cast fail? // FIXME: Add more detail on failures. ie did the dyn_cast fail?
To to = dynamic_cast<To>(from); To to = dynamic_cast<To>(from);
return MatchPrintAndExplain(to, this->matcher_, listener); return MatchPrintAndExplain(to, this->matcher_, listener);
} }
...@@ -4529,6 +4530,20 @@ Property(PropertyType (Class::*property)() const &, ...@@ -4529,6 +4530,20 @@ Property(PropertyType (Class::*property)() const &,
property, property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher))); MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
} }
// Three-argument form for reference-qualified member functions.
template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher<internal::PropertyMatcher<
Class, PropertyType, PropertyType (Class::*)() const &> >
Property(const std::string& property_name,
PropertyType (Class::*property)() const &,
const PropertyMatcher& matcher) {
return MakePolymorphicMatcher(
internal::PropertyMatcher<Class, PropertyType,
PropertyType (Class::*)() const &>(
property_name, property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
}
#endif #endif
// Creates a matcher that matches an object iff the result of applying // Creates a matcher that matches an object iff the result of applying
...@@ -5165,13 +5180,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) { ...@@ -5165,13 +5180,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in // Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers. // gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template <typename... Args> template <typename... Args>
internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) { internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
return internal::AllOfMatcher<Args...>(matchers...); const Args&... matchers) {
return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
} }
template <typename... Args> template <typename... Args>
internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) { internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
return internal::AnyOfMatcher<Args...>(matchers...); const Args&... matchers) {
return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
} }
template <typename... Args> template <typename... Args>
......
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some actions that depend on gmock-generated-actions.h. // This file implements some actions that depend on gmock-generated-actions.h.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment