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

◆ testDefaultTabHandler()

void testDefaultTabHandler ( const bfs::path &  datafile)

Definition at line 34 of file TabReaderTest.cpp.

35{
36 const char* alphabet = "abcd";
37 const char* numbers = "1234";
38
39 TabReader tr;
41
42 tr.setHandler(&vth);
43 tr.process(datafile.string().c_str());
44
46 cout << (* (*it).begin()) << endl;
47
48 size_t y=0;
49 for (; it != vth.end(); it++)
50 {
51 size_t x=0;
52 for (vector<string>::const_iterator it2=(*it).begin(); it2!=(*it).end();it2++)
53 {
54 const char* value = (*it2).c_str();
55 unit_assert(value[0] == alphabet[x]);
56 unit_assert(value[1] == numbers[y]);
57 x++;
58 }
59 cerr << endl;
60 y++;
61 }
62}
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
virtual void setHandler(TabHandler *handler)
virtual bool process(const char *filename)
virtual const_iterator begin() const
virtual const_iterator end() const
std::vector< std::vector< std::string > >::const_iterator const_iterator
Definition TabReader.hpp:94
PWIZ_API_DECL std::string value(const std::string &id, const std::string &name)
convenience function to extract a named value from an id string
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::util::VectorTabHandler::begin(), pwiz::util::VectorTabHandler::end(), pwiz::util::TabReader::process(), pwiz::util::TabReader::setHandler(), unit_assert, x, and y.

Referenced by runTests().

◆ testMSIHandler()

void testMSIHandler ( const bfs::path &  datafile)

Definition at line 64 of file TabReaderTest.cpp.

65{
66 TabReader tr;
67 MSIHandler mh;
68
69 tr.setHandler(&mh);
70 tr.process(datafile.string().c_str());
71}

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

Referenced by runTests().

◆ runTests()

void runTests ( const bfs::path &  datapath)

Definition at line 73 of file TabReaderTest.cpp.

74{
75 testDefaultTabHandler(datapath / "TabTest.tab");
76 testMSIHandler(datapath / "MSITest.tab");
77}
void testMSIHandler(const bfs::path &datafile)
void testDefaultTabHandler(const bfs::path &datafile)

References testDefaultTabHandler(), and testMSIHandler().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 79 of file TabReaderTest.cpp.

80{
81 TEST_PROLOG(argc, argv)
82
83 try
84 {
85 bfs::path datapath = ".";
86
87 for (int i=1; i<argc; i++)
88 {
89 if (!strcmp(argv[i],"-v"))
90 os_ = &cout;
91 else
92 // hack to allow running unit test from a different directory:
93 // Jamfile passes full path to specified input file.
94 // we want the path, so we can ignore filename
95 datapath = bfs::path(argv[i]).branch_path();
96 }
97 if (os_) *os_ << "TabReaderTest\n";
98 runTests(datapath);
99 }
100 catch (exception& e)
101 {
102 TEST_FAILED(e.what())
103 }
104 catch (...)
105 {
106 TEST_FAILED("Caught unknown exception.")
107 }
108
110}
void runTests(const bfs::path &datapath)
ostream * os_
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

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

Variable Documentation

◆ os_

ostream* os_ = NULL

Definition at line 32 of file TabReaderTest.cpp.

Referenced by main().