Skip to content

Commit

Permalink
Updated 'AsEnum' tests to template implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Vashurkin (Alkenso) committed Aug 9, 2019
1 parent c904f13 commit 4df3a46
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/AsEnumTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,39 @@ TEST(AsEnum, Switch_Default)
})
.ifDefault(handler.AsStdFunction());
}

TEST(AsEnum, Map1)
{
const TestAsEnum value = TestAsEnum::create<TestEnum::StringOpt>("test");

const bool vv = value.doMap<bool>()
.ifCase<TestEnum::StringOpt>([] (const std::string& value) {
return true;
})
.ifCase<TestEnum::VoidOpt>([] {
return false;
})
.ifDefault([] {
return false;
});

EXPECT_TRUE(vv);
}

TEST(AsEnum, Map2)
{
const TestAsEnum value = TestAsEnum::create<TestEnum::StringOpt>("test");

const bool vv = value.doMap<bool>()
.ifCase<TestEnum::Unknown>([] (const int& value) {
return false;
}) // AsMap<Unknown>
.ifCase<TestEnum::VoidOpt>([] {
return false;
}) // AsMap<VoidOpt, Unknown>
.ifCase<TestEnum::StringOpt>([] (const std::string& value) {
return true;
});

EXPECT_TRUE(vv);
}

0 comments on commit 4df3a46

Please sign in to comment.