ProteoWizard
Classes | Functions
Reader_Thermo_Test.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "Reader_Thermo.hpp"
#include "pwiz/utility/misc/VendorReaderTestHarness.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

struct  IsRawFile
 

Functions

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

Function Documentation

§ main()

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

Definition at line 42 of file Reader_Thermo_Test.cpp.

References pwiz::msdata::detail::Bruker::createInstrumentConfigurations(), CVID_Unknown, boost::lexical_cast(), TEST_EPILOG, TEST_FAILED, TEST_PROLOG, pwiz::util::testReader(), pwiz::msdata::detail::Thermo::translateAsInstrumentModel(), and unit_assert.

43 {
44  TEST_PROLOG(argc, argv)
45 
46  #if defined(PWIZ_READER_THERMO) && !defined(PWIZ_READER_THERMO_TEST_ACCEPT_ONLY)
47  const bool testAcceptOnly = false;
48  #else
49  const bool testAcceptOnly = true;
50  #endif
51 
52  try
53  {
54  #ifdef PWIZ_READER_THERMO
55 
56  using namespace pwiz::msdata;
57  using namespace pwiz::msdata::detail;
58  using namespace pwiz::msdata::detail::Thermo;
59  using namespace pwiz::cv;
60  using namespace pwiz::util;
61 
62  // test that all instrument types are handled by translation functions (skipping the 'Unknown' type)
63  bool allInstrumentTestsPassed = true;
64  for (int i=0; i < (int) InstrumentModelType_Count; ++i)
65  {
66  InstrumentModelType model = (InstrumentModelType) i;
67 
68  try
69  {
71 
72  Component dummySource;
73  vector<InstrumentConfiguration> configurations = createInstrumentConfigurations(dummySource, model);
74 
75  switch (model)
76  {
77  case InstrumentModelType_Tempus_TOF:
78  case InstrumentModelType_Element_2:
79  case InstrumentModelType_Element_XR:
80  case InstrumentModelType_Element_GD:
81  case InstrumentModelType_Delta_Plus_Advantage:
82  case InstrumentModelType_Delta_Plus_XP:
83  case InstrumentModelType_Neptune:
84  case InstrumentModelType_Triton:
85  unit_assert(configurations.empty());
86  break;
87 
88  default:
89  unit_assert(!configurations.empty());
90  break;
91  }
92 
93  // test for ionization types for this instrument
94  vector<IonizationType> ionizationTypes = getIonSourcesForInstrumentModel(model);
95 
96  switch (model)
97  {
98  case InstrumentModelType_Element_XR:
99  case InstrumentModelType_Element_2:
100  case InstrumentModelType_Delta_Plus_Advantage:
101  case InstrumentModelType_Delta_Plus_XP:
102  case InstrumentModelType_Neptune:
103  case InstrumentModelType_Tempus_TOF:
104  case InstrumentModelType_Triton:
105  case InstrumentModelType_MAT253:
106  case InstrumentModelType_MAT900XP:
107  case InstrumentModelType_MAT900XP_Trap:
108  case InstrumentModelType_MAT95XP:
109  case InstrumentModelType_MAT95XP_Trap:
110  case InstrumentModelType_Surveyor_PDA:
111  case InstrumentModelType_Accela_PDA:
112  unit_assert(ionizationTypes.empty());
113  break;
114 
115  default:
116  unit_assert(!ionizationTypes.empty());
117  break;
118  }
119 
120  // test for mass analyzer types for this instrument
121  vector<MassAnalyzerType> massAnalyzerTypes = getMassAnalyzersForInstrumentModel(model);
122 
123  switch (model)
124  {
125  case InstrumentModelType_Element_XR:
126  case InstrumentModelType_Element_2:
127  case InstrumentModelType_Element_GD:
128  case InstrumentModelType_Delta_Plus_Advantage:
129  case InstrumentModelType_Delta_Plus_XP:
130  case InstrumentModelType_Neptune:
131  case InstrumentModelType_Triton:
132  case InstrumentModelType_Surveyor_PDA:
133  case InstrumentModelType_Accela_PDA:
134  unit_assert(massAnalyzerTypes.empty());
135  break;
136 
137  default:
138  unit_assert(!massAnalyzerTypes.empty());
139  break;
140  }
141 
142  // test for detector types for this instrument
143  vector<DetectorType> detectorTypes = getDetectorsForInstrumentModel(model);
144 
145  switch (model)
146  {
147  case InstrumentModelType_Element_GD:
148  case InstrumentModelType_Element_XR:
149  case InstrumentModelType_Element_2:
150  case InstrumentModelType_Delta_Plus_Advantage:
151  case InstrumentModelType_Delta_Plus_XP:
152  case InstrumentModelType_Neptune:
153  case InstrumentModelType_Tempus_TOF:
154  case InstrumentModelType_Triton:
155  case InstrumentModelType_MAT253:
156  case InstrumentModelType_MAT900XP:
157  case InstrumentModelType_MAT900XP_Trap:
158  case InstrumentModelType_MAT95XP:
159  case InstrumentModelType_MAT95XP_Trap:
160  unit_assert(detectorTypes.empty());
161  break;
162 
163  default:
164  unit_assert(!detectorTypes.empty());
165  break;
166  }
167 
168  // test for translation of scan filter mass analyzer type to real mass analyzer type
169  BOOST_FOREACH(MassAnalyzerType realType, massAnalyzerTypes)
170  {
171  bool hasCorrespondingScanFilterType = false;
172  for (int j=0; j < (int) ScanFilterMassAnalyzerType_Count; ++j)
173  if (convertScanFilterMassAnalyzer((ScanFilterMassAnalyzerType) j, model) == realType)
174  hasCorrespondingScanFilterType = true;
175  unit_assert(hasCorrespondingScanFilterType);
176  }
177  }
178  catch (runtime_error& e)
179  {
180  cerr << "Unit test failed for instrument model " << lexical_cast<string>(model) << ":\n" << e.what() << endl;
181  allInstrumentTestsPassed = false;
182  }
183  }
184 
185  unit_assert(allInstrumentTestsPassed);
186  #endif
187 
188  bool requireUnicodeSupport = true;
189  pwiz::util::testReader(pwiz::msdata::Reader_Thermo(), testArgs, testAcceptOnly, requireUnicodeSupport, IsRawFile());
190  }
191  catch (exception& e)
192  {
193  TEST_FAILED(e.what())
194  }
195  catch (...)
196  {
197  TEST_FAILED("Caught unknown exception.")
198  }
199 
201 }
PWIZ_API_DECL std::vector< InstrumentConfiguration > createInstrumentConfigurations(RawFile &rawfile)
PWIZ_API_DECL CVID translateAsInstrumentModel(InstrumentModelType instrumentModelType)
A component of an instrument corresponding to a source (i.e. ion source), an analyzer (i...
Definition: MSData.hpp:130
#define TEST_EPILOG
Definition: unit.hpp:182
float lexical_cast(const std::string &str)
PWIZ_API_DECL int testReader(const pwiz::msdata::Reader &reader, const std::vector< std::string > &args, bool testAcceptOnly, bool requireUnicodeSupport, const TestPathPredicate &isPathTestable)
A common test harness for vendor readers;.
#define TEST_FAILED(x)
Definition: unit.hpp:176
CVID_Unknown
Definition: cv.hpp:97
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
#define unit_assert(x)
Definition: unit.hpp:85
Definition: cv.hpp:91