Commit b007c54f authored by Abseil Team's avatar Abseil Team Committed by Copybara-Service
Browse files

Running clang-format over all of GoogleTest

A few tests are examining code locations and looking af the resulting line
numbers to verify that GoogleTest shows those to users correctly. Some of those
locations change when clang-format is run. For those locations, I've wrapped
portions in:
// clang-format off
...
// clang-format on

There may be other locations that are currently not tickled by running
clang-format.

PiperOrigin-RevId: 434844712
Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
parent 8a422b83
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -102,7 +103,8 @@ class MockBar { ...@@ -102,7 +103,8 @@ class MockBar {
MockBar(char a1, char a2, std::string a3, std::string a4, int a5, int a6, MockBar(char a1, char a2, std::string a3, std::string a4, int a5, int a6,
const std::string& a7, const std::string& a8, bool a9, bool a10) { const std::string& a7, const std::string& a8, bool a9, bool a10) {
str_ = std::string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) + str_ = std::string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) +
static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') + (a10 ? 'T' : 'F'); static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') +
(a10 ? 'T' : 'F');
} }
virtual ~MockBar() {} virtual ~MockBar() {}
...@@ -118,7 +120,6 @@ class MockBar { ...@@ -118,7 +120,6 @@ class MockBar {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar); GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);
}; };
class MockBaz { class MockBaz {
public: public:
class MoveOnly { class MoveOnly {
...@@ -161,8 +162,7 @@ TEST(RawMockTest, WarningForUninterestingCallAfterDeath) { ...@@ -161,8 +162,7 @@ TEST(RawMockTest, WarningForUninterestingCallAfterDeath) {
MockFoo* const raw_foo = new MockFoo; MockFoo* const raw_foo = new MockFoo;
ON_CALL(*raw_foo, DoThis()) ON_CALL(*raw_foo, DoThis()).WillByDefault(Invoke(raw_foo, &MockFoo::Delete));
.WillByDefault(Invoke(raw_foo, &MockFoo::Delete));
CaptureStdout(); CaptureStdout();
raw_foo->DoThis(); raw_foo->DoThis();
...@@ -280,8 +280,8 @@ TEST(NiceMockTest, NonDefaultConstructor) { ...@@ -280,8 +280,8 @@ TEST(NiceMockTest, NonDefaultConstructor) {
// Tests that NiceMock works with a mock class that has a 10-ary // Tests that NiceMock works with a mock class that has a 10-ary
// non-default constructor. // non-default constructor.
TEST(NiceMockTest, NonDefaultConstructor10) { TEST(NiceMockTest, NonDefaultConstructor10) {
NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f', NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f', "g", "h", true,
"g", "h", true, false); false);
EXPECT_EQ("abcdefghTF", nice_bar.str()); EXPECT_EQ("abcdefghTF", nice_bar.str());
nice_bar.This(); nice_bar.This();
...@@ -390,8 +390,8 @@ TEST(NaggyMockTest, NonDefaultConstructor) { ...@@ -390,8 +390,8 @@ TEST(NaggyMockTest, NonDefaultConstructor) {
// Tests that NaggyMock works with a mock class that has a 10-ary // Tests that NaggyMock works with a mock class that has a 10-ary
// non-default constructor. // non-default constructor.
TEST(NaggyMockTest, NonDefaultConstructor10) { TEST(NaggyMockTest, NonDefaultConstructor10) {
NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5', NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5', "6", "7", true,
"6", "7", true, false); false);
EXPECT_EQ("01234567TF", naggy_bar.str()); EXPECT_EQ("01234567TF", naggy_bar.str());
naggy_bar.This(); naggy_bar.This();
...@@ -490,8 +490,8 @@ TEST(StrictMockTest, NonDefaultConstructor) { ...@@ -490,8 +490,8 @@ TEST(StrictMockTest, NonDefaultConstructor) {
// Tests that StrictMock works with a mock class that has a 10-ary // Tests that StrictMock works with a mock class that has a 10-ary
// non-default constructor. // non-default constructor.
TEST(StrictMockTest, NonDefaultConstructor10) { TEST(StrictMockTest, NonDefaultConstructor10) {
StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f', StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f', "g", "h", true,
"g", "h", true, false); false);
EXPECT_EQ("abcdefghTF", strict_bar.str()); EXPECT_EQ("abcdefghTF", strict_bar.str());
EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true), EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the internal cross-platform support utilities. // This file tests the internal cross-platform support utilities.
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// NOTE: if this file is left without tests for some reason, put a dummy // NOTE: if this file is left without tests for some reason, put a dummy
......
...@@ -30,11 +30,10 @@ ...@@ -30,11 +30,10 @@
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the internal preprocessor macro library. // This file tests the internal preprocessor macro library.
#include "gmock/internal/gmock-pp.h"
#include <string> #include <string>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gmock/internal/gmock-pp.h"
namespace testing { namespace testing {
namespace { namespace {
......
This diff is collapsed.
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Tests Google Mock's functionality that depends on exceptions. // Tests Google Mock's functionality that depends on exceptions.
#include "gmock/gmock.h" #include "gmock/gmock.h"
...@@ -75,6 +74,5 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) { ...@@ -75,6 +74,5 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
} }
} }
} // unnamed namespace } // unnamed namespace
#endif #endif
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This program is for verifying that a leaked mock object can be // This program is for verifying that a leaked mock object can be
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file is for verifying that various Google Mock constructs do not // This file is for verifying that various Google Mock constructs do not
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file is for verifying that various Google Mock constructs do not // This file is for verifying that various Google Mock constructs do not
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests that: // This file tests that:
...@@ -118,7 +117,7 @@ ...@@ -118,7 +117,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#if !GTEST_OS_WINDOWS_MOBILE #if !GTEST_OS_WINDOWS_MOBILE
# include <errno.h> #include <errno.h>
#endif #endif
#include <iostream> #include <iostream>
...@@ -200,14 +199,14 @@ class Interface { ...@@ -200,14 +199,14 @@ class Interface {
virtual char* StringFromString(char* str) = 0; virtual char* StringFromString(char* str) = 0;
virtual int IntFromString(char* str) = 0; virtual int IntFromString(char* str) = 0;
virtual int& IntRefFromString(char* str) = 0; virtual int& IntRefFromString(char* str) = 0;
virtual void VoidFromFunc(void(*func)(char* str)) = 0; virtual void VoidFromFunc(void (*func)(char* str)) = 0;
virtual void VoidFromIntRef(int& n) = 0; // NOLINT virtual void VoidFromIntRef(int& n) = 0; // NOLINT
virtual void VoidFromFloat(float n) = 0; virtual void VoidFromFloat(float n) = 0;
virtual void VoidFromDouble(double n) = 0; virtual void VoidFromDouble(double n) = 0;
virtual void VoidFromVector(const std::vector<int>& v) = 0; virtual void VoidFromVector(const std::vector<int>& v) = 0;
}; };
class Mock: public Interface { class Mock : public Interface {
public: public:
Mock() {} Mock() {}
...@@ -215,7 +214,7 @@ class Mock: public Interface { ...@@ -215,7 +214,7 @@ class Mock: public Interface {
MOCK_METHOD1(StringFromString, char*(char* str)); MOCK_METHOD1(StringFromString, char*(char* str));
MOCK_METHOD1(IntFromString, int(char* str)); MOCK_METHOD1(IntFromString, int(char* str));
MOCK_METHOD1(IntRefFromString, int&(char* str)); MOCK_METHOD1(IntRefFromString, int&(char* str));
MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str))); MOCK_METHOD1(VoidFromFunc, void(void (*func)(char* str)));
MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT
MOCK_METHOD1(VoidFromFloat, void(float n)); MOCK_METHOD1(VoidFromFloat, void(float n));
MOCK_METHOD1(VoidFromDouble, void(double n)); MOCK_METHOD1(VoidFromDouble, void(double n));
...@@ -301,8 +300,8 @@ TEST(LinkTest, TestSetArrayArgument) { ...@@ -301,8 +300,8 @@ TEST(LinkTest, TestSetArrayArgument) {
char ch = 'x'; char ch = 'x';
char ch2 = 'y'; char ch2 = 'y';
EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2, EXPECT_CALL(mock, VoidFromString(_))
&ch2 + 1)); .WillOnce(SetArrayArgument<0>(&ch2, &ch2 + 1));
mock.VoidFromString(&ch); mock.VoidFromString(&ch);
} }
...@@ -339,8 +338,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) { ...@@ -339,8 +338,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
EXPECT_CALL(mock, VoidFromString(_)) EXPECT_CALL(mock, VoidFromString(_))
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid)) .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
.WillOnce(InvokeWithoutArgs(&test_invoke_helper, .WillOnce(
&InvokeHelper::VoidFromVoid)); InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid));
mock.VoidFromString(nullptr); mock.VoidFromString(nullptr);
mock.VoidFromString(nullptr); mock.VoidFromString(nullptr);
} }
...@@ -424,14 +423,14 @@ TEST(LinkTest, TestThrow) { ...@@ -424,14 +423,14 @@ TEST(LinkTest, TestThrow) {
// is expanded and macro expansion cannot contain #pragma. Therefore // is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here. // we suppress them here.
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
#endif #endif
// Tests the linkage of actions created using ACTION macro. // Tests the linkage of actions created using ACTION macro.
namespace { namespace {
ACTION(Return1) { return 1; } ACTION(Return1) { return 1; }
} } // namespace
TEST(LinkTest, TestActionMacro) { TEST(LinkTest, TestActionMacro) {
Mock mock; Mock mock;
...@@ -443,7 +442,7 @@ TEST(LinkTest, TestActionMacro) { ...@@ -443,7 +442,7 @@ TEST(LinkTest, TestActionMacro) {
// Tests the linkage of actions created using ACTION_P macro. // Tests the linkage of actions created using ACTION_P macro.
namespace { namespace {
ACTION_P(ReturnArgument, ret_value) { return ret_value; } ACTION_P(ReturnArgument, ret_value) { return ret_value; }
} } // namespace
TEST(LinkTest, TestActionPMacro) { TEST(LinkTest, TestActionPMacro) {
Mock mock; Mock mock;
...@@ -457,10 +456,10 @@ namespace { ...@@ -457,10 +456,10 @@ namespace {
ACTION_P2(ReturnEqualsEitherOf, first, second) { ACTION_P2(ReturnEqualsEitherOf, first, second) {
return arg0 == first || arg0 == second; return arg0 == first || arg0 == second;
} }
} } // namespace
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
TEST(LinkTest, TestActionP2Macro) { TEST(LinkTest, TestActionP2Macro) {
...@@ -492,8 +491,7 @@ TEST(LinkTest, TestMatchersEq) { ...@@ -492,8 +491,7 @@ TEST(LinkTest, TestMatchersEq) {
const char* p = "x"; const char* p = "x";
ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return()); ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
ON_CALL(mock, VoidFromString(const_cast<char*>("y"))) ON_CALL(mock, VoidFromString(const_cast<char*>("y"))).WillByDefault(Return());
.WillByDefault(Return());
} }
// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers. // Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
...@@ -592,7 +590,7 @@ TEST(LinkTest, TestMatcherElementsAre) { ...@@ -592,7 +590,7 @@ TEST(LinkTest, TestMatcherElementsAre) {
// Tests the linkage of the ElementsAreArray matcher. // Tests the linkage of the ElementsAreArray matcher.
TEST(LinkTest, TestMatcherElementsAreArray) { TEST(LinkTest, TestMatcherElementsAreArray) {
Mock mock; Mock mock;
char arr[] = { 'a', 'b' }; char arr[] = {'a', 'b'};
ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return()); ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
} }
......
...@@ -27,21 +27,20 @@ ...@@ -27,21 +27,20 @@
// (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.
// Tests Google Mock's output in various scenarios. This ensures that // Tests Google Mock's output in various scenarios. This ensures that
// Google Mock's messages are readable and useful. // Google Mock's messages are readable and useful.
#include "gmock/gmock.h"
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Silence C4100 (unreferenced formal parameter) // Silence C4100 (unreferenced formal parameter)
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
#endif #endif
using testing::_; using testing::_;
...@@ -90,9 +89,7 @@ TEST_F(GMockOutputTest, ExpectedCallToVoidFunction) { ...@@ -90,9 +89,7 @@ TEST_F(GMockOutputTest, ExpectedCallToVoidFunction) {
} }
TEST_F(GMockOutputTest, ExplicitActionsRunOut) { TEST_F(GMockOutputTest, ExplicitActionsRunOut) {
EXPECT_CALL(foo_, Bar2(_, _)) EXPECT_CALL(foo_, Bar2(_, _)).Times(2).WillOnce(Return(false));
.Times(2)
.WillOnce(Return(false));
foo_.Bar2(2, 2); foo_.Bar2(2, 2);
foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out. foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out.
} }
...@@ -134,8 +131,7 @@ TEST_F(GMockOutputTest, UninterestingCallToVoidFunction) { ...@@ -134,8 +131,7 @@ TEST_F(GMockOutputTest, UninterestingCallToVoidFunction) {
} }
TEST_F(GMockOutputTest, RetiredExpectation) { TEST_F(GMockOutputTest, RetiredExpectation) {
EXPECT_CALL(foo_, Bar2(_, _)) EXPECT_CALL(foo_, Bar2(_, _)).RetiresOnSaturation();
.RetiresOnSaturation();
EXPECT_CALL(foo_, Bar2(0, 0)); EXPECT_CALL(foo_, Bar2(0, 0));
foo_.Bar2(1, 1); foo_.Bar2(1, 1);
...@@ -160,12 +156,9 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisite) { ...@@ -160,12 +156,9 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisite) {
TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) { TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {
Sequence s1, s2; Sequence s1, s2;
EXPECT_CALL(foo_, Bar(_, 0, _)) EXPECT_CALL(foo_, Bar(_, 0, _)).InSequence(s1);
.InSequence(s1); EXPECT_CALL(foo_, Bar2(0, 0)).InSequence(s2);
EXPECT_CALL(foo_, Bar2(0, 0)) EXPECT_CALL(foo_, Bar2(1, _)).InSequence(s1, s2);
.InSequence(s2);
EXPECT_CALL(foo_, Bar2(1, _))
.InSequence(s1, s2);
foo_.Bar2(1, 0); // Has two immediate unsatisfied pre-requisites foo_.Bar2(1, 0); // Has two immediate unsatisfied pre-requisites
foo_.Bar("Hi", 0, 0); foo_.Bar("Hi", 0, 0);
...@@ -179,8 +172,7 @@ TEST_F(GMockOutputTest, UnsatisfiedWith) { ...@@ -179,8 +172,7 @@ TEST_F(GMockOutputTest, UnsatisfiedWith) {
TEST_F(GMockOutputTest, UnsatisfiedExpectation) { TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
EXPECT_CALL(foo_, Bar(_, _, _)); EXPECT_CALL(foo_, Bar(_, _, _));
EXPECT_CALL(foo_, Bar2(0, _)) EXPECT_CALL(foo_, Bar2(0, _)).Times(2);
.Times(2);
foo_.Bar2(0, 1); foo_.Bar2(0, 1);
} }
...@@ -194,26 +186,22 @@ TEST_F(GMockOutputTest, MismatchArguments) { ...@@ -194,26 +186,22 @@ TEST_F(GMockOutputTest, MismatchArguments) {
} }
TEST_F(GMockOutputTest, MismatchWith) { TEST_F(GMockOutputTest, MismatchWith) {
EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))) EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))).With(Ge());
.With(Ge());
foo_.Bar2(2, 3); // Mismatch With() foo_.Bar2(2, 3); // Mismatch With()
foo_.Bar2(2, 1); foo_.Bar2(2, 1);
} }
TEST_F(GMockOutputTest, MismatchArgumentsAndWith) { TEST_F(GMockOutputTest, MismatchArgumentsAndWith) {
EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))) EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))).With(Ge());
.With(Ge());
foo_.Bar2(1, 3); // Mismatch arguments and mismatch With() foo_.Bar2(1, 3); // Mismatch arguments and mismatch With()
foo_.Bar2(2, 1); foo_.Bar2(2, 1);
} }
TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) { TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) {
ON_CALL(foo_, Bar2(_, _)) ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
.WillByDefault(Return(true)); // Default action #1 ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
ON_CALL(foo_, Bar2(1, _))
.WillByDefault(Return(false)); // Default action #2
EXPECT_CALL(foo_, Bar2(2, 2)); EXPECT_CALL(foo_, Bar2(2, 2));
foo_.Bar2(1, 0); // Unexpected call, takes default action #2. foo_.Bar2(1, 0); // Unexpected call, takes default action #2.
...@@ -222,10 +210,8 @@ TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) { ...@@ -222,10 +210,8 @@ TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) {
} }
TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) { TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) {
ON_CALL(foo_, Bar2(_, _)) ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
.WillByDefault(Return(true)); // Default action #1 ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
ON_CALL(foo_, Bar2(1, _))
.WillByDefault(Return(false)); // Default action #2
EXPECT_CALL(foo_, Bar2(2, 2)); EXPECT_CALL(foo_, Bar2(2, 2));
EXPECT_CALL(foo_, Bar2(1, 1)); EXPECT_CALL(foo_, Bar2(1, 1));
...@@ -237,22 +223,17 @@ TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) { ...@@ -237,22 +223,17 @@ TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) {
} }
TEST_F(GMockOutputTest, UninterestingCallWithDefaultAction) { TEST_F(GMockOutputTest, UninterestingCallWithDefaultAction) {
ON_CALL(foo_, Bar2(_, _)) ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
.WillByDefault(Return(true)); // Default action #1 ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
ON_CALL(foo_, Bar2(1, _))
.WillByDefault(Return(false)); // Default action #2
foo_.Bar2(2, 2); // Uninteresting call, takes default action #1. foo_.Bar2(2, 2); // Uninteresting call, takes default action #1.
foo_.Bar2(1, 1); // Uninteresting call, takes default action #2. foo_.Bar2(1, 1); // Uninteresting call, takes default action #2.
} }
TEST_F(GMockOutputTest, ExplicitActionsRunOutWithDefaultAction) { TEST_F(GMockOutputTest, ExplicitActionsRunOutWithDefaultAction) {
ON_CALL(foo_, Bar2(_, _)) ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
.WillByDefault(Return(true)); // Default action #1
EXPECT_CALL(foo_, Bar2(_, _)) EXPECT_CALL(foo_, Bar2(_, _)).Times(2).WillOnce(Return(false));
.Times(2)
.WillOnce(Return(false));
foo_.Bar2(2, 2); foo_.Bar2(2, 2);
foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out. foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out.
} }
...@@ -293,7 +274,7 @@ void TestCatchesLeakedMocksInAdHocTests() { ...@@ -293,7 +274,7 @@ void TestCatchesLeakedMocksInAdHocTests() {
// foo is deliberately leaked. // foo is deliberately leaked.
} }
int main(int argc, char **argv) { int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv); testing::InitGoogleMock(&argc, argv);
// Ensures that the tests pass no matter what value of // Ensures that the tests pass no matter what value of
// --gmock_catch_leaked_mocks and --gmock_verbose the user specifies. // --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.
...@@ -305,5 +286,5 @@ int main(int argc, char **argv) { ...@@ -305,5 +286,5 @@ int main(int argc, char **argv) {
} }
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Tests that Google Mock constructs can be used in a large number of // Tests that Google Mock constructs can be used in a large number of
// threads concurrently. // threads concurrently.
...@@ -62,21 +61,16 @@ void JoinAndDelete(ThreadWithParam<T>* t) { ...@@ -62,21 +61,16 @@ void JoinAndDelete(ThreadWithParam<T>* t) {
struct Dummy {}; struct Dummy {};
// Tests that different mock objects can be used in their respective // Tests that different mock objects can be used in their respective
// threads. This should generate no Google Test failure. // threads. This should generate no Google Test failure.
void TestConcurrentMockObjects(Dummy /* dummy */) { void TestConcurrentMockObjects(Dummy /* dummy */) {
// Creates a mock and does some typical operations on it. // Creates a mock and does some typical operations on it.
MockFoo foo; MockFoo foo;
ON_CALL(foo, Bar(_)) ON_CALL(foo, Bar(_)).WillByDefault(Return(1));
.WillByDefault(Return(1)); ON_CALL(foo, Baz(_, _)).WillByDefault(Return('b'));
ON_CALL(foo, Baz(_, _)) ON_CALL(foo, Baz(_, "you")).WillByDefault(Return('a'));
.WillByDefault(Return('b'));
ON_CALL(foo, Baz(_, "you")) EXPECT_CALL(foo, Bar(0)).Times(AtMost(3));
.WillByDefault(Return('a'));
EXPECT_CALL(foo, Bar(0))
.Times(AtMost(3));
EXPECT_CALL(foo, Baz(_, _)); EXPECT_CALL(foo, Baz(_, _));
EXPECT_CALL(foo, Baz("hi", "you")) EXPECT_CALL(foo, Baz("hi", "you"))
.WillOnce(Return('z')) .WillOnce(Return('z'))
...@@ -119,22 +113,19 @@ void Helper1(Helper1Param param) { ...@@ -119,22 +113,19 @@ void Helper1(Helper1Param param) {
void TestConcurrentCallsOnSameObject(Dummy /* dummy */) { void TestConcurrentCallsOnSameObject(Dummy /* dummy */) {
MockFoo foo; MockFoo foo;
ON_CALL(foo, Bar(_)) ON_CALL(foo, Bar(_)).WillByDefault(Return(1));
.WillByDefault(Return(1)); EXPECT_CALL(foo, Baz(_, "b")).Times(kRepeat).WillRepeatedly(Return('a'));
EXPECT_CALL(foo, Baz(_, "b"))
.Times(kRepeat)
.WillRepeatedly(Return('a'));
EXPECT_CALL(foo, Baz(_, "c")); // Expected to be unsatisfied. EXPECT_CALL(foo, Baz(_, "c")); // Expected to be unsatisfied.
// This chunk of code should generate kRepeat failures about // This chunk of code should generate kRepeat failures about
// excessive calls, and 2*kRepeat failures about unexpected calls. // excessive calls, and 2*kRepeat failures about unexpected calls.
int count1 = 0; int count1 = 0;
const Helper1Param param = { &foo, &count1 }; const Helper1Param param = {&foo, &count1};
ThreadWithParam<Helper1Param>* const t = ThreadWithParam<Helper1Param>* const t =
new ThreadWithParam<Helper1Param>(Helper1, param, nullptr); new ThreadWithParam<Helper1Param>(Helper1, param, nullptr);
int count2 = 0; int count2 = 0;
const Helper1Param param2 = { &foo, &count2 }; const Helper1Param param2 = {&foo, &count2};
Helper1(param2); Helper1(param2);
JoinAndDelete(t); JoinAndDelete(t);
...@@ -162,22 +153,18 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) { ...@@ -162,22 +153,18 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
{ {
InSequence dummy; InSequence dummy;
EXPECT_CALL(foo, Bar(0)); EXPECT_CALL(foo, Bar(0));
EXPECT_CALL(foo, Bar(1)) EXPECT_CALL(foo, Bar(1)).InSequence(s1, s2);
.InSequence(s1, s2);
} }
EXPECT_CALL(foo, Bar(2)) EXPECT_CALL(foo, Bar(2))
.Times(2*kRepeat) .Times(2 * kRepeat)
.InSequence(s1) .InSequence(s1)
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_CALL(foo, Bar(3)) EXPECT_CALL(foo, Bar(3)).Times(2 * kRepeat).InSequence(s2);
.Times(2*kRepeat)
.InSequence(s2);
{ {
InSequence dummy; InSequence dummy;
EXPECT_CALL(foo, Bar(2)) EXPECT_CALL(foo, Bar(2)).InSequence(s1, s2);
.InSequence(s1, s2);
EXPECT_CALL(foo, Bar(4)); EXPECT_CALL(foo, Bar(4));
} }
...@@ -201,7 +188,7 @@ TEST(StressTest, CanUseGMockWithThreads) { ...@@ -201,7 +188,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
&TestPartiallyOrderedExpectationsWithThreads, &TestPartiallyOrderedExpectationsWithThreads,
}; };
const int kRoutines = sizeof(test_routines)/sizeof(test_routines[0]); const int kRoutines = sizeof(test_routines) / sizeof(test_routines[0]);
const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines; const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;
const int kTestThreads = kCopiesOfEachRoutine * kRoutines; const int kTestThreads = kCopiesOfEachRoutine * kRoutines;
ThreadWithParam<Dummy>* threads[kTestThreads] = {}; ThreadWithParam<Dummy>* threads[kTestThreads] = {};
...@@ -220,7 +207,7 @@ TEST(StressTest, CanUseGMockWithThreads) { ...@@ -220,7 +207,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
// Ensures that the correct number of failures have been reported. // Ensures that the correct number of failures have been reported.
const TestInfo* const info = UnitTest::GetInstance()->current_test_info(); const TestInfo* const info = UnitTest::GetInstance()->current_test_info();
const TestResult& result = *info->result(); const TestResult& result = *info->result();
const int kExpectedFailures = (3*kRepeat + 1)*kCopiesOfEachRoutine; const int kExpectedFailures = (3 * kRepeat + 1) * kCopiesOfEachRoutine;
GTEST_CHECK_(kExpectedFailures == result.total_part_count()) GTEST_CHECK_(kExpectedFailures == result.total_part_count())
<< "Expected " << kExpectedFailures << " failures, but got " << "Expected " << kExpectedFailures << " failures, but got "
<< result.total_part_count(); << result.total_part_count();
...@@ -229,7 +216,7 @@ TEST(StressTest, CanUseGMockWithThreads) { ...@@ -229,7 +216,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
} // namespace } // namespace
} // namespace testing } // namespace testing
int main(int argc, char **argv) { int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv); testing::InitGoogleMock(&argc, argv);
const int exit_code = RUN_ALL_TESTS(); // Expected to fail. const int exit_code = RUN_ALL_TESTS(); // Expected to fail.
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (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.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests code in gmock.cc. // This file tests code in gmock.cc.
...@@ -35,6 +34,7 @@ ...@@ -35,6 +34,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include <string> #include <string>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h" #include "gtest/internal/custom/gtest.h"
......
...@@ -170,23 +170,23 @@ GTEST_API_ bool InDeathTestChild(); ...@@ -170,23 +170,23 @@ GTEST_API_ bool InDeathTestChild();
// Asserts that a given `statement` causes the program to exit, with an // Asserts that a given `statement` causes the program to exit, with an
// integer exit status that satisfies `predicate`, and emitting error output // integer exit status that satisfies `predicate`, and emitting error output
// that matches `matcher`. // that matches `matcher`.
# define ASSERT_EXIT(statement, predicate, matcher) \ #define ASSERT_EXIT(statement, predicate, matcher) \
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_)
// Like `ASSERT_EXIT`, but continues on to successive tests in the // Like `ASSERT_EXIT`, but continues on to successive tests in the
// test suite, if any: // test suite, if any:
# define EXPECT_EXIT(statement, predicate, matcher) \ #define EXPECT_EXIT(statement, predicate, matcher) \
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_)
// Asserts that a given `statement` causes the program to exit, either by // Asserts that a given `statement` causes the program to exit, either by
// explicitly exiting with a nonzero exit code or being killed by a // explicitly exiting with a nonzero exit code or being killed by a
// signal, and emitting error output that matches `matcher`. // signal, and emitting error output that matches `matcher`.
# define ASSERT_DEATH(statement, matcher) \ #define ASSERT_DEATH(statement, matcher) \
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher) ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
// Like `ASSERT_DEATH`, but continues on to successive tests in the // Like `ASSERT_DEATH`, but continues on to successive tests in the
// test suite, if any: // test suite, if any:
# define EXPECT_DEATH(statement, matcher) \ #define EXPECT_DEATH(statement, matcher) \
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher) EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
...@@ -198,21 +198,23 @@ class GTEST_API_ ExitedWithCode { ...@@ -198,21 +198,23 @@ class GTEST_API_ ExitedWithCode {
ExitedWithCode(const ExitedWithCode&) = default; ExitedWithCode(const ExitedWithCode&) = default;
void operator=(const ExitedWithCode& other) = delete; void operator=(const ExitedWithCode& other) = delete;
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
const int exit_code_; const int exit_code_;
}; };
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA #if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
// Tests that an exit code describes an exit due to termination by a // Tests that an exit code describes an exit due to termination by a
// given signal. // given signal.
class GTEST_API_ KilledBySignal { class GTEST_API_ KilledBySignal {
public: public:
explicit KilledBySignal(int signum); explicit KilledBySignal(int signum);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
const int signum_; const int signum_;
}; };
# endif // !GTEST_OS_WINDOWS #endif // !GTEST_OS_WINDOWS
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
// The death testing framework causes this to have interesting semantics, // The death testing framework causes this to have interesting semantics,
...@@ -257,23 +259,21 @@ class GTEST_API_ KilledBySignal { ...@@ -257,23 +259,21 @@ class GTEST_API_ KilledBySignal {
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); // EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
// }, "death"); // }, "death");
// //
# ifdef NDEBUG #ifdef NDEBUG
# define EXPECT_DEBUG_DEATH(statement, regex) \ #define EXPECT_DEBUG_DEATH(statement, regex) \
GTEST_EXECUTE_STATEMENT_(statement, regex) GTEST_EXECUTE_STATEMENT_(statement, regex)
# define ASSERT_DEBUG_DEATH(statement, regex) \ #define ASSERT_DEBUG_DEATH(statement, regex) \
GTEST_EXECUTE_STATEMENT_(statement, regex) GTEST_EXECUTE_STATEMENT_(statement, regex)
# else #else
# define EXPECT_DEBUG_DEATH(statement, regex) \ #define EXPECT_DEBUG_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
EXPECT_DEATH(statement, regex)
# define ASSERT_DEBUG_DEATH(statement, regex) \ #define ASSERT_DEBUG_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
ASSERT_DEATH(statement, regex)
# endif // NDEBUG for EXPECT_DEBUG_DEATH #endif // NDEBUG for EXPECT_DEBUG_DEATH
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
// This macro is used for implementing macros such as // This macro is used for implementing macros such as
...@@ -311,11 +311,10 @@ class GTEST_API_ KilledBySignal { ...@@ -311,11 +311,10 @@ class GTEST_API_ KilledBySignal {
// statement unconditionally returns or throws. The Message constructor at // statement unconditionally returns or throws. The Message constructor at
// the end allows the syntax of streaming additional messages into the // the end allows the syntax of streaming additional messages into the
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. // macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ #define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AlwaysTrue()) { \ if (::testing::internal::AlwaysTrue()) { \
GTEST_LOG_(WARNING) \ GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \
<< "Death tests are not supported on this platform.\n" \
<< "Statement '" #statement "' cannot be verified."; \ << "Statement '" #statement "' cannot be verified."; \
} else if (::testing::internal::AlwaysFalse()) { \ } else if (::testing::internal::AlwaysFalse()) { \
::testing::internal::RE::PartialMatch(".*", (regex)); \ ::testing::internal::RE::PartialMatch(".*", (regex)); \
...@@ -330,14 +329,14 @@ class GTEST_API_ KilledBySignal { ...@@ -330,14 +329,14 @@ class GTEST_API_ KilledBySignal {
// useful when you are combining death test assertions with normal test // useful when you are combining death test assertions with normal test
// assertions in one test. // assertions in one test.
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ #define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
EXPECT_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ #define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
ASSERT_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
#else #else
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ #define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, ) GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ #define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return) GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
#endif #endif
......
This diff is collapsed.
...@@ -111,7 +111,7 @@ class GTEST_API_ Message { ...@@ -111,7 +111,7 @@ class GTEST_API_ Message {
// Streams a non-pointer value to this object. // Streams a non-pointer value to this object.
template <typename T> template <typename T>
inline Message& operator <<(const T& val) { inline Message& operator<<(const T& val) {
// Some libraries overload << for STL containers. These // Some libraries overload << for STL containers. These
// overloads are defined in the global namespace instead of ::std. // overloads are defined in the global namespace instead of ::std.
// //
...@@ -126,7 +126,7 @@ class GTEST_API_ Message { ...@@ -126,7 +126,7 @@ class GTEST_API_ Message {
// from the global namespace. With this using declaration, // from the global namespace. With this using declaration,
// overloads of << defined in the global namespace and those // overloads of << defined in the global namespace and those
// visible via Koenig lookup are both exposed in this function. // visible via Koenig lookup are both exposed in this function.
using ::operator <<; using ::operator<<;
*ss_ << val; *ss_ << val;
return *this; return *this;
} }
...@@ -145,7 +145,7 @@ class GTEST_API_ Message { ...@@ -145,7 +145,7 @@ class GTEST_API_ Message {
// ensure consistent result across compilers, we always treat NULL // ensure consistent result across compilers, we always treat NULL
// as "(null)". // as "(null)".
template <typename T> template <typename T>
inline Message& operator <<(T* const& pointer) { // NOLINT inline Message& operator<<(T* const& pointer) { // NOLINT
if (pointer == nullptr) { if (pointer == nullptr) {
*ss_ << "(null)"; *ss_ << "(null)";
} else { } else {
...@@ -160,25 +160,23 @@ class GTEST_API_ Message { ...@@ -160,25 +160,23 @@ class GTEST_API_ Message {
// templatized version above. Without this definition, streaming // templatized version above. Without this definition, streaming
// endl or other basic IO manipulators to Message will confuse the // endl or other basic IO manipulators to Message will confuse the
// compiler. // compiler.
Message& operator <<(BasicNarrowIoManip val) { Message& operator<<(BasicNarrowIoManip val) {
*ss_ << val; *ss_ << val;
return *this; return *this;
} }
// Instead of 1/0, we want to see true/false for bool values. // Instead of 1/0, we want to see true/false for bool values.
Message& operator <<(bool b) { Message& operator<<(bool b) { return *this << (b ? "true" : "false"); }
return *this << (b ? "true" : "false");
}
// These two overloads allow streaming a wide C string to a Message // These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding. // using the UTF-8 encoding.
Message& operator <<(const wchar_t* wide_c_str); Message& operator<<(const wchar_t* wide_c_str);
Message& operator <<(wchar_t* wide_c_str); Message& operator<<(wchar_t* wide_c_str);
#if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8 // Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object. // encoding, and streams the result to this Message object.
Message& operator <<(const ::std::wstring& wstr); Message& operator<<(const ::std::wstring& wstr);
#endif // GTEST_HAS_STD_WSTRING #endif // GTEST_HAS_STD_WSTRING
// Gets the text streamed to this object so far as an std::string. // Gets the text streamed to this object so far as an std::string.
...@@ -197,7 +195,7 @@ class GTEST_API_ Message { ...@@ -197,7 +195,7 @@ class GTEST_API_ Message {
}; };
// Streams a Message to an ostream. // Streams a Message to an ostream.
inline std::ostream& operator <<(std::ostream& os, const Message& sb) { inline std::ostream& operator<<(std::ostream& os, const Message& sb) {
return os << sb.GetString(); return os << sb.GetString();
} }
......
...@@ -356,9 +356,7 @@ internal::ValueArray<T...> Values(T... v) { ...@@ -356,9 +356,7 @@ internal::ValueArray<T...> Values(T... v) {
// } // }
// INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool()); // INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
// //
inline internal::ParamGenerator<bool> Bool() { inline internal::ParamGenerator<bool> Bool() { return Values(false, true); }
return Values(false, true);
}
// Combine() allows the user to combine two or more sequences to produce // Combine() allows the user to combine two or more sequences to produce
// values of a Cartesian product of those sequences' elements. // values of a Cartesian product of those sequences' elements.
...@@ -490,7 +488,6 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) { ...@@ -490,7 +488,6 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
&gtest_##prefix##test_suite_name##_EvalGenerateName_, \ &gtest_##prefix##test_suite_name##_EvalGenerateName_, \
__FILE__, __LINE__) __FILE__, __LINE__)
// Allow Marking a Parameterized test class as not needing to be instantiated. // Allow Marking a Parameterized test class as not needing to be instantiated.
#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \ #define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \
namespace gtest_do_not_use_outside_namespace_scope {} \ namespace gtest_do_not_use_outside_namespace_scope {} \
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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