ProteoWizard
Functions | Variables
CVTranslatorTest.cpp File Reference
#include "CVTranslator.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void test (const CVTranslator &translator, const string &text, CVID correct)
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void test ( const CVTranslator translator,
const string &  text,
CVID  correct 
)

Definition at line 38 of file CVTranslatorTest.cpp.

References pwiz::cv::cvTermInfo(), pwiz::cv::CVTermInfo::id, pwiz::cv::CVTermInfo::name, os_, pwiz::data::CVTranslator::translate(), and unit_assert.

{
CVID result = translator.translate(text);
if (os_) *os_ << text << " -> (" << cvTermInfo(result).id << ", \""
<< cvTermInfo(result).name << "\")\n";
unit_assert(result == correct);
}
void test ( )

Definition at line 47 of file CVTranslatorTest.cpp.

References CVID_Unknown, pwiz::data::CVTranslator::insert(), MS_FT_ICR, MS_ion_trap, MS_m_z, MS_software, MS_TIC, os_, test(), pwiz::data::CVTranslator::translate(), and unit_assert.

{
if (os_) *os_ << "test()\n";
CVTranslator translator;
test(translator, "FT-ICR", MS_FT_ICR);
test(translator, " \nFT - \tICR\t", MS_FT_ICR);
test(translator, " Total \t\n iOn @#$CurRENT", MS_TIC);
unit_assert(translator.translate("Darren Kessner") == CVID_Unknown);
translator.insert("DARREN.#$@#$^KESSNER", MS_software);
test(translator, "dARren kESSner", MS_software);
// test collision detection
bool caught = false;
try
{
translator.insert("darren kessner", MS_m_z);
}
catch (exception& )
{
caught = true;
}
if (os_) *os_ << "collision caught: " << boolalpha << caught << endl;
unit_assert(caught);
// test default extra entries
test(translator, " itms ", MS_ion_trap);
test(translator, " FTmS\n", MS_FT_ICR);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 80 of file CVTranslatorTest.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 35 of file CVTranslatorTest.cpp.