[libcxx] r285384 - Add more tests for optional<const T>

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 23:40:29 PDT 2016


Author: ericwf
Date: Fri Oct 28 01:40:29 2016
New Revision: 285384

URL: http://llvm.org/viewvc/llvm-project?rev=285384&view=rev
Log:
Add more tests for optional<const T>

Modified:
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
    libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp Fri Oct 28 01:40:29 2016
@@ -69,6 +69,11 @@ void test_implicit()
         static_assert(implicit_conversion<long double>(3.14, 3.14), "");
     }
     {
+        int x = 42;
+        optional<void* const> o(&x);
+        assert(*o == &x);
+    }
+    {
         using T = TrivialTestTypes::TestType;
         static_assert(implicit_conversion<T>(42, 42), "");
     }

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp Fri Oct 28 01:40:29 2016
@@ -53,6 +53,11 @@ int main()
 
     }
     {
+        const int x = 42;
+        optional<const int> o(x);
+        assert(*o == x);
+    }
+    {
         typedef TestTypes::TestType T;
         T::reset();
         const T t(3);

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp Fri Oct 28 01:40:29 2016
@@ -109,6 +109,11 @@ int main()
     test<int>();
     test<int>(3);
     {
+        const optional<const int> o(42);
+        optional<const int> o2(o);
+        assert(*o2 == 42);
+    }
+    {
         using T = TestTypes::TestType;
         T::reset();
         const optional<T> rhs;

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp Fri Oct 28 01:40:29 2016
@@ -75,6 +75,10 @@ int main()
 
     }
     {
+        optional<const int> opt(in_place, 5);
+        assert(*opt == 5);
+    }
+    {
         const optional<X> opt(in_place);
         assert(static_cast<bool>(opt) == true);
         assert(*opt == X());

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp Fri Oct 28 01:40:29 2016
@@ -137,6 +137,11 @@ int main()
     test<int>();
     test<int>(3);
     {
+        optional<const int> o(42);
+        optional<const int> o2(std::move(o));
+        assert(*o2 == 42);
+    }
+    {
         using T = TestTypes::TestType;
         T::reset();
         optional<T> rhs;

Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp?rev=285384&r1=285383&r2=285384&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp Fri Oct 28 01:40:29 2016
@@ -59,6 +59,11 @@ int main()
         };
     }
     {
+        const int x = 42;
+        optional<const int> o(std::move(x));
+        assert(*o == 42);
+    }
+    {
         typedef TestTypes::TestType T;
         T::reset();
         optional<T> opt = T{3};




More information about the cfe-commits mailing list