ProteoWizard
pwiz
data
tradata
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
"
27
#include "
pwiz/utility/misc/unit.hpp
"
28
#include "boost/iostreams/positioning.hpp"
29
#include "
pwiz/utility/misc/Std.hpp
"
30
#include <cstring>
31
32
33
using namespace
pwiz::util
;
34
using namespace
pwiz::cv
;
35
using namespace
pwiz::tradata
;
36
37
38
ostream*
os_
= 0;
39
40
41
void
testWriteRead
()
42
{
43
if
(
os_
) *
os_
<<
"testWriteRead()"
<< endl;
44
45
TraData
td;
46
examples::initializeTiny
(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
59
Diff<TraData, DiffConfig>
diff
(td, td2);
60
if
(
os_
&&
diff
) *
os_
<<
diff
<< endl;
61
unit_assert
(!
diff
);
62
}
63
64
65
int
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;
72
testWriteRead
();
73
}
74
catch
(exception& e)
75
{
76
TEST_FAILED
(e.what())
77
}
78
catch
(...)
79
{
80
TEST_FAILED
(
"Caught unknown exception."
)
81
}
82
83
TEST_EPILOG
84
}
pwiz::tradata::Serializer_traML
TraData <-> traML stream serialization.
Definition:
Serializer_traML.hpp:37
pwiz::cv
Definition:
cv.hpp:108
pwiz::tradata::Serializer_traML::read
void read(boost::shared_ptr< std::istream > is, TraData &td) const
read in TraData object from a traML istream
TextWriter.hpp
pwiz::data::Diff
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition:
diff_std.hpp:143
pwiz::util
Definition:
almost_equal.hpp:33
pwiz::tradata::TraData
Definition:
TraData.hpp:351
TEST_EPILOG
#define TEST_EPILOG
Definition:
unit.hpp:183
examples.hpp
Std.hpp
diff
void diff(const string &filename1, const string &filename2)
Definition:
FrequencyDataTest.cpp:40
Serializer_traML.hpp
pwiz::identdata::examples::initializeTiny
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
TEST_FAILED
#define TEST_FAILED(x)
Definition:
unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition:
unit.hpp:175
main
int main(int argc, char *argv[])
Definition:
Serializer_traML_Test.cpp:65
testWriteRead
void testWriteRead()
Definition:
Serializer_traML_Test.cpp:41
os_
ostream * os_
Definition:
Serializer_traML_Test.cpp:38
Diff.hpp
unit.hpp
unit_assert
#define unit_assert(x)
Definition:
unit.hpp:85
pwiz::tradata
Definition:
DefaultReaderList.hpp:32
pwiz::tradata::Serializer_traML::write
void write(std::ostream &os, const TraData &td) const
write TraData object to ostream as traML
Generated by
1.8.20