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