ProteoWizard
ChromatogramListWrapperTest.cpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Eric Purser <Eric.Purser .@. Vanderbilt.edu>
6 //
7 // Copyright 2008 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 
27 
28 using namespace pwiz::analysis;
29 using namespace pwiz::cv;
30 using namespace pwiz::msdata;
31 using namespace pwiz::util;
32 
33 
35 {
36  public:
37 
40  {}
41 
42  void verifySize(size_t size)
43  {
44  // verify that we can see inner_
45  unit_assert(size == inner_->size());
46  }
47 };
48 
49 
50 void test()
51 {
53 
54  const size_t chromatogramCount = 10;
55  for (size_t i=0; i<chromatogramCount; i++)
56  {
57  simple->chromatograms.push_back(ChromatogramPtr(new Chromatogram));
58  Chromatogram& s = *simple->chromatograms.back();
59  s.index = i;
60  s.id = "S" + lexical_cast<string>(i);
61  s.nativeID = lexical_cast<string>(i);
62  }
63 
64  shared_ptr<MyWrapper> wrapper(new MyWrapper(simple));
65 
66  // make sure we're getting what we expect
67 
68  wrapper->verifySize(10);
69  unit_assert(wrapper->size() == 10);
70  for (size_t i=0; i<chromatogramCount; i++)
71  {
72  string id = "S" + lexical_cast<string>(i);
73  string nativeID = lexical_cast<string>(i);
74 
75  unit_assert(wrapper->find(id) == i);
76  unit_assert(wrapper->findNative(nativeID) == i);
77 
78  const ChromatogramIdentity& identity = wrapper->chromatogramIdentity(i);
79  unit_assert(identity.id == id);
80  unit_assert(identity.nativeID == nativeID);
81 
82  ChromatogramPtr s = wrapper->chromatogram(i);
83  unit_assert(s->id == id);
84  unit_assert(s->nativeID == nativeID);
85  }
86 }
87 
88 
89 int main(int argc, char* argv[])
90 {
91  TEST_PROLOG(argc, argv)
92 
93  try
94  {
95  test();
96  }
97  catch (exception& e)
98  {
99  TEST_FAILED(e.what())
100  }
101  catch (...)
102  {
103  TEST_FAILED("Caught unknown exception.")
104  }
105 
107 }
108 
109 
pwiz::msdata::ChromatogramIdentity::id
std::string id
a unique identifier for this chromatogram. It should be expected that external files may use this ide...
Definition: MSData.hpp:495
pwiz::msdata::ChromatogramListSimple
Simple writeable in-memory implementation of ChromatogramList.
Definition: MSData.hpp:791
MyWrapper
Definition: ChromatogramListWrapperTest.cpp:35
pwiz::cv
Definition: cv.hpp:108
test
void test()
Definition: ChromatogramListWrapperTest.cpp:50
pwiz::analysis
Definition: ChromatogramList_Filter.hpp:37
pwiz::msdata
Definition: DemuxTypes.hpp:27
MyWrapper::verifySize
void verifySize(size_t size)
Definition: ChromatogramListWrapperTest.cpp:42
ChromatogramListWrapper.hpp
pwiz::msdata::ChromatogramIdentity
Identifying information for a chromatogram.
Definition: MSData.hpp:490
MyWrapper::MyWrapper
MyWrapper(const ChromatogramListPtr &inner)
Definition: ChromatogramListWrapperTest.cpp:38
pwiz::msdata::ChromatogramListPtr
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition: MSData.hpp:785
pwiz::msdata::Chromatogram
A single chromatogram.
Definition: MSData.hpp:578
main
int main(int argc, char *argv[])
Definition: ChromatogramListWrapperTest.cpp:89
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
Std.hpp
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
pwiz::analysis::ChromatogramListWrapper
Inheritable pass-through implementation for wrapping a ChromatogramList.
Definition: ChromatogramListWrapper.hpp:39
pwiz::msdata::ChromatogramPtr
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: MSData.hpp:624
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
pwiz::msdata::ChromatogramIdentity::index
size_t index
the zero-based, consecutive index of the chromatogram in the ChromatogramList.
Definition: MSData.hpp:492
pwiz::msdata::ChromatogramListSimplePtr
boost::shared_ptr< ChromatogramListSimple > ChromatogramListSimplePtr
Definition: MSData.hpp:805