about summary refs log tree commit diff
path: root/absl/utility/utility_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/utility/utility_test.cc')
-rw-r--r--absl/utility/utility_test.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/absl/utility/utility_test.cc b/absl/utility/utility_test.cc
index 5a4972b60085..f044ad644a4d 100644
--- a/absl/utility/utility_test.cc
+++ b/absl/utility/utility_test.cc
@@ -341,5 +341,36 @@ TEST(ExchangeTest, MoveOnly) {
   EXPECT_EQ(1, *b);
 }
 
+TEST(MakeFromTupleTest, String) {
+  EXPECT_EQ(
+      absl::make_from_tuple<std::string>(std::make_tuple("hello world", 5)),
+      "hello");
+}
+
+TEST(MakeFromTupleTest, MoveOnlyParameter) {
+  struct S {
+    S(std::unique_ptr<int> n, std::unique_ptr<int> m) : value(*n + *m) {}
+    int value = 0;
+  };
+  auto tup =
+      std::make_tuple(absl::make_unique<int>(3), absl::make_unique<int>(4));
+  auto s = absl::make_from_tuple<S>(std::move(tup));
+  EXPECT_EQ(s.value, 7);
+}
+
+TEST(MakeFromTupleTest, NoParameters) {
+  struct S {
+    S() : value(1) {}
+    int value = 2;
+  };
+  EXPECT_EQ(absl::make_from_tuple<S>(std::make_tuple()).value, 1);
+}
+
+TEST(MakeFromTupleTest, Pair) {
+  EXPECT_EQ(
+      (absl::make_from_tuple<std::pair<bool, int>>(std::make_tuple(true, 17))),
+      std::make_pair(true, 17));
+}
+
 }  // namespace