Unverified Commit 76bce79a authored by Andy Soffer's avatar Andy Soffer Committed by GitHub
Browse files

Merge branch 'main' into fixes_std_pair_diff

parents 6f1c4b3d f345b2ca
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_OS_ESP8266 || GTEST_OS_ESP32 #if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32)
#if GTEST_OS_ESP8266 #ifdef GTEST_OS_ESP8266
extern "C" { extern "C" {
#endif #endif
void setup() { void setup() {
...@@ -43,7 +43,7 @@ void setup() { ...@@ -43,7 +43,7 @@ void setup() {
testing::InitGoogleMock(); testing::InitGoogleMock();
} }
void loop() { RUN_ALL_TESTS(); } void loop() { RUN_ALL_TESTS(); }
#if GTEST_OS_ESP8266 #ifdef GTEST_OS_ESP8266
} }
#endif #endif
...@@ -55,7 +55,7 @@ void loop() { RUN_ALL_TESTS(); } ...@@ -55,7 +55,7 @@ void loop() { RUN_ALL_TESTS(); }
// Windows. See the following link to track the current status of this bug: // Windows. See the following link to track the current status of this bug:
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library // https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// // NOLINT // // NOLINT
#if GTEST_OS_WINDOWS_MOBILE #ifdef GTEST_OS_WINDOWS_MOBILE
#include <tchar.h> // NOLINT #include <tchar.h> // NOLINT
GTEST_API_ int _tmain(int argc, TCHAR** argv) { GTEST_API_ int _tmain(int argc, TCHAR** argv) {
......
...@@ -37,14 +37,18 @@ ...@@ -37,14 +37,18 @@
#include <functional> #include <functional>
#include <iterator> #include <iterator>
#include <memory> #include <memory>
#include <sstream>
#include <string> #include <string>
#include <tuple>
#include <type_traits> #include <type_traits>
#include <utility>
#include <vector> #include <vector>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
// Silence C4100 (unreferenced formal parameter) and C4503 (decorated name // Silence C4100 (unreferenced formal parameter) and C4503 (decorated name
// length exceeded) for MSVC. // length exceeded) for MSVC.
...@@ -218,7 +222,8 @@ TEST(TypeTraits, IsInvocableRV) { ...@@ -218,7 +222,8 @@ TEST(TypeTraits, IsInvocableRV) {
// In C++17 and above, where it's guaranteed that functions can return // In C++17 and above, where it's guaranteed that functions can return
// non-moveable objects, everything should work fine for non-moveable rsult // non-moveable objects, everything should work fine for non-moveable rsult
// types too. // types too.
#if defined(__cplusplus) && __cplusplus >= 201703L #if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
{ {
struct NonMoveable { struct NonMoveable {
NonMoveable() = default; NonMoveable() = default;
...@@ -444,7 +449,7 @@ TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) { ...@@ -444,7 +449,7 @@ TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) {
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr);
DefaultValue<std::unique_ptr<int>>::SetFactory( DefaultValue<std::unique_ptr<int>>::SetFactory(
[] { return std::unique_ptr<int>(new int(42)); }); [] { return std::make_unique<int>(42); });
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get(); std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get();
EXPECT_EQ(42, *i); EXPECT_EQ(42, *i);
...@@ -982,7 +987,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) { ...@@ -982,7 +987,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) {
class MockClass { class MockClass {
public: public:
MockClass() {} MockClass() = default;
MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT
MOCK_METHOD0(Foo, MyNonDefaultConstructible()); MOCK_METHOD0(Foo, MyNonDefaultConstructible());
...@@ -1592,7 +1597,7 @@ TEST(WithArgsTest, RefQualifiedInnerAction) { ...@@ -1592,7 +1597,7 @@ TEST(WithArgsTest, RefQualifiedInnerAction) {
EXPECT_EQ(19, mock.AsStdFunction()(0, 17)); EXPECT_EQ(19, mock.AsStdFunction()(0, 17));
} }
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
class SetErrnoAndReturnTest : public testing::Test { class SetErrnoAndReturnTest : public testing::Test {
protected: protected:
...@@ -1751,9 +1756,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) { ...@@ -1751,9 +1756,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) {
delete c; delete c;
} }
std::unique_ptr<int> UniquePtrSource() { std::unique_ptr<int> UniquePtrSource() { return std::make_unique<int>(19); }
return std::unique_ptr<int>(new int(19));
}
std::vector<std::unique_ptr<int>> VectorUniquePtrSource() { std::vector<std::unique_ptr<int>> VectorUniquePtrSource() {
std::vector<std::unique_ptr<int>> out; std::vector<std::unique_ptr<int>> out;
...@@ -1802,7 +1805,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { ...@@ -1802,7 +1805,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
// Check default value // Check default value
DefaultValue<std::unique_ptr<int>>::SetFactory( DefaultValue<std::unique_ptr<int>>::SetFactory(
[] { return std::unique_ptr<int>(new int(42)); }); [] { return std::make_unique<int>(42); });
EXPECT_EQ(42, *mock.MakeUnique()); EXPECT_EQ(42, *mock.MakeUnique());
EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource)); EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource));
...@@ -1822,7 +1825,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { ...@@ -1822,7 +1825,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
TEST(MockMethodTest, CanTakeMoveOnlyValue) { TEST(MockMethodTest, CanTakeMoveOnlyValue) {
MockClass mock; MockClass mock;
auto make = [](int i) { return std::unique_ptr<int>(new int(i)); }; auto make = [](int i) { return std::make_unique<int>(i); };
EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr<int> i) { EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr<int> i) {
return *i; return *i;
...@@ -2053,9 +2056,7 @@ struct Double { ...@@ -2053,9 +2056,7 @@ struct Double {
} }
}; };
std::unique_ptr<int> UniqueInt(int i) { std::unique_ptr<int> UniqueInt(int i) { return std::make_unique<int>(i); }
return std::unique_ptr<int>(new int(i));
}
TEST(FunctorActionTest, ActionFromFunction) { TEST(FunctorActionTest, ActionFromFunction) {
Action<int(int, int&, int*)> a = &Add; Action<int(int, int&, int*)> a = &Add;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
// //
// This file tests the built-in cardinalities. // This file tests the built-in cardinalities.
#include <ostream>
#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"
...@@ -50,7 +52,7 @@ using testing::MakeCardinality; ...@@ -50,7 +52,7 @@ using testing::MakeCardinality;
class MockFoo { class MockFoo {
public: public:
MockFoo() {} MockFoo() = default;
MOCK_METHOD0(Bar, int()); // NOLINT MOCK_METHOD0(Bar, int()); // NOLINT
private: private:
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
// Silence C4503 (decorated name length exceeded) for MSVC. // Silence C4503 (decorated name length exceeded) for MSVC.
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4503) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4503)
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but // MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
// we are getting compiler errors if we use basetyps.h, hence including // we are getting compiler errors if we use basetyps.h, hence including
// objbase.h for definition of STDMETHOD. // objbase.h for definition of STDMETHOD.
...@@ -70,7 +70,7 @@ using testing::TypedEq; ...@@ -70,7 +70,7 @@ using testing::TypedEq;
template <typename T> template <typename T>
class TemplatedCopyable { class TemplatedCopyable {
public: public:
TemplatedCopyable() {} TemplatedCopyable() = default;
template <typename U> template <typename U>
TemplatedCopyable(const U& other) {} // NOLINT TemplatedCopyable(const U& other) {} // NOLINT
...@@ -78,7 +78,7 @@ class TemplatedCopyable { ...@@ -78,7 +78,7 @@ class TemplatedCopyable {
class FooInterface { class FooInterface {
public: public:
virtual ~FooInterface() {} virtual ~FooInterface() = default;
virtual void VoidReturning(int x) = 0; virtual void VoidReturning(int x) = 0;
...@@ -120,7 +120,7 @@ class FooInterface { ...@@ -120,7 +120,7 @@ class FooInterface {
virtual int RefQualifiedOverloaded() & = 0; virtual int RefQualifiedOverloaded() & = 0;
virtual int RefQualifiedOverloaded() && = 0; virtual int RefQualifiedOverloaded() && = 0;
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
STDMETHOD_(int, CTNullary)() = 0; STDMETHOD_(int, CTNullary)() = 0;
STDMETHOD_(bool, CTUnary)(int x) = 0; STDMETHOD_(bool, CTUnary)(int x) = 0;
STDMETHOD_(int, CTDecimal) STDMETHOD_(int, CTDecimal)
...@@ -137,7 +137,7 @@ class FooInterface { ...@@ -137,7 +137,7 @@ class FooInterface {
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373)
class MockFoo : public FooInterface { class MockFoo : public FooInterface {
public: public:
MockFoo() {} MockFoo() = default;
// Makes sure that a mock function parameter can be named. // Makes sure that a mock function parameter can be named.
MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT
...@@ -178,7 +178,7 @@ class MockFoo : public FooInterface { ...@@ -178,7 +178,7 @@ class MockFoo : public FooInterface {
MOCK_METHOD(int (*)(bool), ReturnsFunctionPointer1, (int), ()); MOCK_METHOD(int (*)(bool), ReturnsFunctionPointer1, (int), ());
MOCK_METHOD(fn_ptr, ReturnsFunctionPointer2, (int), ()); MOCK_METHOD(fn_ptr, ReturnsFunctionPointer2, (int), ());
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE))); MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE)));
MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE))); MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE)));
MOCK_METHOD(int, CTDecimal, MOCK_METHOD(int, CTDecimal,
...@@ -208,7 +208,7 @@ class MockFoo : public FooInterface { ...@@ -208,7 +208,7 @@ class MockFoo : public FooInterface {
class LegacyMockFoo : public FooInterface { class LegacyMockFoo : public FooInterface {
public: public:
LegacyMockFoo() {} LegacyMockFoo() = default;
// Makes sure that a mock function parameter can be named. // Makes sure that a mock function parameter can be named.
MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
...@@ -248,7 +248,7 @@ class LegacyMockFoo : public FooInterface { ...@@ -248,7 +248,7 @@ class LegacyMockFoo : public FooInterface {
MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool)); MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool));
MOCK_METHOD1(ReturnsFunctionPointer2, fn_ptr(int)); MOCK_METHOD1(ReturnsFunctionPointer2, fn_ptr(int));
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int()); MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT
MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal, MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal,
...@@ -404,7 +404,7 @@ TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) { ...@@ -404,7 +404,7 @@ TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>())); EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
} }
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
// Tests mocking a nullary function with calltype. // Tests mocking a nullary function with calltype.
TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) { TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
EXPECT_CALL(this->mock_foo_, CTNullary()) EXPECT_CALL(this->mock_foo_, CTNullary())
...@@ -487,7 +487,7 @@ TEST(FunctionMockerTest, RefQualified) { ...@@ -487,7 +487,7 @@ TEST(FunctionMockerTest, RefQualified) {
class MockB { class MockB {
public: public:
MockB() {} MockB() = default;
MOCK_METHOD(void, DoB, ()); MOCK_METHOD(void, DoB, ());
...@@ -498,7 +498,7 @@ class MockB { ...@@ -498,7 +498,7 @@ class MockB {
class LegacyMockB { class LegacyMockB {
public: public:
LegacyMockB() {} LegacyMockB() = default;
MOCK_METHOD0(DoB, void()); MOCK_METHOD0(DoB, void());
...@@ -534,7 +534,7 @@ TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) { ...@@ -534,7 +534,7 @@ TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
template <typename T> template <typename T>
class StackInterface { class StackInterface {
public: public:
virtual ~StackInterface() {} virtual ~StackInterface() = default;
// Template parameter appears in function parameter. // Template parameter appears in function parameter.
virtual void Push(const T& value) = 0; virtual void Push(const T& value) = 0;
...@@ -547,7 +547,7 @@ class StackInterface { ...@@ -547,7 +547,7 @@ class StackInterface {
template <typename T> template <typename T>
class MockStack : public StackInterface<T> { class MockStack : public StackInterface<T> {
public: public:
MockStack() {} MockStack() = default;
MOCK_METHOD(void, Push, (const T& elem), ()); MOCK_METHOD(void, Push, (const T& elem), ());
MOCK_METHOD(void, Pop, (), (final)); MOCK_METHOD(void, Pop, (), (final));
...@@ -566,7 +566,7 @@ class MockStack : public StackInterface<T> { ...@@ -566,7 +566,7 @@ class MockStack : public StackInterface<T> {
template <typename T> template <typename T>
class LegacyMockStack : public StackInterface<T> { class LegacyMockStack : public StackInterface<T> {
public: public:
LegacyMockStack() {} LegacyMockStack() = default;
MOCK_METHOD1_T(Push, void(const T& elem)); MOCK_METHOD1_T(Push, void(const T& elem));
MOCK_METHOD0_T(Pop, void()); MOCK_METHOD0_T(Pop, void());
...@@ -620,7 +620,7 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) { ...@@ -620,7 +620,7 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1)); EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
} }
#if GTEST_OS_WINDOWS #ifdef GTEST_OS_WINDOWS
// Tests mocking template interfaces with calltype. // Tests mocking template interfaces with calltype.
template <typename T> template <typename T>
...@@ -711,7 +711,7 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) { ...@@ -711,7 +711,7 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
class MockOverloadedOnArgNumber { class MockOverloadedOnArgNumber {
public: public:
MockOverloadedOnArgNumber() {} MockOverloadedOnArgNumber() = default;
MY_MOCK_METHODS1_; MY_MOCK_METHODS1_;
...@@ -723,7 +723,7 @@ class MockOverloadedOnArgNumber { ...@@ -723,7 +723,7 @@ class MockOverloadedOnArgNumber {
class LegacyMockOverloadedOnArgNumber { class LegacyMockOverloadedOnArgNumber {
public: public:
LegacyMockOverloadedOnArgNumber() {} LegacyMockOverloadedOnArgNumber() = default;
LEGACY_MY_MOCK_METHODS1_; LEGACY_MY_MOCK_METHODS1_;
...@@ -758,7 +758,7 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) { ...@@ -758,7 +758,7 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
class MockOverloadedOnConstness { class MockOverloadedOnConstness {
public: public:
MockOverloadedOnConstness() {} MockOverloadedOnConstness() = default;
MY_MOCK_METHODS2_; MY_MOCK_METHODS2_;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#include "gmock/gmock.h" #include "gmock/gmock.h"
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN #ifdef GTEST_OS_CYGWIN
#include <sys/types.h> // For ssize_t. NOLINT #include <sys/types.h> // For ssize_t. NOLINT
#endif #endif
...@@ -167,7 +168,7 @@ TEST(KindOfTest, Integer) { ...@@ -167,7 +168,7 @@ TEST(KindOfTest, Integer) {
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN #if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || defined(GTEST_OS_CYGWIN)
// ssize_t is not defined on Windows and possibly some other OSes. // ssize_t is not defined on Windows and possibly some other OSes.
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t)); // NOLINT
#endif #endif
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
// //
// This file tests some commonly used argument matchers. // This file tests some commonly used argument matchers.
#include <cmath>
#include <limits> #include <limits>
#include <memory>
#include <string>
#include "test/gmock-matchers_test.h" #include "test/gmock-matchers_test.h"
...@@ -952,7 +955,7 @@ TEST(AllArgsTest, WorksForNonTuple) { ...@@ -952,7 +955,7 @@ TEST(AllArgsTest, WorksForNonTuple) {
class AllArgsHelper { class AllArgsHelper {
public: public:
AllArgsHelper() {} AllArgsHelper() = default;
MOCK_METHOD2(Helper, int(char x, int y)); MOCK_METHOD2(Helper, int(char x, int y));
...@@ -973,7 +976,7 @@ TEST(AllArgsTest, WorksInWithClause) { ...@@ -973,7 +976,7 @@ TEST(AllArgsTest, WorksInWithClause) {
class OptionalMatchersHelper { class OptionalMatchersHelper {
public: public:
OptionalMatchersHelper() {} OptionalMatchersHelper() = default;
MOCK_METHOD0(NoArgs, int()); MOCK_METHOD0(NoArgs, int());
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
// //
// This file tests some commonly used argument matchers. // This file tests some commonly used argument matchers.
#include <functional>
#include <memory>
#include <string>
#include <tuple>
#include <vector> #include <vector>
#include "test/gmock-matchers_test.h" #include "test/gmock-matchers_test.h"
...@@ -585,8 +589,8 @@ TEST(MatcherCastTest, ValueIsNotCopied) { ...@@ -585,8 +589,8 @@ TEST(MatcherCastTest, ValueIsNotCopied) {
class Base { class Base {
public: public:
virtual ~Base() {} virtual ~Base() = default;
Base() {} Base() = default;
private: private:
Base(const Base&) = delete; Base(const Base&) = delete;
...@@ -1542,7 +1546,7 @@ TEST(PairTest, MatchesCorrectly) { ...@@ -1542,7 +1546,7 @@ TEST(PairTest, MatchesCorrectly) {
TEST(PairTest, WorksWithMoveOnly) { TEST(PairTest, WorksWithMoveOnly) {
pair<std::unique_ptr<int>, std::unique_ptr<int>> p; pair<std::unique_ptr<int>, std::unique_ptr<int>> p;
p.second.reset(new int(7)); p.second = std::make_unique<int>(7);
EXPECT_THAT(p, Pair(Eq(nullptr), Ne(nullptr))); EXPECT_THAT(p, Pair(Eq(nullptr), Ne(nullptr)));
} }
......
...@@ -31,6 +31,18 @@ ...@@ -31,6 +31,18 @@
// //
// This file tests some commonly used argument matchers. // This file tests some commonly used argument matchers.
#include <algorithm>
#include <array>
#include <deque>
#include <forward_list>
#include <iterator>
#include <list>
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
...@@ -1824,8 +1836,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) { ...@@ -1824,8 +1836,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {
} }
TEST(UnorderedElementsAreArrayTest, VectorBool) { TEST(UnorderedElementsAreArrayTest, VectorBool) {
const bool a[] = {0, 1, 0, 1, 1}; const bool a[] = {false, true, false, true, true};
const bool b[] = {1, 0, 1, 1, 0}; const bool b[] = {true, false, true, true, false};
std::vector<bool> expected(std::begin(a), std::end(a)); std::vector<bool> expected(std::begin(a), std::end(a));
std::vector<bool> actual(std::begin(b), std::end(b)); std::vector<bool> actual(std::begin(b), std::end(b));
StringMatchResultListener listener; StringMatchResultListener listener;
...@@ -2776,7 +2788,7 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) { ...@@ -2776,7 +2788,7 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {
class NativeArrayPassedAsPointerAndSize { class NativeArrayPassedAsPointerAndSize {
public: public:
NativeArrayPassedAsPointerAndSize() {} NativeArrayPassedAsPointerAndSize() = default;
MOCK_METHOD(void, Helper, (int* array, int size)); MOCK_METHOD(void, Helper, (int* array, int size));
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
// //
// This file tests some commonly used argument matchers. // This file tests some commonly used argument matchers.
#include <array>
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
...@@ -200,7 +208,7 @@ TEST(IsTrueTest, IsTrueIsFalse) { ...@@ -200,7 +208,7 @@ TEST(IsTrueTest, IsTrueIsFalse) {
EXPECT_THAT(nonnull_unique, Not(IsFalse())); EXPECT_THAT(nonnull_unique, Not(IsFalse()));
} }
#if GTEST_HAS_TYPED_TEST #ifdef GTEST_HAS_TYPED_TEST
// Tests ContainerEq with different container types, and // Tests ContainerEq with different container types, and
// different element types. // different element types.
......
...@@ -33,10 +33,14 @@ ...@@ -33,10 +33,14 @@
#include "gmock/gmock-more-actions.h" #include "gmock/gmock-more-actions.h"
#include <algorithm>
#include <functional> #include <functional>
#include <iterator>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <tuple>
#include <vector>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
...@@ -673,7 +677,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) { ...@@ -673,7 +677,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {
Action<MyFunction> a = SetArrayArgument<1>(letters.begin(), letters.end()); Action<MyFunction> a = SetArrayArgument<1>(letters.begin(), letters.end());
std::string s; std::string s;
a.Perform(std::make_tuple(true, back_inserter(s))); a.Perform(std::make_tuple(true, std::back_inserter(s)));
EXPECT_EQ(letters, s); EXPECT_EQ(letters, s);
} }
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
// clash with ::testing::Mock. // clash with ::testing::Mock.
class Mock { class Mock {
public: public:
Mock() {} Mock() = default;
MOCK_METHOD0(DoThis, void()); MOCK_METHOD0(DoThis, void());
...@@ -78,7 +78,7 @@ class CallsMockMethodInDestructor { ...@@ -78,7 +78,7 @@ class CallsMockMethodInDestructor {
class Foo { class Foo {
public: public:
virtual ~Foo() {} virtual ~Foo() = default;
virtual void DoThis() = 0; virtual void DoThis() = 0;
virtual int DoThat(bool flag) = 0; virtual int DoThat(bool flag) = 0;
...@@ -86,7 +86,7 @@ class Foo { ...@@ -86,7 +86,7 @@ class Foo {
class MockFoo : public Foo { class MockFoo : public Foo {
public: public:
MockFoo() {} MockFoo() = default;
void Delete() { delete this; } void Delete() { delete this; }
MOCK_METHOD0(DoThis, void()); MOCK_METHOD0(DoThis, void());
...@@ -109,7 +109,7 @@ class MockBar { ...@@ -109,7 +109,7 @@ class MockBar {
(a10 ? 'T' : 'F'); (a10 ? 'T' : 'F');
} }
virtual ~MockBar() {} virtual ~MockBar() = default;
const std::string& str() const { return str_; } const std::string& str() const { return str_; }
......
...@@ -98,7 +98,7 @@ class NonDefaultConstructible { ...@@ -98,7 +98,7 @@ class NonDefaultConstructible {
class MockA { class MockA {
public: public:
MockA() {} MockA() = default;
MOCK_METHOD1(DoA, void(int n)); MOCK_METHOD1(DoA, void(int n));
MOCK_METHOD1(ReturnResult, Result(int n)); MOCK_METHOD1(ReturnResult, Result(int n));
...@@ -113,7 +113,7 @@ class MockA { ...@@ -113,7 +113,7 @@ class MockA {
class MockB { class MockB {
public: public:
MockB() {} MockB() = default;
MOCK_CONST_METHOD0(DoB, int()); // NOLINT MOCK_CONST_METHOD0(DoB, int()); // NOLINT
MOCK_METHOD1(DoB, int(int n)); // NOLINT MOCK_METHOD1(DoB, int(int n)); // NOLINT
...@@ -125,7 +125,7 @@ class MockB { ...@@ -125,7 +125,7 @@ class MockB {
class ReferenceHoldingMock { class ReferenceHoldingMock {
public: public:
ReferenceHoldingMock() {} ReferenceHoldingMock() = default;
MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*)); MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*));
...@@ -143,12 +143,12 @@ class ReferenceHoldingMock { ...@@ -143,12 +143,12 @@ class ReferenceHoldingMock {
class CC { class CC {
public: public:
virtual ~CC() {} virtual ~CC() = default;
virtual int Method() = 0; virtual int Method() = 0;
}; };
class MockCC : public CC { class MockCC : public CC {
public: public:
MockCC() {} MockCC() = default;
MOCK_METHOD0(Method, int()); MOCK_METHOD0(Method, int());
...@@ -804,39 +804,40 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) { ...@@ -804,39 +804,40 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
"to be called at least once"); "to be called at least once");
} }
#if defined(__cplusplus) && __cplusplus >= 201703L #if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
// It should be possible to return a non-moveable type from a mock action in // It should be possible to return a non-moveable type from a mock action in
// C++17 and above, where it's guaranteed that such a type can be initialized // C++17 and above, where it's guaranteed that such a type can be initialized
// from a prvalue returned from a function. // from a prvalue returned from a function.
TEST(ExpectCallTest, NonMoveableType) { TEST(ExpectCallTest, NonMoveableType) {
// Define a non-moveable result type. // Define a non-moveable result type.
struct Result { struct NonMoveableStruct {
explicit Result(int x_in) : x(x_in) {} explicit NonMoveableStruct(int x_in) : x(x_in) {}
Result(Result&&) = delete; NonMoveableStruct(NonMoveableStruct&&) = delete;
int x; int x;
}; };
static_assert(!std::is_move_constructible_v<Result>); static_assert(!std::is_move_constructible_v<NonMoveableStruct>);
static_assert(!std::is_copy_constructible_v<Result>); static_assert(!std::is_copy_constructible_v<NonMoveableStruct>);
static_assert(!std::is_move_assignable_v<Result>); static_assert(!std::is_move_assignable_v<NonMoveableStruct>);
static_assert(!std::is_copy_assignable_v<Result>); static_assert(!std::is_copy_assignable_v<NonMoveableStruct>);
// We should be able to use a callable that returns that result as both a // We should be able to use a callable that returns that result as both a
// OnceAction and an Action, whether the callable ignores arguments or not. // OnceAction and an Action, whether the callable ignores arguments or not.
const auto return_17 = [] { return Result(17); }; const auto return_17 = [] { return NonMoveableStruct(17); };
static_cast<void>(OnceAction<Result()>{return_17}); static_cast<void>(OnceAction<NonMoveableStruct()>{return_17});
static_cast<void>(Action<Result()>{return_17}); static_cast<void>(Action<NonMoveableStruct()>{return_17});
static_cast<void>(OnceAction<Result(int)>{return_17}); static_cast<void>(OnceAction<NonMoveableStruct(int)>{return_17});
static_cast<void>(Action<Result(int)>{return_17}); static_cast<void>(Action<NonMoveableStruct(int)>{return_17});
// It should be possible to return the result end to end through an // It should be possible to return the result end to end through an
// EXPECT_CALL statement, with both WillOnce and WillRepeatedly. // EXPECT_CALL statement, with both WillOnce and WillRepeatedly.
MockFunction<Result()> mock; MockFunction<NonMoveableStruct()> mock;
EXPECT_CALL(mock, Call) // EXPECT_CALL(mock, Call) //
.WillOnce(return_17) // .WillOnce(return_17) //
.WillRepeatedly(return_17); .WillRepeatedly(return_17);
...@@ -1088,7 +1089,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { ...@@ -1088,7 +1089,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) {
// Verifies that the failure message contains the two unsatisfied // Verifies that the failure message contains the two unsatisfied
// pre-requisites but not the satisfied one. // pre-requisites but not the satisfied one.
#if GTEST_USES_POSIX_RE #ifdef GTEST_USES_POSIX_RE
EXPECT_THAT(r.message(), EXPECT_THAT(r.message(),
ContainsRegex( ContainsRegex(
// POSIX RE doesn't understand the (?s) prefix, but has no // POSIX RE doesn't understand the (?s) prefix, but has no
...@@ -1881,7 +1882,7 @@ struct Unprintable { ...@@ -1881,7 +1882,7 @@ struct Unprintable {
class MockC { class MockC {
public: public:
MockC() {} MockC() = default;
MOCK_METHOD6(VoidMethod, void(bool cond, int n, std::string s, void* p, MOCK_METHOD6(VoidMethod, void(bool cond, int n, std::string s, void* p,
const Printable& x, Unprintable y)); const Printable& x, Unprintable y));
...@@ -2050,7 +2051,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { ...@@ -2050,7 +2051,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture {
"See " "See "
"https://github.com/google/googletest/blob/main/docs/" "https://github.com/google/googletest/blob/main/docs/"
"gmock_cook_book.md#" "gmock_cook_book.md#"
"knowing-when-to-expect for details."; "knowing-when-to-expect-useoncall for details.";
// A void-returning function. // A void-returning function.
CaptureStdout(); CaptureStdout();
...@@ -2121,7 +2122,7 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) { ...@@ -2121,7 +2122,7 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {
class LogTestHelper { class LogTestHelper {
public: public:
LogTestHelper() {} LogTestHelper() = default;
MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot)); MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
// Tests Google Mock's functionality that depends on exceptions. // Tests Google Mock's functionality that depends on exceptions.
#include <exception>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -40,13 +40,13 @@ using ::testing::Return; ...@@ -40,13 +40,13 @@ using ::testing::Return;
class FooInterface { class FooInterface {
public: public:
virtual ~FooInterface() {} virtual ~FooInterface() = default;
virtual void DoThis() = 0; virtual void DoThis() = 0;
}; };
class MockFoo : public FooInterface { class MockFoo : public FooInterface {
public: public:
MockFoo() {} MockFoo() = default;
MOCK_METHOD0(DoThis, void()); MOCK_METHOD0(DoThis, void());
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
#include <errno.h> #include <errno.h>
#endif #endif
...@@ -181,7 +181,7 @@ using testing::WithArg; ...@@ -181,7 +181,7 @@ using testing::WithArg;
using testing::WithArgs; using testing::WithArgs;
using testing::WithoutArgs; using testing::WithoutArgs;
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
using testing::SetErrnoAndReturn; using testing::SetErrnoAndReturn;
#endif #endif
...@@ -194,7 +194,7 @@ using testing::MatchesRegex; ...@@ -194,7 +194,7 @@ using testing::MatchesRegex;
class Interface { class Interface {
public: public:
virtual ~Interface() {} virtual ~Interface() = default;
virtual void VoidFromString(char* str) = 0; virtual void VoidFromString(char* str) = 0;
virtual char* StringFromString(char* str) = 0; virtual char* StringFromString(char* str) = 0;
virtual int IntFromString(char* str) = 0; virtual int IntFromString(char* str) = 0;
...@@ -208,7 +208,7 @@ class Interface { ...@@ -208,7 +208,7 @@ class Interface {
class Mock : public Interface { class Mock : public Interface {
public: public:
Mock() {} Mock() = default;
MOCK_METHOD1(VoidFromString, void(char* str)); MOCK_METHOD1(VoidFromString, void(char* str));
MOCK_METHOD1(StringFromString, char*(char* str)); MOCK_METHOD1(StringFromString, char*(char* str));
...@@ -306,7 +306,7 @@ TEST(LinkTest, TestSetArrayArgument) { ...@@ -306,7 +306,7 @@ TEST(LinkTest, TestSetArrayArgument) {
mock.VoidFromString(&ch); mock.VoidFromString(&ch);
} }
#if !GTEST_OS_WINDOWS_MOBILE #ifndef GTEST_OS_WINDOWS_MOBILE
// Tests the linkage of the SetErrnoAndReturn action. // Tests the linkage of the SetErrnoAndReturn action.
TEST(LinkTest, TestSetErrnoAndReturn) { TEST(LinkTest, TestSetErrnoAndReturn) {
......
...@@ -52,7 +52,7 @@ using testing::Value; ...@@ -52,7 +52,7 @@ using testing::Value;
class MockFoo { class MockFoo {
public: public:
MockFoo() {} MockFoo() = default;
MOCK_METHOD3(Bar, char(const std::string& s, int i, double x)); MOCK_METHOD3(Bar, char(const std::string& s, int i, double x));
MOCK_METHOD2(Bar2, bool(int x, int y)); MOCK_METHOD2(Bar2, bool(int x, int y));
......
...@@ -40,6 +40,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(0, _))... ...@@ -40,6 +40,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(0, _))...
Actual: 1 Actual: 1
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnexpectedCall [ FAILED ] GMockOutputTest.UnexpectedCall
[ RUN ] GMockOutputTest.UnexpectedCallToVoidFunction [ RUN ] GMockOutputTest.UnexpectedCallToVoidFunction
unknown file: Failure unknown file: Failure
...@@ -53,6 +54,7 @@ FILE:#: EXPECT_CALL(foo_, Bar3(0, _))... ...@@ -53,6 +54,7 @@ FILE:#: EXPECT_CALL(foo_, Bar3(0, _))...
Actual: 1 Actual: 1
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction [ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction
[ RUN ] GMockOutputTest.ExcessiveCall [ RUN ] GMockOutputTest.ExcessiveCall
FILE:#: Failure FILE:#: Failure
...@@ -61,6 +63,7 @@ Mock function called more times than expected - returning default value. ...@@ -61,6 +63,7 @@ Mock function called more times than expected - returning default value.
Returns: false Returns: false
Expected: to be called once Expected: to be called once
Actual: called twice - over-saturated and active Actual: called twice - over-saturated and active
[ FAILED ] GMockOutputTest.ExcessiveCall [ FAILED ] GMockOutputTest.ExcessiveCall
[ RUN ] GMockOutputTest.ExcessiveCallToVoidFunction [ RUN ] GMockOutputTest.ExcessiveCallToVoidFunction
FILE:#: Failure FILE:#: Failure
...@@ -68,6 +71,7 @@ Mock function called more times than expected - returning directly. ...@@ -68,6 +71,7 @@ Mock function called more times than expected - returning directly.
Function call: Bar3(0, 1) Function call: Bar3(0, 1)
Expected: to be called once Expected: to be called once
Actual: called twice - over-saturated and active Actual: called twice - over-saturated and active
[ FAILED ] GMockOutputTest.ExcessiveCallToVoidFunction [ FAILED ] GMockOutputTest.ExcessiveCallToVoidFunction
[ RUN ] GMockOutputTest.UninterestingCall [ RUN ] GMockOutputTest.UninterestingCall
...@@ -75,14 +79,14 @@ GMOCK WARNING: ...@@ -75,14 +79,14 @@ GMOCK WARNING:
Uninteresting mock function call - returning default value. Uninteresting mock function call - returning default value.
Function call: Bar2(0, 1) Function call: Bar2(0, 1)
Returns: false Returns: false
NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details.
[ OK ] GMockOutputTest.UninterestingCall [ OK ] GMockOutputTest.UninterestingCall
[ RUN ] GMockOutputTest.UninterestingCallToVoidFunction [ RUN ] GMockOutputTest.UninterestingCallToVoidFunction
GMOCK WARNING: GMOCK WARNING:
Uninteresting mock function call - returning directly. Uninteresting mock function call - returning directly.
Function call: Bar3(0, 1) Function call: Bar3(0, 1)
NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details.
[ OK ] GMockOutputTest.UninterestingCallToVoidFunction [ OK ] GMockOutputTest.UninterestingCallToVoidFunction
[ RUN ] GMockOutputTest.RetiredExpectation [ RUN ] GMockOutputTest.RetiredExpectation
unknown file: Failure unknown file: Failure
...@@ -104,6 +108,7 @@ FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))... ...@@ -104,6 +108,7 @@ FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...
Actual: 1 Actual: 1
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.RetiredExpectation [ FAILED ] GMockOutputTest.RetiredExpectation
[ RUN ] GMockOutputTest.UnsatisfiedPrerequisite [ RUN ] GMockOutputTest.UnsatisfiedPrerequisite
unknown file: Failure unknown file: Failure
...@@ -125,6 +130,7 @@ FILE:#: pre-requisite #0 ...@@ -125,6 +130,7 @@ FILE:#: pre-requisite #0
(end of pre-requisites) (end of pre-requisites)
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite [ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
[ RUN ] GMockOutputTest.UnsatisfiedPrerequisites [ RUN ] GMockOutputTest.UnsatisfiedPrerequisites
unknown file: Failure unknown file: Failure
...@@ -147,6 +153,7 @@ FILE:#: pre-requisite #1 ...@@ -147,6 +153,7 @@ FILE:#: pre-requisite #1
(end of pre-requisites) (end of pre-requisites)
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites [ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
[ RUN ] GMockOutputTest.UnsatisfiedWith [ RUN ] GMockOutputTest.UnsatisfiedWith
FILE:#: Failure FILE:#: Failure
...@@ -154,16 +161,19 @@ Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))... ...@@ -154,16 +161,19 @@ Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...
Expected args: are a pair where the first >= the second Expected args: are a pair where the first >= the second
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedWith [ FAILED ] GMockOutputTest.UnsatisfiedWith
[ RUN ] GMockOutputTest.UnsatisfiedExpectation [ RUN ] GMockOutputTest.UnsatisfiedExpectation
FILE:#: Failure FILE:#: Failure
Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))... Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...
Expected: to be called twice Expected: to be called twice
Actual: called once - unsatisfied and active Actual: called once - unsatisfied and active
FILE:#: Failure FILE:#: Failure
Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))... Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation [ FAILED ] GMockOutputTest.UnsatisfiedExpectation
[ RUN ] GMockOutputTest.MismatchArguments [ RUN ] GMockOutputTest.MismatchArguments
unknown file: Failure unknown file: Failure
...@@ -180,6 +190,7 @@ FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))... ...@@ -180,6 +190,7 @@ FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...
Actual: -0.1 Actual: -0.1
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.MismatchArguments [ FAILED ] GMockOutputTest.MismatchArguments
[ RUN ] GMockOutputTest.MismatchWith [ RUN ] GMockOutputTest.MismatchWith
unknown file: Failure unknown file: Failure
...@@ -194,6 +205,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))... ...@@ -194,6 +205,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Actual: don't match Actual: don't match
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.MismatchWith [ FAILED ] GMockOutputTest.MismatchWith
[ RUN ] GMockOutputTest.MismatchArgumentsAndWith [ RUN ] GMockOutputTest.MismatchArgumentsAndWith
unknown file: Failure unknown file: Failure
...@@ -210,6 +222,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))... ...@@ -210,6 +222,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Actual: don't match Actual: don't match
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.MismatchArgumentsAndWith [ FAILED ] GMockOutputTest.MismatchArgumentsAndWith
[ RUN ] GMockOutputTest.UnexpectedCallWithDefaultAction [ RUN ] GMockOutputTest.UnexpectedCallWithDefaultAction
unknown file: Failure unknown file: Failure
...@@ -227,6 +240,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))... ...@@ -227,6 +240,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Actual: 0 Actual: 0
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
unknown file: Failure unknown file: Failure
Unexpected mock function call - taking default action specified at: Unexpected mock function call - taking default action specified at:
...@@ -242,6 +256,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))... ...@@ -242,6 +256,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Actual: 0 Actual: 0
Expected: to be called once Expected: to be called once
Actual: never called - unsatisfied and active Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnexpectedCallWithDefaultAction [ FAILED ] GMockOutputTest.UnexpectedCallWithDefaultAction
[ RUN ] GMockOutputTest.ExcessiveCallWithDefaultAction [ RUN ] GMockOutputTest.ExcessiveCallWithDefaultAction
FILE:#: Failure FILE:#: Failure
...@@ -251,6 +266,7 @@ FILE:#: ...@@ -251,6 +266,7 @@ FILE:#:
Returns: true Returns: true
Expected: to be called once Expected: to be called once
Actual: called twice - over-saturated and active Actual: called twice - over-saturated and active
FILE:#: Failure FILE:#: Failure
Mock function called more times than expected - taking default action specified at: Mock function called more times than expected - taking default action specified at:
FILE:#: FILE:#:
...@@ -258,6 +274,7 @@ FILE:#: ...@@ -258,6 +274,7 @@ FILE:#:
Returns: false Returns: false
Expected: to be called once Expected: to be called once
Actual: called twice - over-saturated and active Actual: called twice - over-saturated and active
[ FAILED ] GMockOutputTest.ExcessiveCallWithDefaultAction [ FAILED ] GMockOutputTest.ExcessiveCallWithDefaultAction
[ RUN ] GMockOutputTest.UninterestingCallWithDefaultAction [ RUN ] GMockOutputTest.UninterestingCallWithDefaultAction
...@@ -266,14 +283,14 @@ Uninteresting mock function call - taking default action specified at: ...@@ -266,14 +283,14 @@ Uninteresting mock function call - taking default action specified at:
FILE:#: FILE:#:
Function call: Bar2(2, 2) Function call: Bar2(2, 2)
Returns: true Returns: true
NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details.
GMOCK WARNING: GMOCK WARNING:
Uninteresting mock function call - taking default action specified at: Uninteresting mock function call - taking default action specified at:
FILE:#: FILE:#:
Function call: Bar2(1, 1) Function call: Bar2(1, 1)
Returns: false Returns: false
NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details.
[ OK ] GMockOutputTest.UninterestingCallWithDefaultAction [ OK ] GMockOutputTest.UninterestingCallWithDefaultAction
[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction [ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction
......
...@@ -174,6 +174,6 @@ TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) { ...@@ -174,6 +174,6 @@ TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {
// Makes sure Google Mock flags can be accessed in code. // Makes sure Google Mock flags can be accessed in code.
TEST(FlagTest, IsAccessibleInCode) { TEST(FlagTest, IsAccessibleInCode) {
bool dummy = bool dummy =
GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose) == ""; GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose).empty();
(void)dummy; // Avoids the "unused local variable" warning. (void)dummy; // Avoids the "unused local variable" warning.
} }
...@@ -16,6 +16,10 @@ if (POLICY CMP0054) ...@@ -16,6 +16,10 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0054 NEW)
endif (POLICY CMP0054) endif (POLICY CMP0054)
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif (POLICY CMP0069)
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs. # Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
# #
# This must be a macro(), as inside a function string() can only # This must be a macro(), as inside a function string() can only
...@@ -91,13 +95,13 @@ macro(config_compiler_and_linker) ...@@ -91,13 +95,13 @@ macro(config_compiler_and_linker)
set(cxx_base_flags "${cxx_base_flags} -utf-8") set(cxx_base_flags "${cxx_base_flags} -utf-8")
endif() endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(cxx_base_flags "-Wall -Wshadow -Wconversion") set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")
set(cxx_exception_flags "-fexceptions") set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions") set(cxx_no_exception_flags "-fno-exceptions")
set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
set(cxx_no_rtti_flags "-fno-rtti") set(cxx_no_rtti_flags "-fno-rtti")
elseif (CMAKE_COMPILER_IS_GNUCXX) elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow") set(cxx_base_flags "-Wall -Wshadow -Wundef")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else") set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
endif() endif()
......
...@@ -181,7 +181,7 @@ class GTEST_API_ AssertionResult { ...@@ -181,7 +181,7 @@ class GTEST_API_ AssertionResult {
// assertion's expectation). When nothing has been streamed into the // assertion's expectation). When nothing has been streamed into the
// object, returns an empty string. // object, returns an empty string.
const char* message() const { const char* message() const {
return message_.get() != nullptr ? message_->c_str() : ""; return message_ != nullptr ? message_->c_str() : "";
} }
// Deprecated; please use message() instead. // Deprecated; please use message() instead.
const char* failure_message() const { return message(); } const char* failure_message() const { return message(); }
...@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult { ...@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult {
private: private:
// Appends the contents of message to message_. // Appends the contents of message to message_.
void AppendMessage(const Message& a_message) { void AppendMessage(const Message& a_message) {
if (message_.get() == nullptr) message_.reset(new ::std::string); if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
message_->append(a_message.GetString().c_str()); message_->append(a_message.GetString().c_str());
} }
......
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