about summary refs log tree commit diff
path: root/absl/base/invoke_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base/invoke_test.cc')
-rw-r--r--absl/base/invoke_test.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/absl/base/invoke_test.cc b/absl/base/invoke_test.cc
index 691f553791d3..9074443b3cbb 100644
--- a/absl/base/invoke_test.cc
+++ b/absl/base/invoke_test.cc
@@ -70,6 +70,10 @@ struct OverloadedFunctor {
 struct Class {
   int Method(int a, int b) { return a - b; }
   int ConstMethod(int a, int b) const { return a - b; }
+  int RefMethod(int a, int b) & { return a - b; }
+  int RefRefMethod(int a, int b) && { return a - b; }
+  int NoExceptMethod(int a, int b) noexcept { return a - b; }
+  int VolatileMethod(int a, int b) volatile { return a - b; }
 
   int member;
 };
@@ -151,8 +155,18 @@ TEST(InvokeTest, ReferenceWrapper) {
 TEST(InvokeTest, MemberFunction) {
   std::unique_ptr<Class> p(new Class);
   std::unique_ptr<const Class> cp(new Class);
+  std::unique_ptr<volatile Class> vp(new Class);
+
   EXPECT_EQ(1, Invoke(&Class::Method, p, 3, 2));
   EXPECT_EQ(1, Invoke(&Class::Method, p.get(), 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::Method, *p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::RefMethod, p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::RefMethod, p.get(), 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::RefMethod, *p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::RefRefMethod, std::move(*p), 3, 2));  // NOLINT
+  EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, p.get(), 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::NoExceptMethod, *p, 3, 2));
 
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, p, 3, 2));
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, p.get(), 3, 2));
@@ -162,6 +176,13 @@ TEST(InvokeTest, MemberFunction) {
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, cp.get(), 3, 2));
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, *cp, 3, 2));
 
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, p.get(), 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, *p, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, vp, 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, vp.get(), 3, 2));
+  EXPECT_EQ(1, Invoke(&Class::VolatileMethod, *vp, 3, 2));
+
   EXPECT_EQ(1, Invoke(&Class::Method, make_unique<Class>(), 3, 2));
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<Class>(), 3, 2));
   EXPECT_EQ(1, Invoke(&Class::ConstMethod, make_unique<const Class>(), 3, 2));