aboutsummaryrefslogtreecommitdiff
path: root/googlemock/test
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-matchers-comparisons_test.cc9
-rw-r--r--googlemock/test/gmock-more-actions_test.cc14
-rw-r--r--googlemock/test/gmock_link_test.h9
3 files changed, 31 insertions, 1 deletions
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index b2ce99e1..5b75b457 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -1769,6 +1769,15 @@ TEST(StartsWithTest, CanDescribeSelf) {
EXPECT_EQ("starts with \"Hi\"", Describe(m));
}
+TEST(StartsWithTest, WorksWithStringMatcherOnStringViewMatchee) {
+#if GTEST_INTERNAL_HAS_STRING_VIEW
+ EXPECT_THAT(internal::StringView("talk to me goose"),
+ StartsWith(std::string("talk")));
+#else
+ GTEST_SKIP() << "Not applicable without internal::StringView.";
+#endif // GTEST_INTERNAL_HAS_STRING_VIEW
+}
+
// Tests EndsWith(s).
TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 9980f3bc..16af6892 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -85,6 +85,12 @@ struct UnaryFunctor {
int operator()(bool x) { return x ? 1 : -1; }
};
+struct UnaryMoveOnlyFunctor : UnaryFunctor {
+ UnaryMoveOnlyFunctor() = default;
+ UnaryMoveOnlyFunctor(const UnaryMoveOnlyFunctor&) = delete;
+ UnaryMoveOnlyFunctor(UnaryMoveOnlyFunctor&&) = default;
+};
+
const char* Binary(const char* input, short n) { return input + n; } // NOLINT
int Ternary(int x, char y, short z) { return x + y + z; } // NOLINT
@@ -698,12 +704,18 @@ TEST(InvokeArgumentTest, Function0) {
EXPECT_EQ(1, a.Perform(std::make_tuple(2, &Nullary)));
}
-// Tests using InvokeArgument with a unary function.
+// Tests using InvokeArgument with a unary functor.
TEST(InvokeArgumentTest, Functor1) {
Action<int(UnaryFunctor)> a = InvokeArgument<0>(true); // NOLINT
EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryFunctor())));
}
+// Tests using InvokeArgument with a unary move-only functor.
+TEST(InvokeArgumentTest, Functor1MoveOnly) {
+ Action<int(UnaryMoveOnlyFunctor)> a = InvokeArgument<0>(true); // NOLINT
+ EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryMoveOnlyFunctor())));
+}
+
// Tests using InvokeArgument with a 5-ary function.
TEST(InvokeArgumentTest, Function5) {
Action<int(int (*)(int, int, int, int, int))> a = // NOLINT
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index db11c2d2..cf0a985b 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -187,6 +187,7 @@ using testing::SetErrnoAndReturn;
#if GTEST_HAS_EXCEPTIONS
using testing::Throw;
+using testing::Rethrow;
#endif
using testing::ContainsRegex;
@@ -416,6 +417,14 @@ TEST(LinkTest, TestThrow) {
EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
EXPECT_THROW(mock.VoidFromString(nullptr), int);
}
+// Tests the linkage of the Rethrow action.
+TEST(LinkTest, TestRethrow) {
+ Mock mock;
+
+ EXPECT_CALL(mock, VoidFromString(_))
+ .WillOnce(Rethrow(std::make_exception_ptr(42)));
+ EXPECT_THROW(mock.VoidFromString(nullptr), int);
+}
#endif // GTEST_HAS_EXCEPTIONS
// The ACTION*() macros trigger warning C4100 (unreferenced formal