From 11ca89a2fd22c1ea732bf19fe87733c618147cb0 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 29 Aug 2015 19:07:51 +0200 Subject: [PATCH] cover usage of predicate in unit test --- tests/library/variant-test.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/library/variant-test.cpp b/tests/library/variant-test.cpp index f6d91d2a2..187bebac0 100644 --- a/tests/library/variant-test.cpp +++ b/tests/library/variant-test.cpp @@ -79,6 +79,7 @@ namespace test{ { createVariant(); accessVariant(); + acceptPredicate(); verifyAssignment(); } @@ -206,6 +207,35 @@ namespace test{ } + void + acceptPredicate() + { + const TestVariant v1(12); + const TestVariant v2(string("123")); + const TestVariant v3(Time::NEVER); + + struct Checker + : TestVariant::Predicate + { + bool handle (int const& i) { return i % 2; } + bool handle (string const& s) { return s.length() % 2; } + } + check; + + CHECK (12 == v1.get()); + CHECK ("123" == v2.get()); + CHECK (Time::NEVER == v3.get