ProteoWizard
Reader_ABI_Test.cpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2009 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
24 #include "Reader_ABI.hpp"
28 
29 #ifdef PWIZ_READER_ABI
30 #include "Reader_ABI_Detail.hpp"
31 #endif
32 
34 {
35  bool operator() (const string& rawpath) const
36  {
37  return bal::iends_with(rawpath, ".wiff")
38 #ifdef _WIN64
39  || bal::iends_with(rawpath, ".wiff2")
40 #endif
41  ;
42  }
43 };
44 
45 int main(int argc, char* argv[])
46 {
47  TEST_PROLOG(argc, argv)
48 
49  #ifdef PWIZ_READER_ABI
50  const bool testAcceptOnly = false;
51  #else
52  const bool testAcceptOnly = true;
53  #endif
54 
55  try
56  {
57  #ifdef PWIZ_READER_ABI
58 
59  using namespace pwiz::msdata;
60  using namespace pwiz::msdata::detail;
61  using namespace pwiz::msdata::detail::ABI;
62  using namespace pwiz::util;
63 
64  // test that all instrument types are handled by translation functions (skipping the 'Unknown' type)
65  bool allInstrumentTestsPassed = true;
66  for (int i = 1; i < (int) InstrumentModel_Count; ++i)
67  {
68  InstrumentModel model = (InstrumentModel) i;
69 
70  try
71  {
73 
74  InstrumentConfigurationPtr configuration = translateAsInstrumentConfiguration(model, IonSourceType_Unknown);
75 
76  unit_assert(configuration->componentList.source(0).hasCVParam(MS_ionization_type));
77  unit_assert(configuration->componentList.analyzer(0).hasCVParam(MS_quadrupole));
78  unit_assert(configuration->componentList.detector(0).hasCVParam(MS_electron_multiplier));
79  }
80  catch (runtime_error& e)
81  {
82  cerr << "Unit test failed for instrument model " << lexical_cast<string>(model) << ":\n" << e.what() << endl;
83  allInstrumentTestsPassed = false;
84  }
85  }
86 
87  unit_assert(allInstrumentTestsPassed);
88  #endif
89 
90  bool requireUnicodeSupport = true;
91  pwiz::util::testReader(pwiz::msdata::Reader_ABI(), testArgs, testAcceptOnly, requireUnicodeSupport, IsWiffFile());
92  }
93  catch (exception& e)
94  {
95  TEST_FAILED(e.what())
96  }
97  catch (...)
98  {
99  TEST_FAILED("Caught unknown exception.")
100  }
101 
103 }
pwiz::msdata::detail::Thermo::translateAsInstrumentModel
PWIZ_API_DECL CVID translateAsInstrumentModel(InstrumentModelType instrumentModelType)
pwiz::msdata
Definition: DemuxTypes.hpp:27
pwiz::msdata::detail
Definition: ChromatogramList_ABI.hpp:35
MS_ionization_type
MS_ionization_type
ionization type: The method by which gas phase ions are generated from the sample.
Definition: cv.hpp:285
Reader_ABI.hpp
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
CVID_Unknown
CVID_Unknown
Definition: cv.hpp:114
main
int main(int argc, char *argv[])
Definition: Reader_ABI_Test.cpp:45
pwiz::msdata::Reader_ABI
Definition: Reader_ABI.hpp:42
Std.hpp
Filesystem.hpp
pwiz::util::TestPathPredicate
test implementations derive from this to define which paths should be tested
Definition: VendorReaderTestHarness.hpp:35
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
Reader_ABI_Detail.hpp
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
pwiz::msdata::InstrumentConfigurationPtr
boost::shared_ptr< InstrumentConfiguration > InstrumentConfigurationPtr
Definition: MSData.hpp:250
VendorReaderTestHarness.hpp
MS_quadrupole
MS_quadrupole
quadrupole: A mass spectrometer that consists of four parallel rods whose centers form the corners of...
Definition: cv.hpp:543
IsWiffFile::operator()
bool operator()(const string &rawpath) const
returns true iff the given rawpath is a real path to test/generate
Definition: Reader_ABI_Test.cpp:35
MS_electron_multiplier
MS_electron_multiplier
electron multiplier: A device to amplify the current of a beam or packet of charged particles or phot...
Definition: cv.hpp:1212
IsWiffFile
Definition: Reader_ABI_Test.cpp:33
pwiz::util::testReader
PWIZ_API_DECL int testReader(const pwiz::msdata::Reader &reader, const std::vector< std::string > &args, bool testAcceptOnly, bool requireUnicodeSupport, const TestPathPredicate &isPathTestable, const ReaderTestConfig &config=ReaderTestConfig())
A common test harness for vendor readers;.