no message
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@70 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
52020f94e0
commit
08bd05c8c4
27 changed files with 2717 additions and 1276 deletions
|
@ -25,26 +25,26 @@
|
|||
// SameType
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if _MSC_VER && !__INTEL_COMPILER && !__MWERKS__
|
||||
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
|
||||
|
||||
// Rani Sharoni's SameType
|
||||
//
|
||||
// Non-conforming workaround for MSVC
|
||||
|
||||
//This is non-standard code, you are not allowed to
|
||||
// specialize a nested template
|
||||
template<class T1,class T2>
|
||||
struct SameType
|
||||
{
|
||||
private:
|
||||
template<class>
|
||||
struct In
|
||||
{ enum { value = false }; };
|
||||
template<class>
|
||||
struct In
|
||||
{ enum { value = false }; };
|
||||
|
||||
template<>
|
||||
struct In<T1>
|
||||
{ enum { value = true }; };
|
||||
template<>
|
||||
struct In<T1>
|
||||
{ enum { value = true }; };
|
||||
|
||||
public:
|
||||
enum { value = In<T2>::value };
|
||||
enum { value = In<T2>::value };
|
||||
};
|
||||
|
||||
#else
|
||||
|
@ -52,13 +52,13 @@ public:
|
|||
template<class T1,class T2>
|
||||
struct SameType
|
||||
{
|
||||
static const bool value=false;
|
||||
static const bool value=false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct SameType<T,T>
|
||||
{
|
||||
static const bool value=true;
|
||||
static const bool value=true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -70,12 +70,12 @@ struct SameType<T,T>
|
|||
class TestResult
|
||||
{
|
||||
public:
|
||||
TestResult() : pos(0),passed(0),failed(0),notSupported(0) {}
|
||||
TestResult() : pos(0),passed(0),failed(0),notSupported(0) {}
|
||||
|
||||
int pos;
|
||||
int passed;
|
||||
int failed;
|
||||
int notSupported;
|
||||
int pos;
|
||||
int passed;
|
||||
int failed;
|
||||
int notSupported;
|
||||
};
|
||||
|
||||
|
||||
|
@ -89,94 +89,94 @@ typedef std::vector<Test*> tests_type;
|
|||
static tests_type tests;
|
||||
|
||||
public:
|
||||
explicit Test(const std::string &n) : name(n)
|
||||
{
|
||||
Test::tests.push_back(this);
|
||||
}
|
||||
explicit Test(const std::string &n) : name(n)
|
||||
{
|
||||
Test::tests.push_back(this);
|
||||
}
|
||||
|
||||
virtual void execute(TestResult &) =0;
|
||||
|
||||
virtual void execute(TestResult &) =0;
|
||||
|
||||
protected:
|
||||
~Test() {}
|
||||
~Test() {}
|
||||
|
||||
void printName(const TestResult &result) const
|
||||
{
|
||||
if(name.length()!=0)
|
||||
std::cout << std::string(result.pos,' ') << name << '\n';
|
||||
}
|
||||
void printName(const TestResult &result) const
|
||||
{
|
||||
if(name.length()!=0)
|
||||
std::cout << std::string(result.pos,' ') << name << '\n';
|
||||
}
|
||||
|
||||
void testAssert(const std::string &s,bool assertion,TestResult &result,bool supported =true,
|
||||
const std::string &failStr =emptyStr())
|
||||
{
|
||||
std::string str=std::string(result.pos+2,' ')+s;
|
||||
void testAssert(const std::string &s,bool assertion,TestResult &result,bool supported =true,
|
||||
const std::string &failStr =emptyStr())
|
||||
{
|
||||
std::string str=std::string(result.pos+2,' ')+s;
|
||||
|
||||
str+=std::string(offset-str.length(),' ');
|
||||
str+=std::string(offset-str.length(),' ');
|
||||
|
||||
if(supported)
|
||||
{
|
||||
if(assertion)
|
||||
{
|
||||
std::cout << str << "Passed\n";
|
||||
if(supported)
|
||||
{
|
||||
if(assertion)
|
||||
{
|
||||
std::cout << str << "Passed\n";
|
||||
|
||||
++result.passed;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << str << (failStr==emptyStr() ? std::string("Failed") : "Failed - "+failStr) << '\n';
|
||||
++result.passed;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << str << (failStr==emptyStr() ? std::string("Failed") : "Failed - "+failStr) << '\n';
|
||||
|
||||
++result.failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << str << "Not Supported\n";
|
||||
++result.failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << str << "Not Supported\n";
|
||||
|
||||
++result.notSupported;
|
||||
}
|
||||
}
|
||||
++result.notSupported;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string emptyStr()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
static std::string emptyStr()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
public:
|
||||
enum { offset=63 };
|
||||
enum { offset=63 };
|
||||
|
||||
protected:
|
||||
const std::string name;
|
||||
|
||||
const std::string name;
|
||||
|
||||
public:
|
||||
static int run(const std::string &title)
|
||||
{
|
||||
std::cout << title << std::string(Test::offset-title.length(),' ') << "Result\n";
|
||||
std::cout << std::string(76,'-') << '\n';
|
||||
|
||||
TestResult 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';
|
||||
static int run(const std::string &title)
|
||||
{
|
||||
std::cout << title << std::string(Test::offset-title.length(),' ') << "Result\n";
|
||||
std::cout << std::string(76,'-') << '\n';
|
||||
|
||||
TestResult 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';
|
||||
|
||||
const int total=testResult.passed+testResult.failed;
|
||||
const int totalAll=total+testResult.notSupported;
|
||||
const int total=testResult.passed+testResult.failed;
|
||||
const int totalAll=total+testResult.notSupported;
|
||||
|
||||
if(total!=0)
|
||||
std::cout << "Total - " << testResult.passed << '/' << total << (total==1 ? " test, " : " tests, ")
|
||||
<< testResult.passed*100/total << "% Passed\n";
|
||||
if(total!=0)
|
||||
std::cout << "Total - " << testResult.passed << '/' << total << (total==1 ? " test, " : " tests, ")
|
||||
<< testResult.passed*100/total << "% Passed\n";
|
||||
|
||||
if(testResult.notSupported!=0)
|
||||
std::cout << "Not Supported - " << testResult.notSupported << '/' << totalAll << ", "
|
||||
<< testResult.notSupported*100/totalAll << "%\n";
|
||||
if(testResult.notSupported!=0)
|
||||
std::cout << "Not Supported - " << testResult.notSupported << '/' << totalAll << ", "
|
||||
<< testResult.notSupported*100/totalAll << "%\n";
|
||||
|
||||
return testResult.failed;
|
||||
}
|
||||
return testResult.failed;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue