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
33using namespace pwiz::identdata;
34using namespace pwiz::identdata::examples;
35using namespace pwiz::util;
36
37
38ostream* 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);
57
58 if (os_ && diff) *os_ << diff << endl;
60}
61
62void test()
63{
65}
66
67int 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}
void diff(const string &filename1, const string &filename2)
int main(int argc, char **argv)
void testSerialize()
ostream * os_
void test()
MZIDData <-> mzIdentML stream serialization.
void write(std::ostream &os, const IdentData &mzid, const pwiz::util::IterationListenerRegistry *=0) const
write MZIDData object to ostream as mzIdentML
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_API_DECL void initializeTiny(IdentData &mzid)
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
Implementation of the MzIdentMLType from the mzIdentML schema.
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175