aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorHerbert Thielen <thielen@hs-worms.de>2017-08-09 11:03:27 +0200
committerHerbert Thielen <thielen@hs-worms.de>2017-08-09 11:03:27 +0200
commite022dcded846c36c14dcbf97d49de9ca68ddd6fc (patch)
tree8e65719ddf45c8f99b2ceae1a8dc24c84d7f2a90 /googlemock
parent6b896774815127c11de3aa4400454e88b9763020 (diff)
parent461713fec4603806d2049835c0790bf94d2db631 (diff)
downloadgoogletest-e022dcded846c36c14dcbf97d49de9ca68ddd6fc.tar.gz
googletest-e022dcded846c36c14dcbf97d49de9ca68ddd6fc.tar.bz2
googletest-e022dcded846c36c14dcbf97d49de9ca68ddd6fc.zip
Merge branch 'master' into hethi/remove-old-docs
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/CHANGES2
-rw-r--r--googlemock/README.md39
-rw-r--r--googlemock/configure.ac2
-rw-r--r--googlemock/docs/CookBook.md11
-rw-r--r--googlemock/docs/DevGuide.md2
-rw-r--r--googlemock/include/gmock/gmock-actions.h8
-rw-r--r--googlemock/include/gmock/gmock-matchers.h2
-rw-r--r--googlemock/src/gmock-matchers.cc2
-rw-r--r--googlemock/test/gmock-generated-actions_test.cc2
9 files changed, 52 insertions, 18 deletions
diff --git a/googlemock/CHANGES b/googlemock/CHANGES
index d6f2f760..4328ece3 100644
--- a/googlemock/CHANGES
+++ b/googlemock/CHANGES
@@ -94,7 +94,7 @@ Google Test):
* 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 for specifying inter-argument
+ * New feature: the .With() clause for specifying inter-argument
constraints.
* New feature: actions ReturnArg<k>(), ReturnNew<T>(...), and
DeleteArg<k>().
diff --git a/googlemock/README.md b/googlemock/README.md
index 7b13a6d3..7efc0685 100644
--- a/googlemock/README.md
+++ b/googlemock/README.md
@@ -125,13 +125,46 @@ build Google Mock and its tests, which has further requirements:
### Building Google Mock ###
+#### Using CMake ####
+
If you have CMake available, it is recommended that you follow the
[build instructions][gtest_cmakebuild]
-as described for Google Test. If are using Google Mock with an
+as described for Google Test.
+
+If are using Google Mock with an
existing CMake project, the section
[Incorporating Into An Existing CMake Project][gtest_incorpcmake]
-may be of particular interest. Otherwise, the following sections
-detail how to build Google Mock without CMake.
+may be of particular interest.
+To make it work for Google Mock you will need to change
+
+ target_link_libraries(example gtest_main)
+
+to
+
+ target_link_libraries(example gmock_main)
+
+This works because `gmock_main` library is compiled with Google Test.
+However, it does not automatically add Google Test includes.
+Therefore you will also have to change
+
+ if (CMAKE_VERSION VERSION_LESS 2.8.11)
+ include_directories("${gtest_SOURCE_DIR}/include")
+ endif()
+
+to
+
+ if (CMAKE_VERSION VERSION_LESS 2.8.11)
+ include_directories(BEFORE SYSTEM
+ "${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
+ else()
+ target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
+ "${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
+ endif()
+
+This will addtionally mark Google Mock includes as system, which will
+silence compiler warnings when compiling your tests using clang with
+`-Wpedantic -Wall -Wextra -Wconversion`.
+
#### Preparing to Build (Unix only) ####
diff --git a/googlemock/configure.ac b/googlemock/configure.ac
index 3b740f20..edfd8963 100644
--- a/googlemock/configure.ac
+++ b/googlemock/configure.ac
@@ -130,7 +130,7 @@ AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
GTEST_LIBS=`${GTEST_CONFIG} --libs`
GTEST_VERSION=`${GTEST_CONFIG} --version`],
[AC_CONFIG_SUBDIRS([../googletest])
- # GTEST_CONFIG needs to be executable both in a Makefile environmont and
+ # GTEST_CONFIG needs to be executable both in a Makefile environment and
# in a shell script environment, so resolve an absolute path for it here.
GTEST_CONFIG="`pwd -P`/../googletest/scripts/gtest-config"
GTEST_CPPFLAGS='-I$(top_srcdir)/../googletest/include'
diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md
index 90071bc0..3d2ae4a7 100644
--- a/googlemock/docs/CookBook.md
+++ b/googlemock/docs/CookBook.md
@@ -18,8 +18,9 @@ You must always put a mock method definition (`MOCK_METHOD*`) in a
`public:` section of the mock class, regardless of the method being
mocked being `public`, `protected`, or `private` in the base class.
This allows `ON_CALL` and `EXPECT_CALL` to reference the mock function
-from outside of the mock class. (Yes, C++ allows a subclass to change
-the access level of a virtual function in the base class.) Example:
+from outside of the mock class. (Yes, C++ allows a subclass to specify
+a different access level than the base class on a virtual function.)
+Example:
```
class Foo {
@@ -294,7 +295,7 @@ There are some caveats though (I don't like them just as much as the
next guy, but sadly they are side effects of C++'s limitations):
1. `NiceMock<MockFoo>` and `StrictMock<MockFoo>` only work for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In particular, nesting `NiceMock` and `StrictMock` (e.g. `NiceMock<StrictMock<MockFoo> >`) is **not** supported.
- 1. The constructors of the base mock (`MockFoo`) cannot have arguments passed by non-const reference, which happens to be banned by the [Google C++ style guide](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml).
+ 1. The constructors of the base mock (`MockFoo`) cannot have arguments passed by non-const reference, which happens to be banned by the [Google C++ style guide](https://google.github.io/styleguide/cppguide.html).
1. During the constructor or destructor of `MockFoo`, the mock object is _not_ nice or strict. This may cause surprises if the constructor or destructor calls a mock method on `this` object. (This behavior, however, is consistent with C++'s general rule: if a constructor or destructor calls a virtual method of `this` object, that method is treated as non-virtual. In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class. This rule is required for safety. Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
Finally, you should be **very cautious** about when to use naggy or strict mocks, as they tend to make tests more brittle and harder to maintain. When you refactor your code without changing its externally visible behavior, ideally you should't need to update any tests. If your code interacts with a naggy mock, however, you may start to get spammed with warnings as the result of your change. Worse, if your code interacts with a strict mock, your tests may start to fail and you'll be forced to fix them. Our general recommendation is to use nice mocks (not yet the default) most of the time, use naggy mocks (the current default) when developing or debugging tests, and use strict mocks only as the last resort.
@@ -2366,7 +2367,7 @@ Now there’s one topic we haven’t covered: how do you set expectations on `Sh
// When one calls ShareBuzz() on the MockBuzzer like this, the call is
// forwarded to DoShareBuzz(), which is mocked. Therefore this statement
// will trigger the above EXPECT_CALL.
- mock_buzzer_.ShareBuzz(MakeUnique&lt;Buzz&gt;(AccessLevel::kInternal),
+ mock_buzzer_.ShareBuzz(MakeUnique<Buzz>(AccessLevel::kInternal),
::base::Now());
```
@@ -2405,7 +2406,7 @@ Now, the mock `DoShareBuzz()` method is free to save the buzz argument for later
```
std::unique_ptr<Buzz> intercepted_buzz;
EXPECT_CALL(mock_buzzer_, DoShareBuzz(NotNull(), _))
- .WillOnce(Invoke([&amp;intercepted_buzz](Buzz* buzz, Time timestamp) {
+ .WillOnce(Invoke([&intercepted_buzz](Buzz* buzz, Time timestamp) {
// Save buzz in intercepted_buzz for analysis later.
intercepted_buzz.reset(buzz);
return false;
diff --git a/googlemock/docs/DevGuide.md b/googlemock/docs/DevGuide.md
index f4bab75c..adb74fe1 100644
--- a/googlemock/docs/DevGuide.md
+++ b/googlemock/docs/DevGuide.md
@@ -91,7 +91,7 @@ instructions for how to sign and return it.
To keep the source consistent, readable, diffable and easy to merge,
we use a fairly rigid coding style, as defined by the [google-styleguide](https://github.com/google/styleguide) project. All patches will be expected
-to conform to the style outlined [here](https://github.com/google/styleguide/blob/gh-pages/cppguide.xml).
+to conform to the style outlined [here](https://google.github.io/styleguide/cppguide.html).
## Submitting Patches ##
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index b3f654af..845c8232 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -1029,9 +1029,9 @@ class DoBothAction {
// return sqrt(x*x + y*y);
// }
// ...
-// EXEPCT_CALL(mock, Foo("abc", _, _))
+// EXPECT_CALL(mock, Foo("abc", _, _))
// .WillOnce(Invoke(DistanceToOriginWithLabel));
-// EXEPCT_CALL(mock, Bar(5, _, _))
+// EXPECT_CALL(mock, Bar(5, _, _))
// .WillOnce(Invoke(DistanceToOriginWithIndex));
//
// you could write
@@ -1041,8 +1041,8 @@ class DoBothAction {
// return sqrt(x*x + y*y);
// }
// ...
-// EXEPCT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin));
-// EXEPCT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));
+// EXPECT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin));
+// EXPECT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));
typedef internal::IgnoredValue Unused;
// This constructor allows us to turn an Action<From> object into an
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 9ade5b64..3a97c438 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -646,7 +646,7 @@ class SafeMatcherCastImpl {
// type U.
GTEST_COMPILE_ASSERT_(
internal::is_reference<T>::value || !internal::is_reference<U>::value,
- cannot_convert_non_referentce_arg_to_reference);
+ cannot_convert_non_reference_arg_to_reference);
// In case both T and U are arithmetic types, enforce that the
// conversion is not lossy.
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc
index e0de25cb..6e40e5e8 100644
--- a/googlemock/src/gmock-matchers.cc
+++ b/googlemock/src/gmock-matchers.cc
@@ -288,7 +288,7 @@ class MaxBipartiteMatchState {
// Each element of the left_ vector represents a left hand side node
// (i.e. an element) and each element of right_ is a right hand side
// node (i.e. a matcher). The values in the left_ vector indicate
- // outflow from that node to a node on the the right_ side. The values
+ // outflow from that node to a node on the right_ side. The values
// in the right_ indicate inflow, and specify which left_ node is
// feeding that right_ node, if any. For example, left_[3] == 1 means
// there's a flow from element #3 to matcher #1. Such a flow would also
diff --git a/googlemock/test/gmock-generated-actions_test.cc b/googlemock/test/gmock-generated-actions_test.cc
index 58d45728..80bcb31c 100644
--- a/googlemock/test/gmock-generated-actions_test.cc
+++ b/googlemock/test/gmock-generated-actions_test.cc
@@ -1120,7 +1120,7 @@ TEST(ActionTemplateTest, WorksForIntegralTemplateParams) {
EXPECT_FALSE(b); // Verifies that resetter is deleted.
}
-// Tests that ACTION_TEMPLATES works for template template parameters.
+// Tests that ACTION_TEMPLATE works for a template with template parameters.
ACTION_TEMPLATE(ReturnSmartPointer,
HAS_1_TEMPLATE_PARAMS(template <typename Pointee> class,
Pointer),