util: Add Expected::swap()

This commit is contained in:
MarcoFalke
2025-12-11 11:02:33 +01:00
parent fabb47e4e3
commit faa59b3679
2 changed files with 11 additions and 0 deletions

View File

@@ -122,4 +122,13 @@ BOOST_AUTO_TEST_CASE(unexpected_error_accessors)
BOOST_CHECK_EQUAL(*moved, -2);
}
BOOST_AUTO_TEST_CASE(expected_swap)
{
Expected<const char*, std::unique_ptr<int>> a{Unexpected{std::make_unique<int>(-1)}};
Expected<const char*, std::unique_ptr<int>> b{"good"};
a.swap(b);
BOOST_CHECK_EQUAL(a.value(), "good");
BOOST_CHECK_EQUAL(*b.error(), -1);
}
BOOST_AUTO_TEST_SUITE_END()