Skip to content

Commit

Permalink
enhance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achabense committed Aug 15, 2023
1 parent da3f334 commit 798e89c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private:
}
}

void _Reset_and_move_from(any _That) noexcept {
void _Reset_and_move_from(any _That) noexcept { // intentionally pass by value
reset();
_Move_from(_That);
}
Expand Down
20 changes: 20 additions & 0 deletions tests/std/tests/P0220R1_any/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,24 +2571,44 @@ namespace msvc {
any a;
a = std::move(a);
assertEmpty(a);

a = std::make_any<any>();
any* inner_any = any_cast<any>(&a);
a = std::move(*inner_any);
assertEmpty(a);
}
{
// small
any a{small{42}};
a = std::move(a);
assertContains<small>(a, 42);

a = std::make_any<any>(small{42});
any* inner_any = any_cast<any>(&a);
a = std::move(*inner_any);
assertContains<small>(a, 42);
}
{
// large
any a{large{42}};
a = std::move(a);
assertContains<large>(a, 42);

a = std::make_any<any>(large{42});
any* inner_any = any_cast<any>(&a);
a = std::move(*inner_any);
assertContains<large>(a, 42);
}
{
// trivial
any a{int{42}};
a = std::move(a);
assertContains<int>(a, 42);

a = std::make_any<any>(int{42});
any* inner_any = any_cast<any>(&a);
a = std::move(*inner_any);
assertContains<int>(a, 42);
}
}
#ifdef __clang__
Expand Down

0 comments on commit 798e89c

Please sign in to comment.