115 #ifndef GOOGLEMOCK_TEST_GMOCK_LINK_TEST_H_
116 #define GOOGLEMOCK_TEST_GMOCK_LINK_TEST_H_
118 #include "gmock/gmock.h"
120 #if !GTEST_OS_WINDOWS_MOBILE
127 #include "gtest/gtest.h"
128 #include "gtest/internal/gtest-port.h"
133 using testing::AllOf;
134 using testing::AnyOf;
136 using testing::ContainerEq;
139 using testing::DoubleEq;
140 using testing::ElementsAre;
141 using testing::ElementsAreArray;
142 using testing::EndsWith;
144 using testing::Field;
145 using testing::FloatEq;
148 using testing::HasSubstr;
153 using testing::IsNull;
154 using testing::IsSubsetOf;
155 using testing::IsSupersetOf;
159 using testing::MatcherCast;
160 using testing::NanSensitiveDoubleEq;
161 using testing::NanSensitiveFloatEq;
164 using testing::NotNull;
165 using testing::Pointee;
166 using testing::Property;
168 using testing::ResultOf;
174 using testing::StartsWith;
175 using testing::StrCaseEq;
176 using testing::StrCaseNe;
177 using testing::StrEq;
178 using testing::StrNe;
179 using testing::Truly;
180 using testing::TypedEq;
185 #if !GTEST_OS_WINDOWS_MOBILE
189 #if GTEST_HAS_EXCEPTIONS
190 using testing::Throw;
193 using testing::ContainsRegex;
194 using testing::MatchesRegex;
225 GTEST_DISALLOW_COPY_AND_ASSIGN_(
Mock);
247 TEST(LinkTest, TestReturnVoid) {
264 TEST(LinkTest, TestReturnNull) {
272 TEST(LinkTest, TestReturnRef) {
290 TEST(LinkTest, TestSetArgPointee) {
294 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgPointee<0>(
'y'));
299 TEST(LinkTest, TestSetArrayArgument) {
304 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
309 #if !GTEST_OS_WINDOWS_MOBILE
312 TEST(LinkTest, TestSetErrnoAndReturn) {
315 int saved_errno = errno;
336 TEST(LinkTest, TestInvokeWithoutArgs) {
349 TEST(LinkTest, TestInvokeArgument) {
353 EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));
376 TEST(LinkTest, TestWithoutArgs) {
394 TEST(LinkTest, TestDoDefault) {
404 TEST(LinkTest, TestIgnoreResult) {
411 #if GTEST_HAS_EXCEPTIONS
413 TEST(LinkTest, TestThrow) {
416 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
427 # pragma warning(push)
428 # pragma warning(disable:4100)
433 ACTION(Return1) {
return 1; }
436 TEST(LinkTest, TestActionMacro) {
439 EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());
445 ACTION_P(ReturnArgument, ret_value) {
return ret_value; }
448 TEST(LinkTest, TestActionPMacro) {
451 EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));
457 ACTION_P2(ReturnEqualsEitherOf, first, second) {
458 return arg0 == first || arg0 == second;
463 # pragma warning(pop)
466 TEST(LinkTest, TestActionP2Macro) {
471 .WillOnce(ReturnEqualsEitherOf(
"one",
"two"));
476 TEST(LinkTest, TestMatcherAnything) {
486 ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(
Return());
490 TEST(LinkTest, TestMatchersEq) {
494 ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(
Return());
495 ON_CALL(mock, VoidFromString(
const_cast<char*
>(
"y")))
500 TEST(LinkTest, TestMatchersRelations) {
503 ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(
Return());
504 ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(
Return());
505 ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(
Return());
506 ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(
Return());
507 ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(
Return());
511 TEST(LinkTest, TestMatcherNotNull) {
514 ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(
Return());
518 TEST(LinkTest, TestMatcherIsNull) {
521 ON_CALL(mock, VoidFromString(IsNull())).WillByDefault(
Return());
525 TEST(LinkTest, TestMatcherRef) {
529 ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(
Return());
533 TEST(LinkTest, TestMatcherTypedEq) {
537 ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(
Return());
542 TEST(LinkTest, TestMatchersFloatingPoint) {
546 ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(
Return());
547 ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(
Return());
548 ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(
Return());
549 ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))
554 TEST(LinkTest, TestMatcherContainsRegex) {
557 ON_CALL(mock, VoidFromString(ContainsRegex(
".*"))).WillByDefault(
Return());
561 TEST(LinkTest, TestMatcherMatchesRegex) {
564 ON_CALL(mock, VoidFromString(MatchesRegex(
".*"))).WillByDefault(
Return());
568 TEST(LinkTest, TestMatchersSubstrings) {
571 ON_CALL(mock, VoidFromString(StartsWith(
"a"))).WillByDefault(
Return());
572 ON_CALL(mock, VoidFromString(EndsWith(
"c"))).WillByDefault(
Return());
573 ON_CALL(mock, VoidFromString(HasSubstr(
"b"))).WillByDefault(
Return());
577 TEST(LinkTest, TestMatchersStringEquality) {
579 ON_CALL(mock, VoidFromString(StrEq(
"a"))).WillByDefault(
Return());
580 ON_CALL(mock, VoidFromString(StrNe(
"a"))).WillByDefault(
Return());
581 ON_CALL(mock, VoidFromString(StrCaseEq(
"a"))).WillByDefault(
Return());
582 ON_CALL(mock, VoidFromString(StrCaseNe(
"a"))).WillByDefault(
Return());
586 TEST(LinkTest, TestMatcherElementsAre) {
589 ON_CALL(mock, VoidFromVector(ElementsAre(
'a', _))).WillByDefault(
Return());
593 TEST(LinkTest, TestMatcherElementsAreArray) {
595 char arr[] = {
'a',
'b' };
597 ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(
Return());
601 TEST(LinkTest, TestMatcherIsSubsetOf) {
603 char arr[] = {
'a',
'b'};
605 ON_CALL(mock, VoidFromVector(IsSubsetOf(arr))).WillByDefault(
Return());
609 TEST(LinkTest, TestMatcherIsSupersetOf) {
611 char arr[] = {
'a',
'b'};
613 ON_CALL(mock, VoidFromVector(IsSupersetOf(arr))).WillByDefault(
Return());
617 TEST(LinkTest, TestMatcherContainerEq) {
621 ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(
Return());
625 TEST(LinkTest, TestMatcherField) {
636 TEST(LinkTest, TestMatcherProperty) {
647 TEST(LinkTest, TestMatcherResultOf) {
653 TEST(LinkTest, TestMatcherPointee) {
661 TEST(LinkTest, TestMatcherTruly) {
667 TEST(LinkTest, TestMatcherAllOf) {
673 TEST(LinkTest, TestMatcherAnyOf) {
679 TEST(LinkTest, TestMatcherNot) {
685 TEST(LinkTest, TestMatcherCast) {
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:238
FieldHelper(int a_field)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:240
int field_
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:242
int field() const
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:241
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:196
virtual void VoidFromString(char *str)=0
virtual ~Interface()
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:198
virtual char * StringFromString(char *str)=0
virtual void VoidFromFunc(void(*func)(char *str))=0
virtual void VoidFromIntRef(int &n)=0
virtual void VoidFromDouble(double n)=0
virtual int IntFromString(char *str)=0
virtual int & IntRefFromString(char *str)=0
virtual void VoidFromFloat(float n)=0
virtual void VoidFromVector(const std::vector< int > &v)=0
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:228
static int StaticIntFromString(char *)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:234
static void StaticVoidFromString(char *)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:232
void VoidFromVoid()
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:231
void VoidFromString(char *)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:233
static void StaticVoidFromVoid()
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:230
static bool StaticBoolFromString(const char *)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:235
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:210
Mock()
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:212
MOCK_METHOD1(IntRefFromString, int &(char *str))
MOCK_METHOD1(StringFromString, char *(char *str))
MOCK_METHOD1(VoidFromFloat, void(float n))
MOCK_METHOD1(VoidFromVector, void(const std::vector< int > &v))
MOCK_METHOD1(VoidFromDouble, void(double n))
MOCK_METHOD1(VoidFromFunc, void(void(*func)(char *str)))
MOCK_METHOD1(VoidFromString, void(char *str))
MOCK_METHOD1(VoidFromIntRef, void(int &n))
MOCK_METHOD1(IntFromString, int(char *str))
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:438
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:52
#define ACTION(name)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1627
#define ACTION_P2(name,...)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1654
#define ACTION_P(name,...)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1651
#define EXPECT_CALL(obj, call)
#define ON_CALL(obj, call)
TEST(LinkTest, TestReturnVoid)
Definition: cmake-build-debug/googletest-src/googlemock/test/gmock_link_test.h:247
#define EXPECT_THROW(statement, expected_exception)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1949
#define EXPECT_TRUE(condition)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1965
#define EXPECT_FALSE(condition)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1968
internal::WithArgsAction< typename std::decay< InnerAction >::type > WithoutArgs(InnerAction &&action)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1236
internal::IgnoreResultAction< A > IgnoreResult(const A &an_action)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1376
internal::SetArrayArgumentAction< k, I1, I2 > SetArrayArgument(I1 first, I2 last)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1438
internal::DoAllAction< typename std::decay< Action >::type... > DoAll(Action &&... action)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1204
internal::WithArgsAction< typename std::decay< InnerAction >::type, k, ks... > WithArgs(InnerAction &&action)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1226
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1322
internal::SetArgumentPointeeAction< N, T > SetArgPointee(T value)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1310
PolymorphicAction< internal::SetErrnoAndReturnAction< T > > SetErrnoAndReturn(int errval, T result)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1331
internal::InvokeWithoutArgsAction< typename std::decay< FunctionImpl >::type > InvokeWithoutArgs(FunctionImpl function_impl)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1360
internal::WithArgsAction< typename std::decay< InnerAction >::type, k > WithArg(InnerAction &&action)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1216
internal::ReturnRefAction< R > ReturnRef(R &x)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1260
internal::ReturnAction< R > Return(R value)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1244
internal::DoDefaultAction DoDefault()
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1303
PolymorphicAction< internal::ReturnNullAction > ReturnNull()
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1249
std::decay< FunctionImpl >::type Invoke(FunctionImpl &&function_impl)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:1345
internal::InvokeArgumentAction< index, typename std::decay< Params >::type... > InvokeArgument(Params &&... params)
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-more-actions.h:562