Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions orc-rt/unittests/ErrorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,31 @@ TEST(ErrorTest, ExpectedError) {
}
}

// Test that Expected<Expected<T>> works as expected.
TEST(ErrorTest, ExpectedExpected) {
{
// Test success-success case.
Expected<Expected<int>> E(Expected<int>(42), ForceExpectedSuccessValue());
EXPECT_TRUE(!!E);
cantFail(E.takeError());
auto EI = std::move(*E);
EXPECT_TRUE(!!EI);
cantFail(EI.takeError());
EXPECT_EQ(*EI, 42);
}

{
// Test "failure" success case.
Expected<Expected<int>> E(Expected<int>(make_error<StringError>("foo")),
ForceExpectedSuccessValue());
EXPECT_TRUE(!!E);
cantFail(E.takeError());
auto EI = std::move(*E);
EXPECT_FALSE(!!EI);
EXPECT_EQ(toString(EI.takeError()), "foo");
}
}

// Test that the ExitOnError utility works as expected.
TEST(ErrorTest, CantFailSuccess) {
cantFail(Error::success());
Expand Down
Loading