Index: ext/googletest/googlemock/src/gmock.cc =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -r3d5880c6661c3ed500e0c1c739a923ae9ede0364 --- ext/googletest/googlemock/src/gmock.cc (.../gmock.cc) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ext/googletest/googlemock/src/gmock.cc (.../gmock.cc) (revision 3d5880c6661c3ed500e0c1c739a923ae9ede0364) @@ -26,15 +26,14 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) + #include "gmock/gmock.h" #include "gmock/internal/gmock-port.h" namespace testing { -// TODO(wan@google.com): support using environment variables to +// FIXME: support using environment variables to // control the flag values, like what Google Test does. GMOCK_DEFINE_bool_(catch_leaked_mocks, true, @@ -48,6 +47,13 @@ " warning - prints warnings and errors.\n" " error - prints errors only."); +GMOCK_DEFINE_int32_(default_mock_behavior, 1, + "Controls the default behavior of mocks." + " Valid values:\n" + " 0 - by default, mocks act as NiceMocks.\n" + " 1 - by default, mocks act as NaggyMocks.\n" + " 2 - by default, mocks act as StrictMocks."); + namespace internal { // Parses a string as a command line flag. The string should have the @@ -120,6 +126,19 @@ return true; } +static bool ParseGoogleMockIntFlag(const char* str, const char* flag, + int* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Sets *value to the value of the flag. + return ParseInt32(Message() << "The value of flag --" << flag, + value_str, value); +} + // The internal implementation of InitGoogleMock(). // // The type parameter CharType can be instantiated to either char or @@ -138,7 +157,9 @@ // Do we see a Google Mock flag? if (ParseGoogleMockBoolFlag(arg, "catch_leaked_mocks", &GMOCK_FLAG(catch_leaked_mocks)) || - ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose))) { + ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose)) || + ParseGoogleMockIntFlag(arg, "default_mock_behavior", + &GMOCK_FLAG(default_mock_behavior))) { // Yes. Shift the remainder of the argv list left by one. Note // that argv has (*argc + 1) elements, the last one always being // NULL. The following loop moves the trailing NULL element as