ProteoWizard
TraDataTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: TraDataTest.cpp 4129 2012-11-20 00:05:37Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2009 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
23 #include "TraData.hpp"
26 
27 using namespace pwiz::cv;
28 using namespace pwiz::util;
29 using namespace pwiz::tradata;
30 
31 
33 {
34  ParamContainer pc;
35  pc.cvParams.push_back(MS_reflectron_on);
36  pc.cvParams.push_back(MS_MSn_spectrum);
37  pc.cvParams.push_back(MS_reflectron_off);
38  pc.cvParams.push_back(CVParam(MS_ionization_type, 420));
39  pc.userParams.push_back(UserParam("name1", "1", "type1", UO_second));
40  pc.userParams.push_back(UserParam("name2", "2", "type2", UO_minute));
41 
44 
46 
49 
51 
52  string result = "goober";
53  result = pc.cvParam(MS_selected_ion_m_z).value;
54  unit_assert(result == "");
55  result = pc.cvParam(MS_ionization_type).value;
56  unit_assert(result == "420");
57 
58  UserParam userParam = pc.userParam("name");
59  unit_assert(userParam.empty());
60  userParam = pc.userParam("name1");
61  unit_assert(userParam.name == "name1");
62  unit_assert(userParam.valueAs<int>() == 1);
63  unit_assert(userParam.type == "type1");
64  unit_assert(userParam.units == UO_second);
65  userParam = pc.userParam("name2");
66  unit_assert(userParam.name == "name2");
67  unit_assert(userParam.valueAs<double>() == 2);
68  unit_assert(userParam.type == "type2");
69  unit_assert(userParam.units == UO_minute);
70  unit_assert(pc.userParam("goober").valueAs<int>() == 0);
71 
72  pc.set(MS_ms_level, 2);
73  unit_assert(pc.cvParam(MS_ms_level).valueAs<int>() == 2);
74  pc.set(MS_ms_level, 3);
75  unit_assert(pc.cvParam(MS_ms_level).valueAs<int>() == 3);
76 
77  pc.set(MS_deisotoping, true);
78  unit_assert(pc.cvParam(MS_deisotoping).valueAs<bool>() == true);
79  pc.set(MS_deisotoping, false);
80  unit_assert(pc.cvParam(MS_deisotoping).valueAs<bool>() == false);
81 }
82 
83 
84 int main(int argc, const char* argv[])
85 {
86  TEST_PROLOG(argc, argv)
87 
88  try
89  {
91  }
92  catch (exception& e)
93  {
94  TEST_FAILED(e.what())
95  }
96  catch (...)
97  {
98  TEST_FAILED("Caught unknown exception.")
99  }
100 
102 }