OLD | NEW |
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Tests that BuiltInDefaultValue<T*>::Exists() return true. | 88 // Tests that BuiltInDefaultValue<T*>::Exists() return true. |
89 TEST(BuiltInDefaultValueTest, ExistsForPointerTypes) { | 89 TEST(BuiltInDefaultValueTest, ExistsForPointerTypes) { |
90 EXPECT_TRUE(BuiltInDefaultValue<int*>::Exists()); | 90 EXPECT_TRUE(BuiltInDefaultValue<int*>::Exists()); |
91 EXPECT_TRUE(BuiltInDefaultValue<const char*>::Exists()); | 91 EXPECT_TRUE(BuiltInDefaultValue<const char*>::Exists()); |
92 EXPECT_TRUE(BuiltInDefaultValue<void*>::Exists()); | 92 EXPECT_TRUE(BuiltInDefaultValue<void*>::Exists()); |
93 } | 93 } |
94 | 94 |
95 // Tests that BuiltInDefaultValue<T>::Get() returns 0 when T is a | 95 // Tests that BuiltInDefaultValue<T>::Get() returns 0 when T is a |
96 // built-in numeric type. | 96 // built-in numeric type. |
97 TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) { | 97 TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) { |
98 EXPECT_EQ(0, BuiltInDefaultValue<unsigned char>::Get()); | 98 EXPECT_EQ(0U, BuiltInDefaultValue<unsigned char>::Get()); |
99 EXPECT_EQ(0, BuiltInDefaultValue<signed char>::Get()); | 99 EXPECT_EQ(0, BuiltInDefaultValue<signed char>::Get()); |
100 EXPECT_EQ(0, BuiltInDefaultValue<char>::Get()); | 100 EXPECT_EQ(0, BuiltInDefaultValue<char>::Get()); |
101 #if GMOCK_HAS_SIGNED_WCHAR_T_ | 101 #if GMOCK_HAS_SIGNED_WCHAR_T_ |
102 EXPECT_EQ(0, BuiltInDefaultValue<unsigned wchar_t>::Get()); | 102 EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get()); |
103 EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get()); | 103 EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get()); |
104 #endif | 104 #endif |
105 #if GMOCK_WCHAR_T_IS_NATIVE_ | 105 #if GMOCK_WCHAR_T_IS_NATIVE_ |
106 EXPECT_EQ(0, BuiltInDefaultValue<wchar_t>::Get()); | 106 EXPECT_EQ(0, BuiltInDefaultValue<wchar_t>::Get()); |
107 #endif | 107 #endif |
108 EXPECT_EQ(0, BuiltInDefaultValue<unsigned short>::Get()); // NOLINT | 108 EXPECT_EQ(0U, BuiltInDefaultValue<unsigned short>::Get()); // NOLINT |
109 EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get()); // NOLINT | 109 EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get()); // NOLINT |
110 EXPECT_EQ(0, BuiltInDefaultValue<short>::Get()); // NOLINT | 110 EXPECT_EQ(0, BuiltInDefaultValue<short>::Get()); // NOLINT |
111 EXPECT_EQ(0, BuiltInDefaultValue<unsigned int>::Get()); | 111 EXPECT_EQ(0U, BuiltInDefaultValue<unsigned int>::Get()); |
112 EXPECT_EQ(0, BuiltInDefaultValue<signed int>::Get()); | 112 EXPECT_EQ(0, BuiltInDefaultValue<signed int>::Get()); |
113 EXPECT_EQ(0, BuiltInDefaultValue<int>::Get()); | 113 EXPECT_EQ(0, BuiltInDefaultValue<int>::Get()); |
114 EXPECT_EQ(0, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT | 114 EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT |
115 EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT | 115 EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT |
116 EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT | 116 EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT |
117 EXPECT_EQ(0, BuiltInDefaultValue<UInt64>::Get()); | 117 EXPECT_EQ(0U, BuiltInDefaultValue<UInt64>::Get()); |
118 EXPECT_EQ(0, BuiltInDefaultValue<Int64>::Get()); | 118 EXPECT_EQ(0, BuiltInDefaultValue<Int64>::Get()); |
119 EXPECT_EQ(0, BuiltInDefaultValue<float>::Get()); | 119 EXPECT_EQ(0, BuiltInDefaultValue<float>::Get()); |
120 EXPECT_EQ(0, BuiltInDefaultValue<double>::Get()); | 120 EXPECT_EQ(0, BuiltInDefaultValue<double>::Get()); |
121 } | 121 } |
122 | 122 |
123 // Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a | 123 // Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a |
124 // built-in numeric type. | 124 // built-in numeric type. |
125 TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) { | 125 TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) { |
126 EXPECT_TRUE(BuiltInDefaultValue<unsigned char>::Exists()); | 126 EXPECT_TRUE(BuiltInDefaultValue<unsigned char>::Exists()); |
127 EXPECT_TRUE(BuiltInDefaultValue<signed char>::Exists()); | 127 EXPECT_TRUE(BuiltInDefaultValue<signed char>::Exists()); |
(...skipping 30 matching lines...) Expand all Loading... |
158 EXPECT_TRUE(BuiltInDefaultValue<bool>::Exists()); | 158 EXPECT_TRUE(BuiltInDefaultValue<bool>::Exists()); |
159 } | 159 } |
160 | 160 |
161 // Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a | 161 // Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a |
162 // string type. | 162 // string type. |
163 TEST(BuiltInDefaultValueTest, IsEmptyStringForString) { | 163 TEST(BuiltInDefaultValueTest, IsEmptyStringForString) { |
164 #if GTEST_HAS_GLOBAL_STRING | 164 #if GTEST_HAS_GLOBAL_STRING |
165 EXPECT_EQ("", BuiltInDefaultValue< ::string>::Get()); | 165 EXPECT_EQ("", BuiltInDefaultValue< ::string>::Get()); |
166 #endif // GTEST_HAS_GLOBAL_STRING | 166 #endif // GTEST_HAS_GLOBAL_STRING |
167 | 167 |
168 #if GTEST_HAS_STD_STRING | |
169 EXPECT_EQ("", BuiltInDefaultValue< ::std::string>::Get()); | 168 EXPECT_EQ("", BuiltInDefaultValue< ::std::string>::Get()); |
170 #endif // GTEST_HAS_STD_STRING | |
171 } | 169 } |
172 | 170 |
173 // Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a | 171 // Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a |
174 // string type. | 172 // string type. |
175 TEST(BuiltInDefaultValueTest, ExistsForString) { | 173 TEST(BuiltInDefaultValueTest, ExistsForString) { |
176 #if GTEST_HAS_GLOBAL_STRING | 174 #if GTEST_HAS_GLOBAL_STRING |
177 EXPECT_TRUE(BuiltInDefaultValue< ::string>::Exists()); | 175 EXPECT_TRUE(BuiltInDefaultValue< ::string>::Exists()); |
178 #endif // GTEST_HAS_GLOBAL_STRING | 176 #endif // GTEST_HAS_GLOBAL_STRING |
179 | 177 |
180 #if GTEST_HAS_STD_STRING | |
181 EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists()); | 178 EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists()); |
182 #endif // GTEST_HAS_STD_STRING | |
183 } | 179 } |
184 | 180 |
185 // Tests that BuiltInDefaultValue<const T>::Get() returns the same | 181 // Tests that BuiltInDefaultValue<const T>::Get() returns the same |
186 // value as BuiltInDefaultValue<T>::Get() does. | 182 // value as BuiltInDefaultValue<T>::Get() does. |
187 TEST(BuiltInDefaultValueTest, WorksForConstTypes) { | 183 TEST(BuiltInDefaultValueTest, WorksForConstTypes) { |
188 EXPECT_EQ("", BuiltInDefaultValue<const std::string>::Get()); | 184 EXPECT_EQ("", BuiltInDefaultValue<const std::string>::Get()); |
189 EXPECT_EQ(0, BuiltInDefaultValue<const int>::Get()); | 185 EXPECT_EQ(0, BuiltInDefaultValue<const int>::Get()); |
190 EXPECT_TRUE(BuiltInDefaultValue<char* const>::Get() == NULL); | 186 EXPECT_TRUE(BuiltInDefaultValue<char* const>::Get() == NULL); |
191 EXPECT_FALSE(BuiltInDefaultValue<const bool>::Get()); | 187 EXPECT_FALSE(BuiltInDefaultValue<const bool>::Get()); |
192 } | 188 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 TEST(ReturnTest, IsCovariant) { | 504 TEST(ReturnTest, IsCovariant) { |
509 Base base; | 505 Base base; |
510 Derived derived; | 506 Derived derived; |
511 Action<Base*()> ret = Return(&base); | 507 Action<Base*()> ret = Return(&base); |
512 EXPECT_EQ(&base, ret.Perform(make_tuple())); | 508 EXPECT_EQ(&base, ret.Perform(make_tuple())); |
513 | 509 |
514 ret = Return(&derived); | 510 ret = Return(&derived); |
515 EXPECT_EQ(&derived, ret.Perform(make_tuple())); | 511 EXPECT_EQ(&derived, ret.Perform(make_tuple())); |
516 } | 512 } |
517 | 513 |
| 514 // Tests that the type of the value passed into Return is converted into T |
| 515 // when the action is cast to Action<T(...)> rather than when the action is |
| 516 // performed. See comments on testing::internal::ReturnAction in |
| 517 // gmock-actions.h for more information. |
| 518 class FromType { |
| 519 public: |
| 520 FromType(bool* is_converted) : converted_(is_converted) {} |
| 521 bool* converted() const { return converted_; } |
| 522 |
| 523 private: |
| 524 bool* const converted_; |
| 525 |
| 526 GTEST_DISALLOW_ASSIGN_(FromType); |
| 527 }; |
| 528 |
| 529 class ToType { |
| 530 public: |
| 531 ToType(const FromType& x) { *x.converted() = true; } |
| 532 }; |
| 533 |
| 534 TEST(ReturnTest, ConvertsArgumentWhenConverted) { |
| 535 bool converted = false; |
| 536 FromType x(&converted); |
| 537 Action<ToType()> action(Return(x)); |
| 538 EXPECT_TRUE(converted) << "Return must convert its argument in its own " |
| 539 << "conversion operator."; |
| 540 converted = false; |
| 541 action.Perform(tuple<>()); |
| 542 EXPECT_FALSE(converted) << "Action must NOT convert its argument " |
| 543 << "when performed." ; |
| 544 } |
| 545 |
| 546 class DestinationType {}; |
| 547 |
| 548 class SourceType { |
| 549 public: |
| 550 // Note: a non-const typecast operator. |
| 551 operator DestinationType() { return DestinationType(); } |
| 552 }; |
| 553 |
| 554 TEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) { |
| 555 SourceType s; |
| 556 Action<DestinationType()> action(Return(s)); |
| 557 } |
| 558 |
518 // Tests that ReturnNull() returns NULL in a pointer-returning function. | 559 // Tests that ReturnNull() returns NULL in a pointer-returning function. |
519 TEST(ReturnNullTest, WorksInPointerReturningFunction) { | 560 TEST(ReturnNullTest, WorksInPointerReturningFunction) { |
520 const Action<int*()> a1 = ReturnNull(); | 561 const Action<int*()> a1 = ReturnNull(); |
521 EXPECT_TRUE(a1.Perform(make_tuple()) == NULL); | 562 EXPECT_TRUE(a1.Perform(make_tuple()) == NULL); |
522 | 563 |
523 const Action<const char*(bool)> a2 = ReturnNull(); // NOLINT | 564 const Action<const char*(bool)> a2 = ReturnNull(); // NOLINT |
524 EXPECT_TRUE(a2.Perform(make_tuple(true)) == NULL); | 565 EXPECT_TRUE(a2.Perform(make_tuple(true)) == NULL); |
525 } | 566 } |
526 | 567 |
527 // Tests that ReturnRef(v) works for reference types. | 568 // Tests that ReturnRef(v) works for reference types. |
(...skipping 14 matching lines...) Expand all Loading... |
542 a = ReturnRef(derived); | 583 a = ReturnRef(derived); |
543 EXPECT_EQ(&derived, &a.Perform(make_tuple())); | 584 EXPECT_EQ(&derived, &a.Perform(make_tuple())); |
544 } | 585 } |
545 | 586 |
546 // Tests that DoDefault() does the default action for the mock method. | 587 // Tests that DoDefault() does the default action for the mock method. |
547 | 588 |
548 class MyClass {}; | 589 class MyClass {}; |
549 | 590 |
550 class MockClass { | 591 class MockClass { |
551 public: | 592 public: |
| 593 MockClass() {} |
| 594 |
552 MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT | 595 MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT |
553 MOCK_METHOD0(Foo, MyClass()); | 596 MOCK_METHOD0(Foo, MyClass()); |
| 597 |
| 598 private: |
| 599 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockClass); |
554 }; | 600 }; |
555 | 601 |
556 // Tests that DoDefault() returns the built-in default value for the | 602 // Tests that DoDefault() returns the built-in default value for the |
557 // return type by default. | 603 // return type by default. |
558 TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) { | 604 TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) { |
559 MockClass mock; | 605 MockClass mock; |
560 EXPECT_CALL(mock, IntFunc(_)) | 606 EXPECT_CALL(mock, IntFunc(_)) |
561 .WillOnce(DoDefault()); | 607 .WillOnce(DoDefault()); |
562 EXPECT_EQ(0, mock.IntFunc(true)); | 608 EXPECT_EQ(0, mock.IntFunc(true)); |
563 } | 609 } |
564 | 610 |
565 // Tests that DoDefault() aborts the process when there is no built-in | 611 // Tests that DoDefault() aborts the process when there is no built-in |
566 // default value for the return type. | 612 // default value for the return type. |
567 TEST(DoDefaultDeathTest, DiesForUnknowType) { | 613 TEST(DoDefaultDeathTest, DiesForUnknowType) { |
568 MockClass mock; | 614 MockClass mock; |
569 EXPECT_CALL(mock, Foo()) | 615 EXPECT_CALL(mock, Foo()) |
570 .WillRepeatedly(DoDefault()); | 616 .WillRepeatedly(DoDefault()); |
571 EXPECT_DEATH_IF_SUPPORTED({ | 617 EXPECT_DEATH_IF_SUPPORTED({ |
572 mock.Foo(); | 618 mock.Foo(); |
573 }, ""); | 619 }, ""); |
574 } | 620 } |
575 | 621 |
576 // Tests that using DoDefault() inside a composite action leads to a | 622 // Tests that using DoDefault() inside a composite action leads to a |
577 // run-time error. | 623 // run-time error. |
578 | 624 |
579 void VoidFunc(bool flag) {} | 625 void VoidFunc(bool /* flag */) {} |
580 | 626 |
581 TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) { | 627 TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) { |
582 MockClass mock; | 628 MockClass mock; |
583 EXPECT_CALL(mock, IntFunc(_)) | 629 EXPECT_CALL(mock, IntFunc(_)) |
584 .WillRepeatedly(DoAll(Invoke(VoidFunc), | 630 .WillRepeatedly(DoAll(Invoke(VoidFunc), |
585 DoDefault())); | 631 DoDefault())); |
586 | 632 |
587 // Ideally we should verify the error message as well. Sadly, | 633 // Ideally we should verify the error message as well. Sadly, |
588 // EXPECT_DEATH() can only capture stderr, while Google Mock's | 634 // EXPECT_DEATH() can only capture stderr, while Google Mock's |
589 // errors are printed on stdout. Therefore we have to settle for | 635 // errors are printed on stdout. Therefore we have to settle for |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 801 |
756 class VoidNullaryFunctor { | 802 class VoidNullaryFunctor { |
757 public: | 803 public: |
758 void operator()() { g_done = true; } | 804 void operator()() { g_done = true; } |
759 }; | 805 }; |
760 | 806 |
761 bool Unary(int x) { return x < 0; } | 807 bool Unary(int x) { return x < 0; } |
762 | 808 |
763 const char* Plus1(const char* s) { return s + 1; } | 809 const char* Plus1(const char* s) { return s + 1; } |
764 | 810 |
765 void VoidUnary(int n) { g_done = true; } | 811 void VoidUnary(int /* n */) { g_done = true; } |
766 | 812 |
767 bool ByConstRef(const std::string& s) { return s == "Hi"; } | 813 bool ByConstRef(const std::string& s) { return s == "Hi"; } |
768 | 814 |
769 const double g_double = 0; | 815 const double g_double = 0; |
770 bool ReferencesGlobalDouble(const double& x) { return &x == &g_double; } | 816 bool ReferencesGlobalDouble(const double& x) { return &x == &g_double; } |
771 | 817 |
772 std::string ByNonConstRef(std::string& s) { return s += "+"; } // NOLINT | 818 std::string ByNonConstRef(std::string& s) { return s += "+"; } // NOLINT |
773 | 819 |
774 struct UnaryFunctor { | 820 struct UnaryFunctor { |
775 int operator()(bool x) { return x ? 1 : -1; } | 821 int operator()(bool x) { return x ? 1 : -1; } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 int value_; | 870 int value_; |
825 }; | 871 }; |
826 | 872 |
827 // Tests InvokeWithoutArgs(function). | 873 // Tests InvokeWithoutArgs(function). |
828 TEST(InvokeWithoutArgsTest, Function) { | 874 TEST(InvokeWithoutArgsTest, Function) { |
829 // As an action that takes one argument. | 875 // As an action that takes one argument. |
830 Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT | 876 Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT |
831 EXPECT_EQ(1, a.Perform(make_tuple(2))); | 877 EXPECT_EQ(1, a.Perform(make_tuple(2))); |
832 | 878 |
833 // As an action that takes two arguments. | 879 // As an action that takes two arguments. |
834 Action<short(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT | 880 Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT |
835 EXPECT_EQ(1, a2.Perform(make_tuple(2, 3.5))); | 881 EXPECT_EQ(1, a2.Perform(make_tuple(2, 3.5))); |
836 | 882 |
837 // As an action that returns void. | 883 // As an action that returns void. |
838 Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT | 884 Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT |
839 g_done = false; | 885 g_done = false; |
840 a3.Perform(make_tuple(1)); | 886 a3.Perform(make_tuple(1)); |
841 EXPECT_TRUE(g_done); | 887 EXPECT_TRUE(g_done); |
842 } | 888 } |
843 | 889 |
844 // Tests InvokeWithoutArgs(functor). | 890 // Tests InvokeWithoutArgs(functor). |
845 TEST(InvokeWithoutArgsTest, Functor) { | 891 TEST(InvokeWithoutArgsTest, Functor) { |
846 // As an action that takes no argument. | 892 // As an action that takes no argument. |
847 Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT | 893 Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT |
848 EXPECT_EQ(2, a.Perform(make_tuple())); | 894 EXPECT_EQ(2, a.Perform(make_tuple())); |
849 | 895 |
850 // As an action that takes three arguments. | 896 // As an action that takes three arguments. |
851 Action<short(int, double, char)> a2 = // NOLINT | 897 Action<int(int, double, char)> a2 = // NOLINT |
852 InvokeWithoutArgs(NullaryFunctor()); | 898 InvokeWithoutArgs(NullaryFunctor()); |
853 EXPECT_EQ(2, a2.Perform(make_tuple(3, 3.5, 'a'))); | 899 EXPECT_EQ(2, a2.Perform(make_tuple(3, 3.5, 'a'))); |
854 | 900 |
855 // As an action that returns void. | 901 // As an action that returns void. |
856 Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor()); | 902 Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor()); |
857 g_done = false; | 903 g_done = false; |
858 a3.Perform(make_tuple()); | 904 a3.Perform(make_tuple()); |
859 EXPECT_TRUE(g_done); | 905 EXPECT_TRUE(g_done); |
860 } | 906 } |
861 | 907 |
(...skipping 20 matching lines...) Expand all Loading... |
882 | 928 |
883 TEST(IgnoreResultTest, MonomorphicAction) { | 929 TEST(IgnoreResultTest, MonomorphicAction) { |
884 g_done = false; | 930 g_done = false; |
885 Action<void()> a = IgnoreResult(Invoke(ReturnOne)); | 931 Action<void()> a = IgnoreResult(Invoke(ReturnOne)); |
886 a.Perform(make_tuple()); | 932 a.Perform(make_tuple()); |
887 EXPECT_TRUE(g_done); | 933 EXPECT_TRUE(g_done); |
888 } | 934 } |
889 | 935 |
890 // Tests using IgnoreResult() on an action that returns a class type. | 936 // Tests using IgnoreResult() on an action that returns a class type. |
891 | 937 |
892 MyClass ReturnMyClass(double x) { | 938 MyClass ReturnMyClass(double /* x */) { |
893 g_done = true; | 939 g_done = true; |
894 return MyClass(); | 940 return MyClass(); |
895 } | 941 } |
896 | 942 |
897 TEST(IgnoreResultTest, ActionReturningClass) { | 943 TEST(IgnoreResultTest, ActionReturningClass) { |
898 g_done = false; | 944 g_done = false; |
899 Action<void(int)> a = IgnoreResult(Invoke(ReturnMyClass)); // NOLINT | 945 Action<void(int)> a = IgnoreResult(Invoke(ReturnMyClass)); // NOLINT |
900 a.Perform(make_tuple(2)); | 946 a.Perform(make_tuple(2)); |
901 EXPECT_TRUE(g_done); | 947 EXPECT_TRUE(g_done); |
902 } | 948 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 // Tests that Google Mock prints expression ByRef(x) as a reference to x. | 1074 // Tests that Google Mock prints expression ByRef(x) as a reference to x. |
1029 TEST(ByRefTest, PrintsCorrectly) { | 1075 TEST(ByRefTest, PrintsCorrectly) { |
1030 int n = 42; | 1076 int n = 42; |
1031 ::std::stringstream expected, actual; | 1077 ::std::stringstream expected, actual; |
1032 testing::internal::UniversalPrinter<const int&>::Print(n, &expected); | 1078 testing::internal::UniversalPrinter<const int&>::Print(n, &expected); |
1033 testing::internal::UniversalPrint(ByRef(n), &actual); | 1079 testing::internal::UniversalPrint(ByRef(n), &actual); |
1034 EXPECT_EQ(expected.str(), actual.str()); | 1080 EXPECT_EQ(expected.str(), actual.str()); |
1035 } | 1081 } |
1036 | 1082 |
1037 } // Unnamed namespace | 1083 } // Unnamed namespace |
OLD | NEW |