ProteoWizard
Functions | Variables
TabReaderTest.cpp File Reference
#include "Std.hpp"
#include "TabReader.hpp"
#include "MSIHandler.hpp"
#include "unit.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testDefaultTabHandler (const bfs::path &datafile)
void testMSIHandler (const bfs::path &datafile)
void runTests (const bfs::path &datapath)
int main (int argc, char **argv)

Variables

ostream * os_ = NULL

Function Documentation

void testDefaultTabHandler ( const bfs::path &  datafile)

Definition at line 35 of file TabReaderTest.cpp.

References pwiz::utility::VectorTabHandler::begin(), pwiz::utility::VectorTabHandler::end(), pwiz::utility::TabReader::process(), pwiz::utility::TabReader::setHandler(), unit_assert, pwiz::msdata::id::value(), x, and y.

Referenced by runTests().

{
const char* alphabet = "abcd";
const char* numbers = "1234";
tr.setHandler(&vth);
tr.process(datafile.string().c_str());
cout << (* (*it).begin()) << endl;
size_t y=0;
for (; it != vth.end(); it++)
{
size_t x=0;
for (vector<string>::const_iterator it2=(*it).begin(); it2!=(*it).end();it2++)
{
const char* value = (*it2).c_str();
unit_assert(value[0] == alphabet[x]);
unit_assert(value[1] == numbers[y]);
x++;
}
cerr << endl;
y++;
}
}
void testMSIHandler ( const bfs::path &  datafile)

Definition at line 65 of file TabReaderTest.cpp.

References pwiz::utility::TabReader::process(), and pwiz::utility::TabReader::setHandler().

Referenced by runTests().

{
tr.setHandler(&mh);
tr.process(datafile.string().c_str());
}
void runTests ( const bfs::path &  datapath)

Definition at line 74 of file TabReaderTest.cpp.

References testDefaultTabHandler(), and testMSIHandler().

{
testDefaultTabHandler(datapath / "TabTest.tab");
testMSIHandler(datapath / "MSITest.tab");
}
int main ( int  argc,
char **  argv 
)

Definition at line 80 of file TabReaderTest.cpp.

References e(), os_, runTests(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

{
TEST_PROLOG(argc, argv)
try
{
bfs::path datapath = ".";
for (int i=1; i<argc; i++)
{
if (!strcmp(argv[i],"-v"))
os_ = &cout;
else
// hack to allow running unit test from a different directory:
// Jamfile passes full path to specified input file.
// we want the path, so we can ignore filename
datapath = bfs::path(argv[i]).branch_path();
}
if (os_) *os_ << "TabReaderTest\n";
runTests(datapath);
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = NULL

Definition at line 33 of file TabReaderTest.cpp.