ProteoWizard
Classes | Functions
SpectrumListWrapperTest.cpp File Reference
#include "SpectrumListWrapper.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

class  MyWrapper
 
class  FilterWrapper
 

Functions

void test ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ test()

void test ( )

Definition at line 67 of file SpectrumListWrapperTest.cpp.

68{
70
71 const size_t spectrumCount = 10;
72 for (size_t i=0; i<spectrumCount; i++)
73 {
74 simple->spectra.push_back(SpectrumPtr(new Spectrum));
75 Spectrum& s = *simple->spectra.back();
76 s.index = i;
77 s.id = "scan=" + lexical_cast<string>(i);
78 }
79
80 // check MyWrapper
81
82 shared_ptr<MyWrapper> wrapper(new MyWrapper(simple));
83
84 wrapper->verifySize(10);
85 unit_assert(wrapper->size() == 10);
86 for (size_t i=0; i<spectrumCount; i++)
87 {
88 string id = "scan=" + lexical_cast<string>(i);
89
90 unit_assert(wrapper->find(id) == i);
91 IndexList indexList = wrapper->findNameValue("scan", lexical_cast<string>(i));
92 unit_assert(indexList.size()==1 && indexList[0]==i);
93
94 const SpectrumIdentity& identity = wrapper->spectrumIdentity(i);
95 unit_assert(identity.id == id);
96
97 SpectrumPtr s = wrapper->spectrum(i);
98 unit_assert(s->id == id);
99 }
100
101 // check FilterWrapper
102
103 shared_ptr<FilterWrapper> filterWrapper(new FilterWrapper(simple));
104
105 unit_assert(filterWrapper->size() == 5);
106
107 for (size_t i=0; i<filterWrapper->size(); i++)
108 {
109 string id = "scan=" + lexical_cast<string>(i*2);
110 string scanNumber = lexical_cast<string>(i*2);
111
112 unit_assert(filterWrapper->find(id) == i);
113 IndexList indexList = filterWrapper->findNameValue("scan", scanNumber);
114 unit_assert(indexList.size()==1 && indexList[0]==i);
115
116 const SpectrumIdentity& identity = filterWrapper->spectrumIdentity(i);
117 unit_assert(identity.id == id);
118
119 SpectrumPtr s = filterWrapper->spectrum(i);
120 unit_assert(s->id == id);
121 }
122}
boost::shared_ptr< Spectrum > SpectrumPtr
Definition MSData.hpp:573
boost::shared_ptr< SpectrumListSimple > SpectrumListSimplePtr
Definition MSData.hpp:731
The structure that captures the generation of a peak list (including the underlying acquisitions)
Definition MSData.hpp:506
Identifying information for a spectrum.
Definition MSData.hpp:471
std::string id
a unique identifier for this spectrum. It should be expected that external files may use this identif...
Definition MSData.hpp:476
size_t index
the zero-based, consecutive index of the spectrum in the SpectrumList.
Definition MSData.hpp:473
Simple writeable in-memory implementation of SpectrumList.
Definition MSData.hpp:717
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::SpectrumIdentity::index, and unit_assert.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 125 of file SpectrumListWrapperTest.cpp.

126{
127 TEST_PROLOG(argc, argv)
128
129 try
130 {
131 test();
132 }
133 catch (exception& e)
134 {
135 TEST_FAILED(e.what())
136 }
137 catch (...)
138 {
139 TEST_FAILED("Caught unknown exception.")
140 }
141
143}
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.