Skip to content

Commit 84df92e

Browse files
committed
Update tests
1 parent 1cb7b40 commit 84df92e

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

libcxx/test/std/utilities/expected/expected.expected/assign/assign.U.pass.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,17 @@ constexpr bool test() {
349349
{
350350
MoveOnlyMulti t{};
351351
std::expected<MoveOnlyMulti, int> e1(std::unexpect);
352-
e1 = std::move(t);
352+
static_assert(std::is_same_v<decltype(std::move(t)), MoveOnlyMulti&&>);
353+
e1 = {std::move(t)};
353354
assert(e1.value().used_move1);
354355
}
355356
{
356357
const MoveOnlyMulti t{};
357358
std::expected<MoveOnlyMulti, int> e1(std::unexpect);
358-
e1 = std::move(t);
359-
assert(e1.value().used_move2);
359+
static_assert(std::is_same_v<decltype(std::move(t)), const MoveOnlyMulti&&>);
360+
// _Up = remove_cv_t<const MoveOnlyMulti&&> --> should use MoveOnlyMulti(MoveOnlyMulti&&)
361+
e1 = {std::move(t)};
362+
assert(e1.value().used_move1);
360363
}
361364
}
362365

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ void test_implicit()
8484
using T = TestTypes::TestType;
8585
assert(implicit_conversion<T>(3, T(3)));
8686
}
87+
{
88+
using T = TestTypes::TestType;
89+
optional<T> opt({3});
90+
assert(opt && *opt == static_cast<T>(3));
91+
}
8792
{
8893
using O = optional<ImplicitAny>;
8994
static_assert(!test_convertible<O, std::in_place_t>(), "");
@@ -132,15 +137,6 @@ void test_explicit() {
132137
assert(T::copy_constructed == 0);
133138
assert(t.value().value == 42);
134139
}
135-
T::reset();
136-
{
137-
optional<T> t{43};
138-
assert(T::alive == 1);
139-
assert(T::value_constructed == 1);
140-
assert(T::move_constructed == 0);
141-
assert(T::copy_constructed == 0);
142-
assert(t.value().value == 43);
143-
}
144140
assert(T::alive == 0);
145141
}
146142
#ifndef TEST_HAS_NO_EXCEPTIONS

libcxx/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ struct X
4040
{return x.i_ == y.i_;}
4141
};
4242

43+
struct Z {
44+
int i_, j_;
45+
constexpr Z(int i, int j) : i_(i), j_(j) {}
46+
friend constexpr bool operator==(const Z& z1, const Z& z2) { return z1.i_ == z2.i_ && z1.j_ == z2.j_; }
47+
};
48+
4349
constexpr int test()
4450
{
4551
{
@@ -69,6 +75,11 @@ constexpr int test()
6975
assert(std::move(opt).value_or({Y(3)}) == 4);
7076
assert(!opt);
7177
}
78+
{
79+
optional<Z> opt;
80+
assert((std::move(opt).value_or({2, 3}) == Z{2, 3}));
81+
assert(!opt);
82+
}
7283
return 0;
7384
}
7485

0 commit comments

Comments
 (0)