ProteoWizard
SpectrumListBaseTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: SpectrumListBaseTest.cpp 6141 2014-05-05 21:03:47Z chambm $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2009 Spielberg Family Center for Applied Proteomics
8 // Cedars Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #include "SpectrumListBase.hpp"
27 
28 using namespace pwiz::msdata;
29 using namespace pwiz::util;
30 
31 
32 class MyBase : public SpectrumListBase
33 {
34  public:
35  virtual size_t size() const {return 0;}
36  virtual const SpectrumIdentity& spectrumIdentity(size_t index) const {throw runtime_error("heh");}
37  virtual SpectrumPtr spectrum(size_t index, bool getBinaryData = false) const {return SpectrumPtr();}
38 
39  // make sure we still compile -- error if setDataProcessingPtr() renamed to dataProcessingPtr()
40  virtual const boost::shared_ptr<const DataProcessing> dataProcessingPtr() const {return dp_;}
41 };
42 
43 
44 void test()
45 {
46  MyBase base;
47  DataProcessingPtr dp(new DataProcessing("dp"));
48  base.setDataProcessingPtr(dp);
49  unit_assert(base.dataProcessingPtr().get() == dp.get());
50 }
51 
52 
53 int main(int argc, char* argv[])
54 {
55  TEST_PROLOG(argc, argv)
56 
57  try
58  {
59  test();
60  }
61  catch (exception& e)
62  {
63  TEST_FAILED(e.what())
64  }
65  catch (...)
66  {
67  TEST_FAILED("Caught unknown exception.")
68  }
69 
71 }
72 
73 
void test()
common functionality for base SpectrumList implementations
Description of the way in which a particular software was used.
Definition: MSData.hpp:272
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: MSData.hpp:569
virtual void setDataProcessingPtr(DataProcessingPtr dp)
set DataProcessing
#define TEST_EPILOG
Definition: unit.hpp:182
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: MSData.hpp:287
int main(int argc, char *argv[])
virtual SpectrumPtr spectrum(size_t index, bool getBinaryData=false) const
retrieve a spectrum by index
Identifying information for a spectrum.
Definition: MSData.hpp:469
#define TEST_FAILED(x)
Definition: unit.hpp:176
virtual const SpectrumIdentity & spectrumIdentity(size_t index) const
access to a spectrum index
virtual const boost::shared_ptr< const DataProcessing > dataProcessingPtr() const
implementation of ChromatogramList
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174
virtual size_t size() const
returns the number of spectra
#define unit_assert(x)
Definition: unit.hpp:85