Quellcode durchsuchen

Add more tests for optional<const T>

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285384 91177308-0d34-0410-b5e6-96231b3b80d8
Eric Fiselier vor 8 Jahren
Ursprung
Commit
a0b4d55133

+ 5 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp

@@ -68,6 +68,11 @@ void test_implicit()
         using T = long double;
         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), "");

+ 5 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp

@@ -52,6 +52,11 @@ int main()
         };
 
     }
+    {
+        const int x = 42;
+        optional<const int> o(x);
+        assert(*o == x);
+    }
     {
         typedef TestTypes::TestType T;
         T::reset();

+ 5 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp

@@ -108,6 +108,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();

+ 4 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp

@@ -74,6 +74,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);

+ 5 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp

@@ -136,6 +136,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();

+ 5 - 0
test/std/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp

@@ -58,6 +58,11 @@ int main()
             constexpr test_constexpr_ctor(T&&) {}
         };
     }
+    {
+        const int x = 42;
+        optional<const int> o(std::move(x));
+        assert(*o == 42);
+    }
     {
         typedef TestTypes::TestType T;
         T::reset();