ProteoWizard
Functions | Variables
LegacyAdapterTest.cpp File Reference
#include "LegacyAdapter.hpp"
#include "pwiz/data/common/CVTranslator.hpp"
#include "TextWriter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testModelAndManufacturer ()
void testIonisation ()
void testAnalyzer ()
void testDetector ()
void testInstrumentConfiguration ()
void testSoftware ()
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void testModelAndManufacturer ( )

Definition at line 43 of file LegacyAdapterTest.cpp.

References pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::manufacturer(), pwiz::msdata::LegacyAdapter_Instrument::manufacturerAndModel(), pwiz::msdata::LegacyAdapter_Instrument::model(), os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

{
if (os_) *os_ << "testModelAndManufacturer()\n";
InstrumentConfiguration instrumentConfiguration;
CVTranslator cvTranslator;
LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
unit_assert(instrumentConfiguration.cvParams.empty() && instrumentConfiguration.userParams.empty());
adapter.manufacturerAndModel("dummy", "LTQ-FT");
if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
<< "model: " << adapter.model() << endl;
unit_assert(instrumentConfiguration.cvParams.size() == 1);
unit_assert(instrumentConfiguration.userParams.empty());
unit_assert(adapter.manufacturer() == "Thermo Scientific");
unit_assert(adapter.model() == "LTQ FT");
adapter.manufacturerAndModel("doobie", "420");
if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
<< "model: " << adapter.model() << endl;
unit_assert(instrumentConfiguration.cvParams.empty());
unit_assert(instrumentConfiguration.userParams.size() == 2);
unit_assert(adapter.manufacturer() == "doobie");
unit_assert(adapter.model() == "420");
adapter.manufacturerAndModel("dummy", "LTQ-FT");
if (os_) *os_ << "manufacturer: " << adapter.manufacturer() << endl
<< "model: " << adapter.model() << endl;
unit_assert(instrumentConfiguration.cvParams.size() == 1);
unit_assert(instrumentConfiguration.userParams.empty());
unit_assert(adapter.manufacturer() == "Thermo Scientific");
unit_assert(adapter.model() == "LTQ FT");
}
void testIonisation ( )

Definition at line 79 of file LegacyAdapterTest.cpp.

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Source, pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::ionisation(), os_, pwiz::msdata::ComponentList::source(), unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

{
InstrumentConfiguration instrumentConfiguration;
instrumentConfiguration.componentList.push_back(Component(ComponentType_Source, 2));
CVTranslator cvTranslator;
LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
adapter.ionisation(" esi\t");
if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
unit_assert(adapter.ionisation() == "electrospray ionization");
adapter.ionisation("goober");
if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
unit_assert(instrumentConfiguration.componentList.source(0).cvParams.empty());
unit_assert(instrumentConfiguration.componentList.source(0).userParams.size() == 1);
unit_assert(adapter.ionisation() == "goober");
adapter.ionisation(" Electrospray-Ionization");
if (os_) *os_ << "ionisation: " << adapter.ionisation() << endl;
unit_assert(instrumentConfiguration.componentList.source(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.source(0).userParams.empty());
unit_assert(adapter.ionisation() == "electrospray ionization");
}
void testAnalyzer ( )

Definition at line 106 of file LegacyAdapterTest.cpp.

References pwiz::msdata::LegacyAdapter_Instrument::analyzer(), pwiz::msdata::ComponentList::analyzer(), pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Analyzer, pwiz::data::ParamContainer::cvParams, os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

{
InstrumentConfiguration instrumentConfiguration;
instrumentConfiguration.componentList.push_back(Component(ComponentType_Analyzer, 2));
CVTranslator cvTranslator;
LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
adapter.analyzer("IT");
if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
unit_assert(adapter.analyzer() == "ion trap");
adapter.analyzer("goober");
if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.empty());
unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.size() == 1);
unit_assert(adapter.analyzer() == "goober");
adapter.analyzer(" qit");
if (os_) *os_ << "analyzer: " << adapter.analyzer() << endl;
unit_assert(instrumentConfiguration.componentList.analyzer(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.analyzer(0).userParams.empty());
unit_assert(adapter.analyzer() == "quadrupole ion trap");
}
void testDetector ( )

Definition at line 133 of file LegacyAdapterTest.cpp.

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::ComponentType_Detector, pwiz::data::ParamContainer::cvParams, pwiz::msdata::LegacyAdapter_Instrument::detector(), pwiz::msdata::ComponentList::detector(), os_, unit_assert, and pwiz::data::ParamContainer::userParams.

Referenced by testInstrumentConfiguration().

{
InstrumentConfiguration instrumentConfiguration;
instrumentConfiguration.componentList.push_back(Component(ComponentType_Detector, 3));
CVTranslator cvTranslator;
LegacyAdapter_Instrument adapter(instrumentConfiguration, cvTranslator);
adapter.detector("emt");
if (os_) *os_ << "detector: " << adapter.detector() << endl;
unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
unit_assert(adapter.detector() == "electron multiplier tube");
adapter.detector("goober");
if (os_) *os_ << "detector: " << adapter.detector() << endl;
unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.empty());
unit_assert(instrumentConfiguration.componentList.detector(0).userParams.size() == 1);
unit_assert(adapter.detector() == "goober");
adapter.detector(" Electron Multiplier ");
if (os_) *os_ << "detector: " << adapter.detector() << endl;
unit_assert(instrumentConfiguration.componentList.detector(0).cvParams.size() == 1);
unit_assert(instrumentConfiguration.componentList.detector(0).userParams.empty());
unit_assert(adapter.detector() == "electron multiplier");
}
void testInstrumentConfiguration ( )
void testSoftware ( )

Definition at line 169 of file LegacyAdapterTest.cpp.

References pwiz::data::CVParam::cvid, CVID_Unknown, MS_software, MS_Xcalibur, pwiz::msdata::LegacyAdapter_Software::name(), os_, pwiz::msdata::LegacyAdapter_Software::type(), unit_assert, and pwiz::msdata::LegacyAdapter_Software::version().

{
SoftwarePtr software(new Software("abcd"));
MSData msd;
CVTranslator cvTranslator;
LegacyAdapter_Software adapter(software, msd, cvTranslator);
adapter.name(" XcaLibur ");
if (os_) *os_ << "software name: " << adapter.name() << endl;
CVParam softwareParam = software->cvParamChild(MS_software);
unit_assert(softwareParam.cvid == MS_Xcalibur);
unit_assert(adapter.name() == "Xcalibur");
adapter.name("goober");
if (os_) *os_ << "software name: " << adapter.name() << endl;
softwareParam = software->cvParamChild(MS_software);
unit_assert(softwareParam.cvid == CVID_Unknown);
unit_assert(adapter.name() == "goober");
adapter.version("4.20");
if (os_) *os_ << "software version: " << adapter.version() << endl;
unit_assert(adapter.version() == "4.20");
//adapter.type("acquisition");
//if (os_) *os_ << "software type: " << adapter.type() << endl;
//unit_assert(adapter.type() == "acquisition");
adapter.type("analysis");
if (os_) *os_ << "software type: " << adapter.type() << endl;
unit_assert(adapter.type() == "analysis");
}
void test ( )
int main ( int  argc,
char *  argv[] 
)

Definition at line 209 of file LegacyAdapterTest.cpp.

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

{
TEST_PROLOG(argc, argv)
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 40 of file LegacyAdapterTest.cpp.