[libcxx] r333252 - Add one more test for optional

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Thu May 24 19:22:54 PDT 2018


Author: marshall
Date: Thu May 24 19:22:54 2018
New Revision: 333252

URL: http://llvm.org/viewvc/llvm-project?rev=333252&view=rev
Log:
Add one more test for optional

Modified:
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp?rev=333252&r1=333251&r2=333252&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp Thu May 24 19:22:54 2018
@@ -25,20 +25,29 @@ int main()
 {  
 //  Test the explicit deduction guides
     {
-//	optional(T)
+//  optional(T)
     std::optional opt(5);
     static_assert(std::is_same_v<decltype(opt), std::optional<int>>, "");
-	assert(static_cast<bool>(opt));
-	assert(*opt == 5);
+    assert(static_cast<bool>(opt));
+    assert(*opt == 5);
     }
 
     {
-//	optional(T)
+//  optional(T)
     std::optional opt(A{});
     static_assert(std::is_same_v<decltype(opt), std::optional<A>>, "");
-	assert(static_cast<bool>(opt));
+    assert(static_cast<bool>(opt));
     }
 
 //  Test the implicit deduction guides
 
+    {
+//  optional(const optional &);
+    std::optional<char> source('A');
+    std::optional opt(source);
+    static_assert(std::is_same_v<decltype(opt), std::optional<char>>, "");
+    assert(static_cast<bool>(opt) == static_cast<bool>(source));
+    assert(*opt == *source);
+    }
+
 }




More information about the cfe-commits mailing list