ProteoWizard
Reader_ABI_Test.cpp
Go to the documentation of this file.
1 //
2 // $Id: Reader_ABI_Test.cpp 8903 2015-09-29 18:17:40Z chambm $
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::to_lower_copy(BFS_STRING(bfs::path(rawpath).extension())) == ".wiff";
38  }
39 };
40 
41 int main(int argc, char* argv[])
42 {
43  TEST_PROLOG(argc, argv)
44 
45  #ifdef PWIZ_READER_ABI
46  const bool testAcceptOnly = false;
47  #else
48  const bool testAcceptOnly = true;
49  #endif
50 
51  try
52  {
53  #ifdef PWIZ_READER_ABI
54 
55  using namespace pwiz::msdata;
56  using namespace pwiz::msdata::detail;
57  using namespace pwiz::msdata::detail::ABI;
58  using namespace pwiz::util;
59 
60  // test that all instrument types are handled by translation functions (skipping the 'Unknown' type)
61  bool allInstrumentTestsPassed = true;
62  for (int i = 1; i < (int) InstrumentModel_Count; ++i)
63  {
64  InstrumentModel model = (InstrumentModel) i;
65 
66  try
67  {
69 
70  InstrumentConfigurationPtr configuration = translateAsInstrumentConfiguration(model, IonSourceType_Unknown);
71 
72  unit_assert(configuration->componentList.source(0).hasCVParam(MS_ionization_type));
73  unit_assert(configuration->componentList.analyzer(0).hasCVParam(MS_quadrupole));
74  unit_assert(configuration->componentList.detector(0).hasCVParam(MS_electron_multiplier));
75  }
76  catch (runtime_error& e)
77  {
78  cerr << "Unit test failed for instrument model " << lexical_cast<string>(model) << ":\n" << e.what() << endl;
79  allInstrumentTestsPassed = false;
80  }
81  }
82 
83  unit_assert(allInstrumentTestsPassed);
84  #endif
85 
86  bool requireUnicodeSupport = true;
87  pwiz::util::testReader(pwiz::msdata::Reader_ABI(), testArgs, testAcceptOnly, requireUnicodeSupport, IsWiffFile());
88  }
89  catch (exception& e)
90  {
91  TEST_FAILED(e.what())
92  }
93  catch (...)
94  {
95  TEST_FAILED("Caught unknown exception.")
96  }
97 
99 }
PWIZ_API_DECL CVID translateAsInstrumentModel(InstrumentModelType instrumentModelType)
int main(int argc, char *argv[])
#define TEST_EPILOG
Definition: unit.hpp:182
MS_electron_multiplier
electron multiplier: A device to amplify the current of a beam or packet of charged particles or phot...
Definition: cv.hpp:1060
float lexical_cast(const std::string &str)
bool operator()(const string &rawpath) const
returns true iff the given rawpath is a real path to test/generate
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;.
MS_ionization_type
ionization type: The method by which gas phase ions are generated from the sample.
Definition: cv.hpp:124
#define BFS_STRING(p)
Definition: Filesystem.hpp:53
boost::shared_ptr< InstrumentConfiguration > InstrumentConfigurationPtr
Definition: MSData.hpp:249
#define TEST_FAILED(x)
Definition: unit.hpp:176
test implementations derive from this to define which paths should be tested
CVID_Unknown
Definition: cv.hpp:97
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
MS_quadrupole
quadrupole: A mass spectrometer that consists of four parallel rods whose centers form the corners of...
Definition: cv.hpp:382
#define unit_assert(x)
Definition: unit.hpp:85