ProteoWizard
Serializer_traML_Test.cpp
Go to the documentation of this file.
1//
2// $Id$
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 "Serializer_traML.hpp"
24#include "Diff.hpp"
25#include "TextWriter.hpp"
26#include "examples.hpp"
28#include "boost/iostreams/positioning.hpp"
30#include <cstring>
31
32
33using namespace pwiz::util;
34using namespace pwiz::cv;
35using namespace pwiz::tradata;
36
37
38ostream* os_ = 0;
39
40
42{
43 if (os_) *os_ << "testWriteRead()" << endl;
44
45 TraData td;
47
48 Serializer_traML tramlSerializer;
49
50 ostringstream oss;
51 tramlSerializer.write(oss, td);
52
53 if (os_) *os_ << "oss:\n" << oss.str() << endl;
54
55 shared_ptr<istringstream> iss(new istringstream(oss.str()));
56 TraData td2;
57 tramlSerializer.read(iss, td2);
58
60 if (os_ && diff) *os_ << diff << endl;
62}
63
64
65int main(int argc, char* argv[])
66{
67 TEST_PROLOG(argc, argv)
68
69 try
70 {
71 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
73 }
74 catch (exception& e)
75 {
76 TEST_FAILED(e.what())
77 }
78 catch (...)
79 {
80 TEST_FAILED("Caught unknown exception.")
81 }
82
84}
void diff(const string &filename1, const string &filename2)
int main(int argc, char *argv[])
ostream * os_
void testWriteRead()
TraData <-> traML stream serialization.
void write(std::ostream &os, const TraData &td) const
write TraData object to ostream as traML
void read(boost::shared_ptr< std::istream > is, TraData &td) const
read in TraData object from a traML istream
PWIZ_API_DECL void initializeTiny(ProteomeData &pd)
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
#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