From 53e882ca3e095ef399ccb410804d57b5ad66e804 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 24 Jun 2009 06:01:14 +0200 Subject: [PATCH] WIP should also cover the detection of empty functors --- .../proc/control/command-basic-test.cpp | 2 ++ tests/lib/meta/function-erasure-test.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/components/proc/control/command-basic-test.cpp b/tests/components/proc/control/command-basic-test.cpp index a47209ad7..76ccc20a1 100644 --- a/tests/components/proc/control/command-basic-test.cpp +++ b/tests/components/proc/control/command-basic-test.cpp @@ -44,6 +44,7 @@ #include //#include #include +#include #include using std::tr1::bind; @@ -54,6 +55,7 @@ using std::tr1::function; using lumiera::Time; //using util::contains; using std::string; +using std::rand; using std::cout; using std::endl; diff --git a/tests/lib/meta/function-erasure-test.cpp b/tests/lib/meta/function-erasure-test.cpp index be7d6a8ae..16024e5c6 100644 --- a/tests/lib/meta/function-erasure-test.cpp +++ b/tests/lib/meta/function-erasure-test.cpp @@ -76,6 +76,10 @@ namespace test { check_FunctPtrHolder(Efp(testFunc),Efp(&testFunc), Efp(returnIt)); check_VoidPtrHolder(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt)); + + detect_unboundFunctor(Efun(testFunc), Efun(getterFunc), Efun(membFunc)); + detect_unboundFunctor(Efp(testFunc),Efp(&testFunc), Efp(returnIt)); + detect_unboundFunctor(Evoid(testFunc),Evoid(&testFunc),Evoid(returnIt)); } void @@ -193,6 +197,21 @@ namespace test { //(*bad_fun) (11, 'x'); // The compiler would accept this line! } // likely to result in heap corruption or SEGV + + + template + void + detect_unboundFunctor(HOL h1, HOL h2, HOL h3) + { + // fabricate an unbound functor... + function emptyFunc; + HOL emptyHolder (emptyFunc); + ASSERT (!emptyHolder); + ASSERT ( h1 ); + ASSERT ( h2 ); + ASSERT ( h3 ); + } + };