Add more tests for optional<const T>

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-10-28 06:40:29 +00:00
parent 68635ee647
commit a0b4d55133
6 changed files with 29 additions and 0 deletions

View File

@@ -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), "");

View File

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

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();