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:
@@ -68,6 +68,11 @@ void test_implicit()
|
|||||||
using T = long double;
|
using T = long double;
|
||||||
static_assert(implicit_conversion<long double>(3.14, 3.14), "");
|
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;
|
using T = TrivialTestTypes::TestType;
|
||||||
static_assert(implicit_conversion<T>(42, 42), "");
|
static_assert(implicit_conversion<T>(42, 42), "");
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ int main()
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const int x = 42;
|
||||||
|
optional<const int> o(x);
|
||||||
|
assert(*o == x);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
typedef TestTypes::TestType T;
|
typedef TestTypes::TestType T;
|
||||||
T::reset();
|
T::reset();
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ int main()
|
|||||||
{
|
{
|
||||||
test<int>();
|
test<int>();
|
||||||
test<int>(3);
|
test<int>(3);
|
||||||
|
{
|
||||||
|
const optional<const int> o(42);
|
||||||
|
optional<const int> o2(o);
|
||||||
|
assert(*o2 == 42);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
using T = TestTypes::TestType;
|
using T = TestTypes::TestType;
|
||||||
T::reset();
|
T::reset();
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ int main()
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
optional<const int> opt(in_place, 5);
|
||||||
|
assert(*opt == 5);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
const optional<X> opt(in_place);
|
const optional<X> opt(in_place);
|
||||||
assert(static_cast<bool>(opt) == true);
|
assert(static_cast<bool>(opt) == true);
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ int main()
|
|||||||
{
|
{
|
||||||
test<int>();
|
test<int>();
|
||||||
test<int>(3);
|
test<int>(3);
|
||||||
|
{
|
||||||
|
optional<const int> o(42);
|
||||||
|
optional<const int> o2(std::move(o));
|
||||||
|
assert(*o2 == 42);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
using T = TestTypes::TestType;
|
using T = TestTypes::TestType;
|
||||||
T::reset();
|
T::reset();
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ int main()
|
|||||||
constexpr test_constexpr_ctor(T&&) {}
|
constexpr test_constexpr_ctor(T&&) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const int x = 42;
|
||||||
|
optional<const int> o(std::move(x));
|
||||||
|
assert(*o == 42);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
typedef TestTypes::TestType T;
|
typedef TestTypes::TestType T;
|
||||||
T::reset();
|
T::reset();
|
||||||
|
|||||||
Reference in New Issue
Block a user