Added -table option to test executables. It outputs the results as a tab

seperated table, which can be pasted into spreadsheet/google docs/etc.
This commit is contained in:
jez 2008-08-09 23:19:21 +01:00
parent 5870c68fa6
commit 07ef52f308
42 changed files with 2400 additions and 2079 deletions

View file

@ -35,7 +35,7 @@ private:
{
string_type uri = namespaceContext_.namespaceURI(prefix);
if(string_adaptor::empty(uri))
throw Arabica::XPath::UnboundNamespacePrefixException(prefix);
throw Arabica::XPath::UnboundNamespacePrefixException(string_adaptor::asStdString(prefix));
return uri;
} // namespaceURI

View file

@ -379,7 +379,7 @@ private:
++node;
if(axis == ATTRIBUTE)
{
if(prefix == string_adaptor::construct("xmlns"))
if(prefix == string_adaptor::construct_from_utf8("xmlns"))
return new FailNodeTest<string_type, string_adaptor>();
return new AttributeQNameNodeTest<string_type, string_adaptor>(uri, name);
}
@ -392,7 +392,7 @@ private:
++node;
if(axis == ATTRIBUTE)
{
if(name == string_adaptor::construct("xmlns"))
if(name == string_adaptor::construct_from_utf8("xmlns"))
return new FailNodeTest<string_type, string_adaptor>();
return new AttributeNameNodeTest<string_type, string_adaptor>(name);
}
@ -456,7 +456,7 @@ private:
string_type uri = namespaceContext.namespaceURI(prefix);
if(axis == ATTRIBUTE)
{
if(prefix == string_adaptor::construct("xmlns"))
if(prefix == string_adaptor::construct_from_utf8("xmlns"))
return new FailNodeTest<string_type, string_adaptor>();
return new AttributeQStarNodeTest<string_type, string_adaptor>(uri);
}

View file

@ -15,7 +15,9 @@ cppunit_sources = framework/CppUnitException.h \
TestRunner.cpp \
TestRunner.hpp \
textui/TextTestResult.cpp \
textui/TextTestResult.h
textui/TextTestResult.h \
textui/TableTestResult.cpp \
textui/TableTestResult.h
silly_string_sources = ../silly_string/silly_string.cpp \
../silly_string/silly_string.hpp

View file

@ -1,5 +1,6 @@
#include "TestRunner.hpp"
#include "textui/TextTestResult.h"
#include "textui/TableTestResult.hpp"
#include <iostream>
//////////////////////////////////////////
@ -23,27 +24,43 @@ using namespace std;
typedef pair<string, Test *> mapping;
typedef vector<pair<string, Test *> > mappings;
template<typename result_type>
bool run(const string& name, Test *test, bool verbose)
{
if(verbose)
cout << "Running " << name << endl;
TextTestResult result(name, verbose);
result_type result(name, verbose);
test->run (&result);
cout << result;
return result.wasSuccessful();
} // run
bool textrun(const string& name, Test *test, bool verbose)
{
return run<TextTestResult>(name, test, verbose);
} // textrun
bool tablerun(const string& name, Test *test, bool verbose)
{
return run<TableTestResult>(name, test, verbose);
} // tablerun
void printBanner ()
{
cout << "Usage: driver [-v] [ -wait ] testName, where name is the name of a test case class" << endl;
cout << "Usage: driver [-v] [-table] [ -wait ] testName, where name is the name of a test case class" << endl;
} // printBanner
typedef bool (*runFn)(const string& name, Test *test, bool verbose);
bool TestRunner::run(int ac, const char **av)
{
bool ok = true;
string testCase;
int numberOfTests = 0;
int opt = 0;
runFn runner = textrun;
for(int i = 1; i < ac; i++)
{
@ -61,6 +78,14 @@ bool TestRunner::run(int ac, const char **av)
continue;
}
if(string(av[i]) == "-table")
{
runner = tablerun;
++opt;
continue;
}
testCase = av[i];
if(testCase == "")
@ -78,7 +103,7 @@ bool TestRunner::run(int ac, const char **av)
if((*it).first == testCase)
{
testToRun = (*it).second;
ok &= ::run((*it).first, testToRun, verbose_);
ok &= runner((*it).first, testToRun, verbose_);
}
}
@ -96,7 +121,7 @@ bool TestRunner::run(int ac, const char **av)
// run everything
for(mappings::iterator it = m_mappings.begin(); it != m_mappings.end(); ++it)
{
ok &= ::run((*it).first, (*it).second, verbose_);
ok &= runner((*it).first, (*it).second, verbose_);
}
return ok;
}

View file

@ -0,0 +1,14 @@
#include "TableTestResult.hpp"
void TableTestResult::print(std::ostream& stream)
{
stream
<< "\n"
<< name() << "\t"
<< runTests() << "\t"
<< testFailures() << "\t"
<< testErrors() << "\t"
<< testSkips();
} // print

View file

@ -0,0 +1,13 @@
#ifndef CPPUNIT_TableTestResult_HPP
#define CPPUNIT_TableTestResult_HPP
#include "TextTestResult.h"
class TableTestResult : public TextTestResult
{
public:
TableTestResult(const std::string& name, bool verbose) : TextTestResult(name, verbose) { }
virtual void print(std::ostream& stream);
};
#endif

View file

@ -125,7 +125,7 @@ void TextTestResult::print (ostream& stream)
if(verbose_)
printSkips (stream);
if(verbose_ || !wasSuccessful())
cout << endl;
stream << endl;
}
@ -135,15 +135,15 @@ void TextTestResult::printHeader (ostream& stream)
{
if(verbose_)
{
cout << endl << name_;
stream << endl << name_;
if(testSkips())
cout << endl << "OK (" << runTests () << " tests, with " << testSkips() << " skips)" << endl;
stream << endl << "OK (" << runTests () << " tests, with " << testSkips() << " skips)" << endl;
else
cout << endl << "OK (" << runTests () << " tests)" << endl;
stream << endl << "OK (" << runTests () << " tests)" << endl;
}
}
else
cout << endl
stream << endl
<< name_ << endl
<< "!!!FAILURES!!!" << endl
<< "Test Results:" << endl

View file

@ -20,6 +20,9 @@ public:
virtual void printSkips (std::ostream& stream);
virtual void printHeader (std::ostream& stream);
protected:
const std::string& name() const { return name_; }
private:
std::string name_;
bool verbose_;

View file

@ -272,6 +272,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -280,6 +280,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -272,6 +272,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -216,6 +216,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -214,6 +214,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -214,6 +214,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -236,6 +236,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -268,6 +268,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -274,6 +274,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -266,6 +266,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -224,6 +224,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -272,6 +272,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -280,6 +280,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -272,6 +272,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -216,6 +216,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -214,6 +214,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -214,6 +214,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -236,6 +236,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -268,6 +268,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -274,6 +274,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -266,6 +266,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -224,6 +224,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -273,6 +273,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -281,6 +281,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -273,6 +273,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -217,6 +217,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -215,6 +215,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -215,6 +215,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -237,6 +237,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -269,6 +269,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -275,6 +275,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -267,6 +267,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>

View file

@ -225,6 +225,14 @@
RelativePath="..\tests\CppUnit\framework\Guards.h"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.cpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\textui\TableTestResult.hpp"
>
</File>
<File
RelativePath="..\tests\CppUnit\framework\Test.h"
>