ProteoWizard
ProteinListFactoryTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: ProteinListFactoryTest.cpp 4129 2012-11-20 00:05:37Z chambm $
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6 //
7 // Copyright 2012 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 "ProteinListFactory.hpp"
27 #include <cstring>
28 
29 
30 using namespace pwiz::analysis;
31 using namespace pwiz::util;
32 using namespace pwiz::proteome;
33 
34 
35 ostream* os_ = 0;
36 
37 
38 void testUsage()
39 {
40  if (os_) *os_ << "ProteinListFactory::usage():\n" << ProteinListFactory::usage() << endl;
41 }
42 
43 
44 void testWrap()
45 {
46  ProteomeData pd;
48 
50 
51  unit_assert(pl.get());
52  unit_assert_operator_equal(3, pl->size());
53 
54  ProteinListFactory::wrap(pd, "id DEFCON42;ZEBRA");
55  unit_assert_operator_equal(2, pl->size());
56  unit_assert_operator_equal("ZEBRA", pl->protein(0)->id);
57  unit_assert_operator_equal("DEFCON42", pl->protein(1)->id);
58 
59  ProteinListFactory::wrap(pd, "index 1");
60  unit_assert_operator_equal(1, pl->size());
61  unit_assert_operator_equal("DEFCON42", pl->protein(0)->id);
62 }
63 
64 
65 void test()
66 {
67  testUsage();
68  testWrap();
69 }
70 
71 
72 int main(int argc, char* argv[])
73 {
74  TEST_PROLOG(argc, argv)
75 
76  try
77  {
78  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
79  test();
80  }
81  catch (exception& e)
82  {
83  TEST_FAILED(e.what())
84  }
85  catch (...)
86  {
87  TEST_FAILED("Caught unknown exception.")
88  }
89 
91 }
92