WIP should also cover the detection of empty functors

This commit is contained in:
Fischlurch 2009-06-24 06:01:14 +02:00
parent 69d6bad1f4
commit 53e882ca3e
2 changed files with 21 additions and 0 deletions

View file

@ -44,6 +44,7 @@
#include <tr1/functional>
//#include <boost/format.hpp>
#include <iostream>
#include <cstdlib>
#include <string>
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;

View file

@ -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<class HOL>
void
detect_unboundFunctor(HOL h1, HOL h2, HOL h3)
{
// fabricate an unbound functor...
function<long(int,char)> emptyFunc;
HOL emptyHolder (emptyFunc);
ASSERT (!emptyHolder);
ASSERT ( h1 );
ASSERT ( h2 );
ASSERT ( h3 );
}
};