From 4df3a466514f83e1dd99b7e2bc8736637ddbe6cc Mon Sep 17 00:00:00 2001 From: "Vladimir Vashurkin (Alkenso)" Date: Fri, 9 Aug 2019 12:51:55 +0300 Subject: [PATCH] Updated 'AsEnum' tests to template implementation --- tests/AsEnumTest.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/AsEnumTest.cpp b/tests/AsEnumTest.cpp index d4015fe..b9e18ef 100644 --- a/tests/AsEnumTest.cpp +++ b/tests/AsEnumTest.cpp @@ -164,3 +164,39 @@ TEST(AsEnum, Switch_Default) }) .ifDefault(handler.AsStdFunction()); } + +TEST(AsEnum, Map1) +{ + const TestAsEnum value = TestAsEnum::create("test"); + + const bool vv = value.doMap() + .ifCase([] (const std::string& value) { + return true; + }) + .ifCase([] { + return false; + }) + .ifDefault([] { + return false; + }); + + EXPECT_TRUE(vv); +} + +TEST(AsEnum, Map2) +{ + const TestAsEnum value = TestAsEnum::create("test"); + + const bool vv = value.doMap() + .ifCase([] (const int& value) { + return false; + }) // AsMap + .ifCase([] { + return false; + }) // AsMap + .ifCase([] (const std::string& value) { + return true; + }); + + EXPECT_TRUE(vv); +}