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
28using namespace pwiz::analysis;
29using namespace pwiz::cv;
30using namespace pwiz::msdata;
31using 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
50void 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
89int 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
int main(int argc, char *argv[])
void verifySize(size_t size)
MyWrapper(const ChromatogramListPtr &inner)
Inheritable pass-through implementation for wrapping a ChromatogramList.
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition MSData.hpp:624
boost::shared_ptr< ChromatogramListSimple > ChromatogramListSimplePtr
Definition MSData.hpp:805
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition MSData.hpp:785
A single chromatogram.
Definition MSData.hpp:578
Identifying information for a chromatogram.
Definition MSData.hpp:490
std::string id
a unique identifier for this chromatogram. It should be expected that external files may use this ide...
Definition MSData.hpp:495
size_t index
the zero-based, consecutive index of the chromatogram in the ChromatogramList.
Definition MSData.hpp:492
Simple writeable in-memory implementation of ChromatogramList.
Definition MSData.hpp:791
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175