mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
9553ecfe01
We were forgetting to clear m_has_value in the Optional being moved from when using operator=(Optional&&).
30 lines
568 B
C++
30 lines
568 B
C++
#include <AK/TestSuite.h>
|
|
|
|
#include <AK/AKString.h>
|
|
#include <AK/Optional.h>
|
|
|
|
TEST_CASE(basic_optional)
|
|
{
|
|
Optional<int> x;
|
|
EXPECT_EQ(x.has_value(), false);
|
|
x = 3;
|
|
EXPECT_EQ(x.has_value(), true);
|
|
EXPECT_EQ(x.value(), 3);
|
|
}
|
|
|
|
TEST_CASE(move_optional)
|
|
{
|
|
Optional<int> x;
|
|
EXPECT_EQ(x.has_value(), false);
|
|
x = 3;
|
|
EXPECT_EQ(x.has_value(), true);
|
|
EXPECT_EQ(x.value(), 3);
|
|
|
|
Optional<int> y;
|
|
y = move(x);
|
|
EXPECT_EQ(y.has_value(), true);
|
|
EXPECT_EQ(y.value(), 3);
|
|
EXPECT_EQ(x.has_value(), false);
|
|
}
|
|
|
|
TEST_MAIN(Optional)
|