add friend injection test

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@708 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-10-11 10:40:47 +00:00
parent 4e99e918b9
commit 47e28751c0

View file

@ -19,6 +19,8 @@
#include "UnitTest.h" #include "UnitTest.h"
#include <loki/SmartPtr.h> #include <loki/SmartPtr.h>
#include <cassert> #include <cassert>
#include <algorithm>
#if 0 // throw assert on failed test #if 0 // throw assert on failed test
#define LOKI_assert(x) assert(x) #define LOKI_assert(x) assert(x)
@ -28,6 +30,27 @@
using namespace Loki; using namespace Loki;
// friend injection
// see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28597
class TestClass;
typedef SmartPtr<TestClass, DeepCopy, DisallowConversion, AssertCheck, DefaultSPStorage> Class;
bool Compare( const Class& a, const Class& b )
{
return true;
}
void friend_injection()
{
std::vector<Class> vec;
std::sort( vec.begin(), vec.end(), Compare );
std::nth_element( vec.begin(), vec.begin(), vec.end(), Compare );
std::search( vec.begin(), vec.end(),
vec.begin(), vec.end(), Compare );
Class a, b;
Compare( a, b );
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// SmartPtrTest // SmartPtrTest
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -63,6 +86,8 @@ public:
return new TestClass(*this); return new TestClass(*this);
} }
public: public:
static int instances; static int instances;