28 using namespace pwiz::util;
29 using namespace pwiz::data;
30 using namespace pwiz::msdata;
45 spectrum0->id =
"scan=1";
49 for (
unsigned int i=0; i<10; i++) bd_mz->data.push_back(i);
51 double* buffer = &bd_mz->data[0];
55 for (
unsigned int i=0; i<10; i++) bd_intensity->data.push_back(10-i);
58 spectrum0->binaryDataArrayPtrs.push_back(bd_mz);
59 spectrum0->binaryDataArrayPtrs.push_back(bd_intensity);
60 spectrum0->defaultArrayLength = 10;
64 spectrum1->id =
"scan=2";
68 spectrumListSimple->spectra.push_back(spectrum0);
69 spectrumListSimple->spectra.push_back(spectrum1);
108 unit_assert(spectrum->binaryDataArrayPtrs.size() == 2);
109 unit_assert(&(spectrum->binaryDataArrayPtrs[0]->data[0]) == buffer);
116 vector<MZIntensityPair> mziPairs;
117 spectrum->getMZIntensityPairs(mziPairs);
120 vector<double> doubleArray;
122 doubleArray.resize(spectrum->defaultArrayLength*2);
123 spectrum->getMZIntensityPairs(reinterpret_cast<MZIntensityPair*>(&doubleArray[0]),
124 spectrum->defaultArrayLength);
126 for (
unsigned int i=0; i<10; i++)
136 spectrum->binaryDataArrayPtrs.clear();
137 unit_assert(spectrum->binaryDataArrayPtrs.empty());
138 vector<MZIntensityPair> mziPairs2;
139 for (
unsigned int i=0; i<10; i++)
142 unit_assert(spectrum->binaryDataArrayPtrs.size() == 2);
146 unit_assert(spectrum->binaryDataArrayPtrs[0]->data.size() == 10);
147 unit_assert(spectrum->binaryDataArrayPtrs[1]->data.size() == 10);
148 for (
unsigned int i=0; i<10; i++)
149 unit_assert(spectrum->binaryDataArrayPtrs[0]->data[i] == 2*i &&
150 spectrum->binaryDataArrayPtrs[1]->data[i] == 3*i);
153 spectrum = spectrumList.
spectrum(1);
168 for (
int i=0; i<3; i++)
170 vector<TimeIntensityPair> pairs;
183 for (
size_t i=0; i<3; i++)
185 vector<TimeIntensityPair> result;
188 for (
size_t j=0; j<10; j++)
189 unit_assert(result[j].time==j && result[j].intensity==10*i+j);
199 string id =
"hair=blue favorite=420 age=36.175 upsideDown=1";
201 map<string,string> parsedID =
id::parse(
id);
205 unit_assert(id::valueAs<int>(
id,
"favorite") == 420);
207 unit_assert(id::valueAs<bool>(
id,
"upsideDown") ==
true);
212 id =
"controllerType=0 controllerNumber=1 scan=123";
239 id =
"sample=1 period=2 cycle=123 experiment=3";
266 int main(
int argc,
const char* argv[])