ProteoWizard
Functions | Variables
IOTest.cpp File Reference
#include "IO.hpp"
#include "Diff.hpp"
#include "examples.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

template<typename object_type >
void testObject (const object_type &a)
void testCV ()
void testUserParam ()
void testCVParam ()
template<typename object_type >
void testNamedParamContainer ()
void testSoftware ()
void testTraData ()
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

template<typename object_type >
void testObject ( const object_type &  a)

Definition at line 40 of file IOTest.cpp.

References diff(), os_, pwiz::identdata::IO::read(), unit_assert, and write().

{
if (os_) *os_ << "testObject(): " << typeid(a).name() << endl;
// write 'a' out to a stream
ostringstream oss;
XMLWriter writer(oss);
IO::write(writer, a);
if (os_) *os_ << oss.str() << endl;
// read 'b' in from stream
object_type b;
istringstream iss(oss.str());
IO::read(iss, b);
// compare 'a' and 'b'
if (diff && os_) *os_ << "diff:\n" << diff << endl;
}
void testCV ( )

Definition at line 67 of file IOTest.cpp.

References pwiz::cv::CV::fullName, pwiz::cv::CV::id, testObject(), pwiz::cv::CV::URI, and pwiz::cv::CV::version.

{
CV a;
a.URI = "abcd";
a.id = "efgh";
a.fullName = "ijkl";
a.version = "mnop";
}
void testUserParam ( )
void testCVParam ( )

Definition at line 91 of file IOTest.cpp.

References MS_m_z, MS_selected_ion_m_z, testObject(), and UO_second.

{
CVParam b(UO_second, "123.45");
}
template<typename object_type >
void testNamedParamContainer ( )

Definition at line 102 of file IOTest.cpp.

References MS_ionization_type, MS_m_z, MS_selected_ion_m_z, and testObject().

{
object_type a;
a.userParams.push_back(UserParam("goober", "goo", "peanuts"));
a.cvParams.push_back(CVParam(MS_ionization_type, "420"));
a.cvParams.push_back(CVParam(MS_selected_ion_m_z, "666", MS_m_z));
}
void testSoftware ( )
void testTraData ( )

Definition at line 166 of file IOTest.cpp.

References diff(), pwiz::identdata::examples::initializeTiny(), os_, pwiz::identdata::IO::read(), unit_assert, and write().

{
if (os_) *os_ << "testTraData():\n";
// write 'a' out to a stream
ostringstream oss;
XMLWriter writer(oss);
IO::write(writer, a);
if (os_) *os_ << oss.str() << endl;
// read 'b' in from stream
istringstream iss(oss.str());
IO::read(iss, b);
// compare 'a' and 'b'
if (diff && os_) *os_ << "diff:\n" << diff << endl;
}
void test ( )

Definition at line 194 of file IOTest.cpp.

References testCV(), testCVParam(), testTraData(), and testUserParam().

{
testCV();
//testNamedParamContainer<Contact>();
//testNamedParamContainer<Publication>();
/*testInstrument();
testConfiguration();
testPrecursor();
testProduct();*/
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 209 of file IOTest.cpp.

References e(), os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG_EX.

{
TEST_PROLOG_EX(argc, argv, "_TraData")
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 36 of file IOTest.cpp.