no message
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@67 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
34baf93ed8
commit
44d1bc8ebf
21 changed files with 336 additions and 97 deletions
|
@ -1,13 +1,19 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// The Loki Library
|
// The Loki Library
|
||||||
// Data Generator by Shannon Barber
|
// Data Generator by Mr. Shannon Barber
|
||||||
// This code DOES NOT accompany the book:
|
// This code DOES NOT accompany the book:
|
||||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
//
|
//
|
||||||
// Code covered by the MIT License
|
// Code covered by the MIT License
|
||||||
|
//
|
||||||
|
// The author makes no representations about the suitability of this software
|
||||||
|
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Last update: Oct 10, 2002
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#include "TypeList.h"
|
#include "TypeList.h"
|
||||||
|
|
||||||
//MSVC7 version
|
//MSVC7 version
|
||||||
|
@ -95,7 +101,12 @@ namespace Loki
|
||||||
void operator()(II ii)
|
void operator()(II ii)
|
||||||
{
|
{
|
||||||
genfunc_t gen;
|
genfunc_t gen;
|
||||||
|
//warning C4267: 'argument' : conversion from 'size_t' to 'const std::_Vbase', possible loss of data
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4267)
|
||||||
|
//TODOSGB
|
||||||
*ii = gen();
|
*ii = gen();
|
||||||
|
#pragma warning(pop)
|
||||||
++ii;
|
++ii;
|
||||||
}
|
}
|
||||||
template<class II, class P1>
|
template<class II, class P1>
|
||||||
|
@ -201,7 +212,7 @@ namespace Loki
|
||||||
//UnitFunc is really a template-template parameter, but MSVC7
|
//UnitFunc is really a template-template parameter, but MSVC7
|
||||||
// chokes on the correct defintion. Oddly enough, it works correctly
|
// chokes on the correct defintion. Oddly enough, it works correctly
|
||||||
// with the 'undecorated' template parameter declaraion!
|
// with the 'undecorated' template parameter declaraion!
|
||||||
//template <typename> class UnitFunc
|
//template <class> class UnitFunc
|
||||||
template<typename Types, class UnitFunc, typename II>
|
template<typename Types, class UnitFunc, typename II>
|
||||||
void iterate_types(II ii)
|
void iterate_types(II ii)
|
||||||
{
|
{
|
||||||
|
@ -215,5 +226,6 @@ namespace Loki
|
||||||
// Change log:
|
// Change log:
|
||||||
// Aug 17, 2002: Ported to MSVC7 by Rani Sharoni
|
// Aug 17, 2002: Ported to MSVC7 by Rani Sharoni
|
||||||
// Aug 18, 2002: Removed ctor(II), replaced with operator(II) Shannon Barber
|
// Aug 18, 2002: Removed ctor(II), replaced with operator(II) Shannon Barber
|
||||||
|
// Oct 10, 2002: Changed II (insertion iterator) from pass-by-reference to pass-by-value
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Last update: May 19, 2002
|
// Last update: Oct 10, 2002
|
||||||
|
|
||||||
#ifndef FUNCTOR_INC_
|
#ifndef FUNCTOR_INC_
|
||||||
#define FUNCTOR_INC_
|
#define FUNCTOR_INC_
|
||||||
|
@ -61,7 +61,10 @@ namespace Loki
|
||||||
{
|
{
|
||||||
if (!pObj) return 0;
|
if (!pObj) return 0;
|
||||||
U* pClone = static_cast<U*>(pObj->DoClone());
|
U* pClone = static_cast<U*>(pObj->DoClone());
|
||||||
assert(typeid(*pClone) == typeid(*pObj));
|
//MSVC7: warning C4541: 'typeid' used on polymorphic type 'Loki::FunctorImpl<R,TList,ThreadingModel>' with /GR-; unpredictable behavior may result
|
||||||
|
//I rather RTTI wasn't a requirement
|
||||||
|
//TODOSGB find another way
|
||||||
|
//assert(typeid(*pClone) == typeid(*pObj));
|
||||||
return pClone;
|
return pClone;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1342,6 +1345,7 @@ namespace Loki
|
||||||
// Change log:
|
// Change log:
|
||||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
||||||
// May 10, 2002: ported by Rani Sharoni to VC7 (RTM - 9466)
|
// May 10, 2002: ported by Rani Sharoni to VC7 (RTM - 9466)
|
||||||
|
// Oct 10, 2002: removed rtti/polymorphic use of typeid
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#endif // FUNCTOR_INC_
|
#endif // FUNCTOR_INC_
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace Loki
|
||||||
typedef typename In<flag>::Result Result;
|
typedef typename In<flag>::Result Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template SameType
|
// class template SameType
|
||||||
// Return true iff two given types are the same
|
// Return true iff two given types are the same
|
||||||
|
@ -98,6 +98,7 @@ namespace Loki
|
||||||
public:
|
public:
|
||||||
enum { value = In<U>::value };
|
enum { value = In<U>::value };
|
||||||
};
|
};
|
||||||
|
//*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)
|
// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)
|
||||||
|
@ -183,6 +184,38 @@ namespace Loki
|
||||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// class template SuperSubclass
|
||||||
|
// Invocation: SuperSubclass<B, D>::value where B and D are types.
|
||||||
|
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||||
|
// same type.
|
||||||
|
//
|
||||||
|
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
struct SuperSubclass
|
||||||
|
{
|
||||||
|
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||||
|
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// class template SuperSubclassStrict
|
||||||
|
// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
|
||||||
|
// Returns true if B is a public base of D.
|
||||||
|
//
|
||||||
|
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class T,class U>
|
||||||
|
struct SuperSubclassStrict
|
||||||
|
{
|
||||||
|
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||||
|
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
|
||||||
|
!::Loki::Conversion<const volatile T*, const volatile U*>::sameType) };
|
||||||
|
};
|
||||||
|
|
||||||
#define SUPERSUBCLASS(T, U) \
|
#define SUPERSUBCLASS(T, U) \
|
||||||
(::Loki::Conversion<const volatile U*, const volatile T*>::exists && \
|
(::Loki::Conversion<const volatile U*, const volatile T*>::exists && \
|
||||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
|
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
|
||||||
|
@ -205,6 +238,7 @@ namespace Loki
|
||||||
// Change log:
|
// Change log:
|
||||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
||||||
// May 10, 2002: ported by Rani Sharoni to VC7 (RTM - 9466)
|
// May 10, 2002: ported by Rani Sharoni to VC7 (RTM - 9466)
|
||||||
|
// Oct 10, 2002: Commented SameType template (not a loki-template - yet)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#endif // TYPEMANIP_INC_
|
#endif // TYPEMANIP_INC_
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
// Last update: May 19, 2002
|
// Last update: May 19, 2002
|
||||||
|
|
||||||
|
//TODOSGB None of the parameter types are defined inside of TypeTraits, e.g. PointeeType, ReferredType, etc...
|
||||||
|
|
||||||
#ifndef TYPETRAITS_INC_
|
#ifndef TYPETRAITS_INC_
|
||||||
#define TYPETRAITS_INC_
|
#define TYPETRAITS_INC_
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,14 @@
|
||||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||||
//
|
//
|
||||||
// Code covered by the MIT License
|
// Code covered by the MIT License
|
||||||
|
// The author makes no representations about the suitability of this software
|
||||||
|
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Last update: Oct 10, 2002
|
||||||
|
|
||||||
|
#ifndef DATAGENERATORS_H
|
||||||
|
#define DATAGENERATORS_H
|
||||||
#include "TypeList.h"
|
#include "TypeList.h"
|
||||||
|
|
||||||
//Reference version
|
//Reference version
|
||||||
|
@ -93,7 +99,7 @@ namespace Loki
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Types, template <typename> class UnitFunc, typename II>
|
template<typename Types, template <class> class UnitFunc, typename II>
|
||||||
void iterate_types(II ii)
|
void iterate_types(II ii)
|
||||||
{
|
{
|
||||||
Loki::TL::IterateTypes<Types, UnitFunc> it;
|
Loki::TL::IterateTypes<Types, UnitFunc> it;
|
||||||
|
@ -102,6 +108,7 @@ namespace Loki
|
||||||
}//ns TL
|
}//ns TL
|
||||||
}//ns Loki
|
}//ns Loki
|
||||||
|
|
||||||
|
#endif //DATAGENERATORS_H
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Change log:
|
// Change log:
|
||||||
// 9/20/02 Named changed from GenData to IterateTypes
|
// 9/20/02 Named changed from GenData to IterateTypes
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <loki/AbstractFactory.h>
|
#include <loki/AbstractFactory.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// AbstractFactoryTest
|
// AbstractFactoryTest
|
||||||
|
@ -64,7 +63,7 @@ public:
|
||||||
|
|
||||||
s = easyFactory->Create<Soldier>();
|
s = easyFactory->Create<Soldier>();
|
||||||
|
|
||||||
r=typeid(*s)==typeid(SillySoldier);
|
r= !!(typeid(*s)==typeid(SillySoldier)); //SGB !! eliminates bool-to-int performance warning
|
||||||
|
|
||||||
delete s;
|
delete s;
|
||||||
|
|
||||||
|
@ -82,6 +81,6 @@ public:
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
};
|
} abstractFactoryTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -187,7 +187,7 @@ void test_vect1()
|
||||||
assert(vec11.size() == 0);
|
assert(vec11.size() == 0);
|
||||||
|
|
||||||
check_insert1(vec11);
|
check_insert1(vec11);
|
||||||
unsigned size1 = vec11.size();
|
size_t size1 = vec11.size();
|
||||||
assert(size1);
|
assert(size1);
|
||||||
|
|
||||||
test_vect1_t vec12(vec11.begin(), vec11.end());
|
test_vect1_t vec12(vec11.begin(), vec11.end());
|
||||||
|
@ -244,7 +244,7 @@ void test_vect2()
|
||||||
assert(it->second == 3);
|
assert(it->second == 3);
|
||||||
|
|
||||||
std::pair<test_vect2_t::iterator, bool> aux = vec21.insert(std::make_pair("xyz", 99));
|
std::pair<test_vect2_t::iterator, bool> aux = vec21.insert(std::make_pair("xyz", 99));
|
||||||
assert(aux.first);
|
assert(aux.first); //TODOSGB was second meant, not first? MSVC7 dies here (more errors follow)
|
||||||
it = vec21.find("xyz");
|
it = vec21.find("xyz");
|
||||||
assert(it->second == 3);
|
assert(it->second == 3);
|
||||||
|
|
||||||
|
@ -353,6 +353,6 @@ public:
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
};
|
} assocVectorTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,14 +6,6 @@
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <Loki/DataGenerators.h>
|
#include <Loki/DataGenerators.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T& remove_const(const T& t)
|
|
||||||
{
|
|
||||||
return const_cast<T&>(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct DataGeneratorsTest : public Test
|
struct DataGeneratorsTest : public Test
|
||||||
{
|
{
|
||||||
|
@ -38,7 +30,7 @@ struct DataGeneratorsTest : public Test
|
||||||
names.reserve(n);
|
names.reserve(n);
|
||||||
//Some fascist decided that all temporaries should be const.
|
//Some fascist decided that all temporaries should be const.
|
||||||
//The following line of code stupidity is a direct result of the half-baked idea
|
//The following line of code stupidity is a direct result of the half-baked idea
|
||||||
iterate_types<char_types, name_from_type>(remove_const(std::back_inserter(names)));
|
iterate_types<char_types, nameof_type>(std::back_inserter(names));
|
||||||
b = names.size() == n;
|
b = names.size() == n;
|
||||||
testAssert("iterate_types - Check Length", b, result);
|
testAssert("iterate_types - Check Length", b, result);
|
||||||
|
|
||||||
|
@ -48,7 +40,7 @@ struct DataGeneratorsTest : public Test
|
||||||
short,
|
short,
|
||||||
int,
|
int,
|
||||||
double>::Result some_types;
|
double>::Result some_types;
|
||||||
iterate_types<some_types, sizeof_type>(remove_const(std::back_inserter(sizes)));
|
iterate_types<some_types, sizeof_type>(std::back_inserter(sizes));
|
||||||
size_t apriori_size[] = {sizeof(char), sizeof(short), sizeof(int), sizeof(double)};
|
size_t apriori_size[] = {sizeof(char), sizeof(short), sizeof(int), sizeof(double)};
|
||||||
b = true;
|
b = true;
|
||||||
for(int i=0; i<n; ++i)
|
for(int i=0; i<n; ++i)
|
||||||
|
@ -65,6 +57,6 @@ struct DataGeneratorsTest : public Test
|
||||||
b = sizes.size() == 0;
|
b = sizes.size() == 0;
|
||||||
testAssert("iterate_types - Degenerate Case 2 - NullType", b, result);
|
testAssert("iterate_types - Degenerate Case 2 - NullType", b, result);
|
||||||
}
|
}
|
||||||
};
|
} datageneratorsTest;
|
||||||
|
|
||||||
#endif //DATAGENERATORSTEST_H
|
#endif //DATAGENERATORSTEST_H
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define FACTORYTEST_H
|
#define FACTORYTEST_H
|
||||||
|
|
||||||
#include <loki/Factory.h>
|
#include <loki/Factory.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// FactoryTest
|
// FactoryTest
|
||||||
|
@ -142,6 +141,6 @@ public:
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
};
|
} factoryTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define FUNCTORTEST_H
|
#define FUNCTORTEST_H
|
||||||
|
|
||||||
#include <loki/Functor.h>
|
#include <loki/Functor.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// FunctorTest
|
// FunctorTest
|
||||||
|
@ -102,8 +101,12 @@ private:
|
||||||
result=true;
|
result=true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
} functorTest;
|
||||||
|
|
||||||
bool FunctorTest::testResult;
|
bool FunctorTest::testResult;
|
||||||
|
|
||||||
|
#ifndef SMALLOBJ_CPP
|
||||||
|
# define SMALLOBJ_CPP
|
||||||
|
# include "../../SmallObj.cpp"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
//#include "AbstractFactoryTest.h"
|
//#include "AbstractFactoryTest.h"
|
||||||
//#include "AssocVectorTest.h"
|
//#include "AssocVectorTest.h"
|
||||||
//#include "FunctorTest.h"
|
//#include "FunctorTest.h"
|
||||||
|
#include "DataGeneratorsTest.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// LokiTest
|
// LokiTest
|
||||||
|
@ -56,6 +57,7 @@ private:
|
||||||
// tests.add(abstractFactoryTest);
|
// tests.add(abstractFactoryTest);
|
||||||
// tests.add(assocVectorTest);
|
// tests.add(assocVectorTest);
|
||||||
// tests.add(functorTest);
|
// tests.add(functorTest);
|
||||||
|
tests.add(datageneratorTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -72,6 +74,7 @@ private:
|
||||||
// AbstractFactoryTest abstractFactoryTest;
|
// AbstractFactoryTest abstractFactoryTest;
|
||||||
// AssocVectorTest assocVectorTest;
|
// AssocVectorTest assocVectorTest;
|
||||||
// FunctorTest functorTest;
|
// FunctorTest functorTest;
|
||||||
|
DataGeneratorsTest datageneratorTest;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
21
tools/RegressionTest/MSVCUnitTest.sln
Normal file
21
tools/RegressionTest/MSVCUnitTest.sln
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "MSVCUnitTest.vcproj", "{79729949-F144-4098-BFE9-B6320E6AC3F6}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
|
ConfigName.0 = Debug
|
||||||
|
ConfigName.1 = Release
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectDependencies) = postSolution
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
|
{79729949-F144-4098-BFE9-B6320E6AC3F6}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{79729949-F144-4098-BFE9-B6320E6AC3F6}.Debug.Build.0 = Debug|Win32
|
||||||
|
{79729949-F144-4098-BFE9-B6320E6AC3F6}.Release.ActiveCfg = Release|Win32
|
||||||
|
{79729949-F144-4098-BFE9-B6320E6AC3F6}.Release.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
121
tools/RegressionTest/MSVCUnitTest.vcproj
Normal file
121
tools/RegressionTest/MSVCUnitTest.vcproj
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.00"
|
||||||
|
Name="UnitTest"
|
||||||
|
ProjectGUID="{79729949-F144-4098-BFE9-B6320E6AC3F6}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="Debug"
|
||||||
|
IntermediateDirectory="Debug"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="5"
|
||||||
|
BufferSecurityCheck="TRUE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
RuntimeTypeInfo="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/UnitTest.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/UnitTest.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="Release"
|
||||||
|
IntermediateDirectory="Release"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
InlineFunctionExpansion="1"
|
||||||
|
OmitFramePointers="TRUE"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
|
StringPooling="TRUE"
|
||||||
|
RuntimeLibrary="4"
|
||||||
|
EnableFunctionLevelLinking="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/UnitTest.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<Files>
|
||||||
|
<File
|
||||||
|
RelativePath="LokiTest.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Test.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\MSVC\1300\TypeTraits.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="UnitTest.h">
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
|
@ -76,7 +76,7 @@ namespace
|
||||||
typedef SingletonHolder<MyClass<19>, CreateStatic, SingletonWithLongevity, SingleThreaded> t19;
|
typedef SingletonHolder<MyClass<19>, CreateStatic, SingletonWithLongevity, SingleThreaded> t19;
|
||||||
typedef SingletonHolder<MyClass<20>, CreateStatic, NoDestroy, SingleThreaded> t20;
|
typedef SingletonHolder<MyClass<20>, CreateStatic, NoDestroy, SingleThreaded> t20;
|
||||||
|
|
||||||
#if !__INTEL_COMPILER && !__GNUC__
|
#if !__INTEL_COMPILER && !__GNUC__ && !_MSC_VER
|
||||||
|
|
||||||
typedef SingletonHolder<MyClass<5>, CreateUsingNew, DefaultLifetime, ClassLevelLockable> t5;
|
typedef SingletonHolder<MyClass<5>, CreateUsingNew, DefaultLifetime, ClassLevelLockable> t5;
|
||||||
typedef SingletonHolder<MyClass<6>, CreateUsingNew, PhoenixSingleton, ClassLevelLockable> t6;
|
typedef SingletonHolder<MyClass<6>, CreateUsingNew, PhoenixSingleton, ClassLevelLockable> t6;
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
MAKE_TEST(t19)
|
MAKE_TEST(t19)
|
||||||
MAKE_TEST(t20)
|
MAKE_TEST(t20)
|
||||||
|
|
||||||
#if !__INTEL_COMPILER && !__GNUC__
|
#if !__INTEL_COMPILER && !__GNUC__ && !_MSC_VER
|
||||||
|
|
||||||
MAKE_TEST(t5)
|
MAKE_TEST(t5)
|
||||||
MAKE_TEST(t6)
|
MAKE_TEST(t6)
|
||||||
|
@ -152,6 +152,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool singletonTest;
|
bool singletonTest;
|
||||||
};
|
} singletonTest;
|
||||||
|
|
||||||
|
#include "../../Singleton.cpp"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,7 +144,7 @@ private:
|
||||||
|
|
||||||
for (int j = 0; j < 1024; ++j)
|
for (int j = 0; j < 1024; ++j)
|
||||||
{
|
{
|
||||||
int pos = std::rand() % vec.size();
|
size_t pos = std::rand() % vec.size();
|
||||||
|
|
||||||
delete vec[pos];
|
delete vec[pos];
|
||||||
|
|
||||||
|
@ -159,6 +159,10 @@ private:
|
||||||
vec.pop_back();
|
vec.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} smallObjectTest;
|
||||||
|
|
||||||
|
#ifndef SMALLOBJ_CPP
|
||||||
|
# define SMALLOBJ_CPP
|
||||||
|
# include "../../SmallObj.cpp"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -285,6 +285,6 @@ private:
|
||||||
typedef SmartPtr<TestClass, DestructiveCopy, DisallowConversion, NoCheck, DefaultSPStorage> p101;
|
typedef SmartPtr<TestClass, DestructiveCopy, DisallowConversion, NoCheck, DefaultSPStorage> p101;
|
||||||
typedef SmartPtr<TestClass, NoCopy, DisallowConversion, NoCheck, DefaultSPStorage> p102;
|
typedef SmartPtr<TestClass, NoCopy, DisallowConversion, NoCheck, DefaultSPStorage> p102;
|
||||||
typedef SmartPtr<TestClass, NoCopy, DisallowConversion, NoCheck, DefaultSPStorage> p103;
|
typedef SmartPtr<TestClass, NoCopy, DisallowConversion, NoCheck, DefaultSPStorage> p103;
|
||||||
};
|
} smartPtrTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,23 +9,86 @@
|
||||||
//
|
//
|
||||||
// This software is provided "as is" without express or implied warranty.
|
// This software is provided "as is" without express or implied warranty.
|
||||||
//
|
//
|
||||||
// Last update: September 16, 2002
|
// Last update: October 10, 2002
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
# pragma warning(disable: 111 193 304 383 444 488 981 1418)
|
# pragma warning(disable: 111 193 304 383 444 488 981 1418)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "LokiTest.h"
|
//Some platforms might have difficulty with this
|
||||||
|
//Need to ifdef around those cases.
|
||||||
|
//TODOSGB
|
||||||
|
|
||||||
|
#include "UnitTest.h"
|
||||||
|
|
||||||
|
//static variable defintion, do not remove
|
||||||
|
Test::tests_type Test::tests;
|
||||||
|
|
||||||
|
|
||||||
|
//Merely comment out any of the following headers to
|
||||||
|
// prevent thier execution during the test.
|
||||||
|
//A pluggable-factory-like method is used to
|
||||||
|
// auto-register the test, so all that is needed
|
||||||
|
// is the header inclusion to execute the correspond
|
||||||
|
// unit test.
|
||||||
|
|
||||||
|
#include "TypelistTest.h"
|
||||||
|
#include "TypeManipTest.h"
|
||||||
|
#include "TypeTraitsTest.h"
|
||||||
|
#include "SmallObjectTest.h"
|
||||||
|
#include "SingletonTest.h"
|
||||||
|
#include "SmartPtrTest.h"
|
||||||
|
#include "FactoryTest.h"
|
||||||
|
#include "AbstractFactoryTest.h"
|
||||||
|
#include "AssocVectorTest.h"
|
||||||
|
#include "FunctorTest.h"
|
||||||
|
#include "DataGeneratorsTest.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AP - All Pass
|
||||||
|
* FC - Fails to Compile
|
||||||
|
* ? - Unknown/Not Tested/Not Recorded
|
||||||
|
*
|
||||||
|
* TypelistTest TypeManipTest TypeTraitsTest SmallObjectTest SingletonTest
|
||||||
|
* gcc 2.95.3 ? ? ? ? ?
|
||||||
|
* gcc 3.2 AP AP AP AP P #ifdef?
|
||||||
|
* MSVC 6 ? ? ? ? ?
|
||||||
|
* MSVC 7 DerivedToFront Conversion FC AP P #ifdef?
|
||||||
|
* Intel ? ? ? ? ? ?
|
||||||
|
* BCB 5.5? ? ? ? ? ?
|
||||||
|
* CW 6.0 DerivedToFront ? ? ? ?
|
||||||
|
*
|
||||||
|
* SmartPtrTest FactoryTest AbstractFactoryTest AssocVectorTest FunctorTest
|
||||||
|
* gcc 2.95.3 ? ? ? ? ?
|
||||||
|
* gcc 3.2 FC AP AP FC AP
|
||||||
|
* MSVC 6 ? ? ? ? ?
|
||||||
|
* MSVC 7 FC AP AP FC AP
|
||||||
|
* Intel ? ? ? ? ? ?
|
||||||
|
* BCB 5.5? ? ? ? ? ?
|
||||||
|
* CW 6.0 ? ? ? ? ?
|
||||||
|
*
|
||||||
|
* DataGeneratorsTest
|
||||||
|
* gcc 2.95.3 ?
|
||||||
|
* gcc 3.2 AP
|
||||||
|
* MSVC 6 ?
|
||||||
|
* MSVC 7 AP
|
||||||
|
* Intel ? ?
|
||||||
|
* BCB 5.5? ?
|
||||||
|
* CW 6.0 ?
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
LokiTest test;
|
|
||||||
|
|
||||||
const int result=test.result();
|
int result = Test::run("Loki Unit Test");
|
||||||
|
|
||||||
#if __BORLANDC__ || __GNUC__
|
#if __BORLANDC__
|
||||||
while(true); // Stop console window from closing if run from IDE.
|
while(true); // Stop console window from closing if run from IDE.
|
||||||
|
#elif _MSC_VER || __GNUC__
|
||||||
|
system("pause");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -114,6 +114,6 @@ private:
|
||||||
struct Base { char c; };
|
struct Base { char c; };
|
||||||
struct Derived1 : Base { char c; };
|
struct Derived1 : Base { char c; };
|
||||||
struct Derived2 : Derived1 { char c; };
|
struct Derived2 : Derived1 { char c; };
|
||||||
};
|
} typeManipTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define TYPETRAITSTEST_H
|
#define TYPETRAITSTEST_H
|
||||||
|
|
||||||
#include <Loki/TypeTraits.h>
|
#include <Loki/TypeTraits.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TypeTraitsTest
|
// TypeTraitsTest
|
||||||
|
@ -111,6 +110,6 @@ public:
|
||||||
|
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
};
|
} typeTraitsTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define TYPELISTTEST_H
|
#define TYPELISTTEST_H
|
||||||
|
|
||||||
#include <Loki/Typelist.h>
|
#include <Loki/Typelist.h>
|
||||||
#include "UnitTest.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TypelistTest
|
// TypelistTest
|
||||||
|
@ -185,6 +184,5 @@ private:
|
||||||
struct Base { char c; };
|
struct Base { char c; };
|
||||||
struct Derived1 : Base { char c; };
|
struct Derived1 : Base { char c; };
|
||||||
struct Derived2 : Derived1 { char c; };
|
struct Derived2 : Derived1 { char c; };
|
||||||
};
|
} typelistTest;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SameType
|
// SameType
|
||||||
|
@ -28,6 +29,8 @@
|
||||||
|
|
||||||
// Rani Sharoni's SameType
|
// Rani Sharoni's SameType
|
||||||
|
|
||||||
|
//This is non-standard code, you are not allowed to
|
||||||
|
// specialize a nested template
|
||||||
template<class T1,class T2>
|
template<class T1,class T2>
|
||||||
struct SameType
|
struct SameType
|
||||||
{
|
{
|
||||||
|
@ -49,13 +52,13 @@ public:
|
||||||
template<class T1,class T2>
|
template<class T1,class T2>
|
||||||
struct SameType
|
struct SameType
|
||||||
{
|
{
|
||||||
static const bool value=false;
|
static const bool value=false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct SameType<T,T>
|
struct SameType<T,T>
|
||||||
{
|
{
|
||||||
static const bool value=true;
|
static const bool value=true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,14 +78,21 @@ public:
|
||||||
int notSupported;
|
int notSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Test
|
// Test
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
{
|
{
|
||||||
|
typedef std::vector<Test*> tests_type;
|
||||||
|
static tests_type tests;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Test(const std::string &n) : name(n) {}
|
explicit Test(const std::string &n) : name(n)
|
||||||
|
{
|
||||||
|
Test::tests.push_back(this);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void execute(TestResult &) =0;
|
virtual void execute(TestResult &) =0;
|
||||||
|
|
||||||
|
@ -135,58 +145,22 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::string name;
|
const std::string name;
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// TestSuite
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TestSuite : public Test
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef std::vector<Test *> TestList;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TestSuite(const std::string &name =emptyStr()) : Test(name) {}
|
static int run(const std::string &title)
|
||||||
|
|
||||||
void add(Test &test)
|
|
||||||
{
|
|
||||||
tests.push_back(&test);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void execute(TestResult &result)
|
|
||||||
{
|
|
||||||
printName(result);
|
|
||||||
|
|
||||||
if(name.length()!=0)
|
|
||||||
result.pos+=2;
|
|
||||||
|
|
||||||
for(TestList::iterator i=tests.begin();i!=tests.end();++i)
|
|
||||||
(*i)->execute(result);
|
|
||||||
|
|
||||||
if(name.length()!=0)
|
|
||||||
result.pos-=2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
TestList tests;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// UnitTest
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class UnitTest
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int run(const std::string &title,TestSuite &tests) const
|
|
||||||
{
|
{
|
||||||
std::cout << title << std::string(Test::offset-title.length(),' ') << "Result\n";
|
std::cout << title << std::string(Test::offset-title.length(),' ') << "Result\n";
|
||||||
std::cout << std::string(76,'-') << '\n';
|
std::cout << std::string(76,'-') << '\n';
|
||||||
|
|
||||||
TestResult testResult;
|
TestResult testResult;
|
||||||
|
|
||||||
tests.execute(testResult);
|
tests_type::iterator it;
|
||||||
|
tests_type::const_iterator itEnd = Test::tests.end();
|
||||||
|
for(it=Test::tests.begin(); it!=itEnd; ++it)
|
||||||
|
{
|
||||||
|
Test* test = *it;
|
||||||
|
test->execute(testResult);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << std::string(76,'-') << '\n';
|
std::cout << std::string(76,'-') << '\n';
|
||||||
|
|
||||||
|
@ -203,6 +177,8 @@ public:
|
||||||
|
|
||||||
return testResult.failed;
|
return testResult.failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue