From f700442db332033cd874fe453c1006b2a5fcd276 Mon Sep 17 00:00:00 2001 From: Marzo Sette Torres Junior Date: Fri, 2 Sep 2016 14:39:48 -0300 Subject: Clarifying language The old language might mislead someone into thinking that the access level on the base class itself was changed. --- googlemock/docs/CookBook.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index c52f1009..5f5ea44c 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 { -- cgit v1.2.3 From bef93f32c1d23f402b4cd25664fc17a096c5f747 Mon Sep 17 00:00:00 2001 From: bartshappee Date: Mon, 7 Nov 2016 13:33:22 -0500 Subject: Fix small typo SeArrayArgument SeArrayArgument => SetArrayArgument --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 0460d357..5399ea06 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -1680,7 +1680,7 @@ This also works when the argument is an output iterator: ``` using ::testing::_; -using ::testing::SeArrayArgument; +using ::testing::SetArrayArgument; class MockRolodex : public Rolodex { public: -- cgit v1.2.3 From 51d92b2ccb9708c52fee3f2dc81c26f51bf8f19f Mon Sep 17 00:00:00 2001 From: Dawid Kurek Date: Mon, 6 Feb 2017 13:31:11 +0100 Subject: Replace html entities with their equivalents --- googlemock/docs/CookBook.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 0460d357..89a41508 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -2365,7 +2365,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<Buzz>(AccessLevel::kInternal), + mock_buzzer_.ShareBuzz(MakeUnique(AccessLevel::kInternal), ::base::Now()); ``` @@ -2404,7 +2404,7 @@ Now, the mock `DoShareBuzz()` method is free to save the buzz argument for later ``` std::unique_ptr intercepted_buzz; EXPECT_CALL(mock_buzzer_, DoShareBuzz(NotNull(), _)) - .WillOnce(Invoke([&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; -- cgit v1.2.3 From f20797bd8dd1c5ea3ae95218abdf3807be497993 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 1 Jul 2017 15:27:07 -0400 Subject: Same fixes for "current" version. --- googlemock/docs/CookBook.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 0460d357..5c1e5b8e 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -1029,9 +1029,10 @@ a value that satisfies matcher `m`. For example: -> | `Field(&Foo::number, Ge(3))` | Matches `x` where `x.number >= 3`. | +| Expression | Description | |:-----------------------------|:-----------------------------------| -> | `Property(&Foo::name, StartsWith("John "))` | Matches `x` where `x.name()` starts with `"John "`. | +| `Field(&Foo::number, Ge(3))` | Matches `x` where `x.number >= 3`. | +| `Property(&Foo::name, StartsWith("John "))` | Matches `x` where `x.name()` starts with `"John "`. | Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument and be declared as `const`. @@ -2482,12 +2483,12 @@ MockFoo::~MockFoo() {} ## Forcing a Verification ## -When it's being destoyed, your friendly mock object will automatically +When it's being destroyed, your friendly mock object will automatically verify that all expectations on it have been satisfied, and will generate [Google Test](../../googletest/) failures if not. This is convenient as it leaves you with one less thing to worry about. That is, unless you are not sure if your mock object will -be destoyed. +be destroyed. How could it be that your mock object won't eventually be destroyed? Well, it might be created on the heap and owned by the code you are -- cgit v1.2.3 From 2fcbc0c1ab4877f2a149fe2b4760fd2bf182d0b1 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 1 Jul 2017 15:30:55 -0400 Subject: Remove silly claim that C++ lacks lambdas. The document itself uses lambdas later, all the scaffolding to work around lack of lambdas should be considered for removal, but that is much larger an effort than I can commit to. --- googlemock/docs/CookBook.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 5c1e5b8e..4f8e944c 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -1920,9 +1920,9 @@ using ::testing::_; // second argument DoThis() receives. ``` -Arghh, you need to refer to a mock function argument but C++ has no -lambda (yet), so you have to define your own action. :-( Or do you -really? +Arghh, you need to refer to a mock function argument but your version +of C++ has no lambdas, so you have to define your own action. :-( +Or do you really? Well, Google Mock has an action to solve _exactly_ this problem: -- cgit v1.2.3 From 0ffd8629c9ee58ee84ec38768a5cc45faebfa297 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sat, 1 Jul 2017 22:34:51 -0400 Subject: More tables that did not render correctly. --- googlemock/docs/CookBook.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 4f8e944c..90071bc0 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -3348,6 +3348,7 @@ For example, when using an `ACTION` as a stub action for mock function: int DoSomething(bool flag, int* ptr); ``` we have: + | **Pre-defined Symbol** | **Is Bound To** | |:-----------------------|:----------------| | `arg0` | the value of `flag` | @@ -3509,6 +3510,7 @@ is asked to infer the type of `x`? If you are writing a function that returns an `ACTION` object, you'll need to know its type. The type depends on the macro used to define the action and the parameter types. The rule is relatively simple: + | **Given Definition** | **Expression** | **Has Type** | |:---------------------|:---------------|:-------------| | `ACTION(Foo)` | `Foo()` | `FooAction` | @@ -3516,7 +3518,7 @@ the action and the parameter types. The rule is relatively simple: | `ACTION_P(Bar, param)` | `Bar(int_value)` | `BarActionP` | | `ACTION_TEMPLATE(Bar, HAS_m_TEMPLATE_PARAMS(...), AND_1_VALUE_PARAMS(p1))` | `Bar(int_value)` | `FooActionP` | | `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value, int_value)` | `BazActionP2` | -| `ACTION_TEMPLATE(Baz, HAS_m_TEMPLATE_PARAMS(...), AND_2_VALUE_PARAMS(p1, p2))` | `Baz(bool_value, int_value)` | `FooActionP2` | +| `ACTION_TEMPLATE(Baz, HAS_m_TEMPLATE_PARAMS(...), AND_2_VALUE_PARAMS(p1, p2))`| `Baz(bool_value, int_value)` | `FooActionP2` | | ... | ... | ... | Note that we have to pick different suffixes (`Action`, `ActionP`, -- cgit v1.2.3 From ec19d455bc1224fc2ca8c43d4a0e3d528a7e2a26 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Sun, 30 Jul 2017 17:05:48 +0200 Subject: fix links to Google C++ Style Guide --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 90071bc0..34387c0e 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -294,7 +294,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` and `StrictMock` 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 >`) 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. -- cgit v1.2.3 From 29c07aa9dbeb622a6f8f0d1d07c9f139e18b5dca Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:19:45 +0200 Subject: remove Yob's comma mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 6ea7f3a9..fa2d2fd0 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -148,7 +148,7 @@ Note that the mock class doesn't define `AppendPacket()`, unlike the real class. That's fine as long as the test doesn't need to call it. Next, you need a way to say that you want to use -`ConcretePacketStream` in production code, and use `MockPacketStream` +`ConcretePacketStream` in production code and to use `MockPacketStream` in tests. Since the functions are not virtual and the two classes are unrelated, you must specify your choice at _compile time_ (as opposed to run time). -- cgit v1.2.3 From bb8399e1baf9d984894a54ba1e6e9e4d20c11a35 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:20:46 +0200 Subject: use plural verb as mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index fa2d2fd0..753c6dd3 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -706,7 +706,7 @@ type `m` accepts): 1. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and 1. When `U` is a reference, `T` must also be a reference (as the underlying matcher may be interested in the address of the `U` value). -The code won't compile if any of these conditions isn't met. +The code won't compile if any of these conditions aren't met. Here's one example: -- cgit v1.2.3 From b70cf1a663ad30f77ab9867095a87d3d5429450d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 27 Sep 2017 13:31:13 +0100 Subject: Use gender-neutral pronouns in comments and docs --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/docs/CookBook.md') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 753c6dd3..3d07e68b 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock will print a warning about the "uninteresting call". The rationale is: * New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called. - * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, he can add an `EXPECT_CALL()` to suppress the warning. + * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, they can add an `EXPECT_CALL()` to suppress the warning. However, sometimes you may want to suppress all "uninteresting call" warnings, while sometimes you may want the opposite, i.e. to treat all -- cgit v1.2.3