mirror of
https://github.com/google/googletest.git
synced 2025-01-14 08:27:56 +08:00
d72813110c
PiperOrigin-RevId: 349349288
2.6 KiB
2.6 KiB
googletest gMock Users Guide
go/gmockguide
Welcome to googletest: Google's C++ testing and mocking framework. gMock is a mocking part of googletest.
-
If you are new to gMock, start with gMock for Dummies to learn the basic usage.
-
Read gMock Cookbook to learn more advanced usage and useful tips.
-
For a quick reference, check out gMock Cheat Sheet.
-
If you have questions, search gMock FAQ and the gmock-users@ archive before sending them to gmock-users@.
Side Effects
Matcher | Description |
---|---|
Assign(&variable, value) |
Assign value to variable. |
DeleteArg<N>() |
Delete the N -th (0-based) argument, which must be a pointer. |
SaveArg<N>(pointer) |
Save the N -th (0-based) argument to *pointer . |
SaveArgPointee<N>(pointer) |
Save the value pointed to by the N -th (0-based) argument to *pointer . |
SetArgReferee<N>(value) |
Assign value to the variable referenced by the N -th (0-based) argument. |
SetArgPointee<N>(value) |
Assign value to the variable pointed by the N -th (0-based) argument. |
SetArgumentPointee<N>(value) |
Same as SetArgPointee<N>(value) . Deprecated. Will be removed in v1.7.0. |
SetArrayArgument<N>(first, last) |
Copies the elements in source range [first , last ) to the array pointed to by the N -th (0-based) argument, which can be either a pointer or an iterator. The action does not take ownership of the elements in the source range. |
SetErrnoAndReturn(error, value) |
Set errno to error and return value . |
Throw(exception) |
Throws the given exception, which can be any copyable value. Available since v1.1.0. |
- When compiling with exceptions in google3, it's not enough to specify
-fexceptions
to copts in your cc_test target. That flag will not be inherited by gmock, and various headers will be compiled both with and without-fexceptions
causing subtle bugs. Instead you must pass--copt=-fexceptions
to the blaze command so the flag gets passed to all targets... but this is Google and we don't use exceptions so it shouldn't really be an issue.