ProteoWizard
Serializer_mzid_Test.cpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Robert Burke <robert.burke@proteowizard.org>
6 //
7 // Copyright 2009 Spielberg Family Center for Applied Proteomics
8 // University of Southern California, Los Angeles, California 90033
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 #define PWIZ_SOURCE
24 
27 #include "IdentData.hpp"
28 #include "Serializer_mzid.hpp"
29 #include "examples.hpp"
30 #include "Diff.hpp"
31 
32 
33 using namespace pwiz::identdata;
34 using namespace pwiz::identdata::examples;
35 using namespace pwiz::util;
36 
37 
38 ostream* os_ = 0;
39 
40 
42 {
43  if (os_) *os_ << "begin testSerialize\n";
44  IdentData mzid;
45  initializeTiny(mzid);
46 
48  ostringstream oss;
49  ser.write(oss, mzid);
50 
51  if (os_) *os_ << oss.str() << endl;
52 
53  IdentData mzid2;
54  boost::shared_ptr<istream> iss(new istringstream(oss.str()));
55  ser.read(iss, mzid2);
56  Diff<IdentData, DiffConfig> diff(mzid, mzid2);
57 
58  if (os_ && diff) *os_ << diff << endl;
59  unit_assert(!diff);
60 }
61 
62 void test()
63 {
64  testSerialize();
65 }
66 
67 int main(int argc, char** argv)
68 {
69  TEST_PROLOG(argc, argv)
70 
71  try
72  {
73  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
74  test();
75  }
76  catch (exception& e)
77  {
78  TEST_FAILED(e.what())
79  }
80  catch (...)
81  {
82  TEST_FAILED("Caught unknown exception.")
83  }
84 
86 }
Diff.hpp
pwiz::identdata
Definition: DefaultReaderList.hpp:33
testSerialize
void testSerialize()
Definition: Serializer_mzid_Test.cpp:41
pwiz::identdata::examples
Definition: examples.hpp:31
pwiz::identdata::Serializer_mzIdentML::read
void read(boost::shared_ptr< std::istream > is, IdentData &mzid, const pwiz::util::IterationListenerRegistry *=0) const
read in MZIDData object from a mzIdentML istream
pwiz::data::Diff
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition: diff_std.hpp:142
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
IdentData.hpp
Std.hpp
diff
void diff(const string &filename1, const string &filename2)
Definition: FrequencyDataTest.cpp:40
Serializer_mzid.hpp
pwiz::identdata::examples::initializeTiny
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
pwiz::identdata::IdentData
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
os_
ostream * os_
Definition: Serializer_mzid_Test.cpp:38
pwiz::identdata::Serializer_mzIdentML
MZIDData <-> mzIdentML stream serialization.
Definition: Serializer_mzid.hpp:36
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
pwiz::identdata::Serializer_mzIdentML::write
void write(std::ostream &os, const IdentData &mzid, const pwiz::util::IterationListenerRegistry *=0) const
write MZIDData object to ostream as mzIdentML
main
int main(int argc, char **argv)
Definition: Serializer_mzid_Test.cpp:67
examples.hpp
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
test
void test()
Definition: Serializer_mzid_Test.cpp:62