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

§ test() [1/2]

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.

Referenced by main(), and test().

39 {
40  CVID result = translator.translate(text);
41  if (os_) *os_ << text << " -> (" << cvTermInfo(result).id << ", \""
42  << cvTermInfo(result).name << "\")\n";
43  unit_assert(result == correct);
44 }
std::string id
Definition: cv.hpp:13384
PWIZ_API_DECL const CVTermInfo & cvTermInfo(CVID cvid)
returns CV term info for the specified CVID
ostream * os_
cv::CVID translate(const std::string &text) const
translate text -> CVID
std::string name
Definition: cv.hpp:13385
#define unit_assert(x)
Definition: unit.hpp:85

§ test() [2/2]

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.

48 {
49  if (os_) *os_ << "test()\n";
50 
51  CVTranslator translator;
52  test(translator, "FT-ICR", MS_FT_ICR);
53  test(translator, " \nFT - \tICR\t", MS_FT_ICR);
54  test(translator, " Total \t\n iOn @#$CurRENT", MS_TIC);
55 
56  unit_assert(translator.translate("Darren Kessner") == CVID_Unknown);
57  translator.insert("DARREN.#$@#$^KESSNER", MS_software);
58  test(translator, "dARren kESSner", MS_software);
59 
60  // test collision detection
61  bool caught = false;
62  try
63  {
64  translator.insert("darren kessner", MS_m_z);
65  }
66  catch (exception& )
67  {
68  caught = true;
69  }
70  if (os_) *os_ << "collision caught: " << boolalpha << caught << endl;
71  unit_assert(caught);
72 
73  // test default extra entries
74 
75  test(translator, " itms ", MS_ion_trap);
76  test(translator, " FTmS\n", MS_FT_ICR);
77 }
MS_TIC
TIC (total ion current): The sum of all the separate ion currents carried by the ions of different m/...
Definition: cv.hpp:1258
MS_FT_ICR
FT_ICR (fourier transform ion cyclotron resonance mass spectrometer): A mass spectrometer based on th...
Definition: cv.hpp:376
ostream * os_
translates text to CV terms
MS_software
software: Software related to the recording or transformation of spectra.
Definition: cv.hpp:2047
cv::CVID translate(const std::string &text) const
translate text -> CVID
MS_m_z
m/z: Three-character symbol m/z is used to denote the quantity formed by dividing the mass of an ion ...
Definition: cv.hpp:223
void insert(const std::string &text, cv::CVID cvid)
insert a text-cvid pair into the dictionary
CVID_Unknown
Definition: cv.hpp:97
void test(const CVTranslator &translator, const string &text, CVID correct)
MS_ion_trap
ion trap: A device for spatially confining ions using electric and magnetic fields alone or in combin...
Definition: cv.hpp:1126
#define unit_assert(x)
Definition: unit.hpp:85

§ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 80 of file CVTranslatorTest.cpp.

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

81 {
82  TEST_PROLOG(argc, argv)
83 
84  try
85  {
86  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
87  test();
88  }
89  catch (exception& e)
90  {
91  TEST_FAILED(e.what())
92  }
93  catch (...)
94  {
95  TEST_FAILED("Caught unknown exception.")
96  }
97 
99 }
ostream * os_
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_FAILED(x)
Definition: unit.hpp:176
void test(const CVTranslator &translator, const string &text, CVID correct)
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 35 of file CVTranslatorTest.cpp.

Referenced by main(), and test().