ProteoWizard
Macros | Functions | Variables
Serializer_Text_Test.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "IdentData.hpp"
#include "Serializer_Text.hpp"
#include "TextWriter.hpp"
#include "examples.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Macros

#define PWIZ_SOURCE
 

Functions

void testSerializeRead ()
 
void testSerializeWrite ()
 
void test ()
 
int main (int argc, char **argv)
 

Variables

ostream * os_ = 0
 

Macro Definition Documentation

◆ PWIZ_SOURCE

#define PWIZ_SOURCE

Definition at line 23 of file Serializer_Text_Test.cpp.

Function Documentation

◆ testSerializeRead()

void testSerializeRead ( )

Definition at line 37 of file Serializer_Text_Test.cpp.

38{
39 if (os_)
40 (*os_) << "*** Beginning testSerializeRead() ***\n";
41
42 string testStr = "scan\trt\tmz\tscore\tscoretype\tpeptide\tprotein\n"
43 "1\t1.01\t100.1\t0.5\tmascot\tVAGWE\tvague protein\n"
44 "2\t2.02\t200.0\t0.9\tmascot\tCERTAIN\tcertain protein\n";
45
46 shared_ptr<istringstream> iss(new istringstream(testStr));
47
48 IdentData mzid;
49 Serializer_Text serializer;
50 serializer.read(iss, mzid);
51
52
53 if (os_)
54 {
55 (*os_) << "mzIdentML output:\n";
56 TextWriter tw(*os_);
57 tw(mzid);
58 }
59
60 if (os_)
61 (*os_) << "*** Ending testSerializeRead() ***\n";
62}
ostream * os_
Serializer_Text reads in and writes out an id file in tab format.
void read(boost::shared_ptr< std::istream > is, IdentData &mzid) const
read in IdentData object from a delimited text fromat.
Implementation of the MzIdentMLType from the mzIdentML schema.

References os_, and pwiz::identdata::Serializer_Text::read().

Referenced by test().

◆ testSerializeWrite()

void testSerializeWrite ( )

Definition at line 64 of file Serializer_Text_Test.cpp.

65{
66 if (os_)
67 (*os_) << "*** Beginning testSerializeWrite() ***\n";
68
69 ostringstream oss;
70 IdentData mzid;
72
73 Serializer_Text serializer;
74 serializer.write(oss, mzid);
75
76 if (os_)
77 (*os_) << oss.str() << endl;
78
79 if (os_)
80 (*os_) << "*** Ending testSerializeRead() ***\n";
81}
void write(std::ostream &os, const IdentData &mzid, const pwiz::util::IterationListenerRegistry *iterationListenerRegistry=0) const
writes IdentData object to ostream as a text table
PWIZ_API_DECL void initializeBasicSpectrumIdentification(IdentData &mzid)

References pwiz::identdata::examples::initializeBasicSpectrumIdentification(), os_, and pwiz::identdata::Serializer_Text::write().

Referenced by test().

◆ test()

void test ( )

Definition at line 83 of file Serializer_Text_Test.cpp.

84{
87}
void testSerializeWrite()
void testSerializeRead()

References testSerializeRead(), and testSerializeWrite().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 89 of file Serializer_Text_Test.cpp.

90{
91 TEST_PROLOG(argc, argv)
92
93 try
94 {
95 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
96 test();
97 }
98 catch (exception& e)
99 {
100 TEST_FAILED(e.what())
101 }
102 catch (...)
103 {
104 TEST_FAILED("Caught unknown exception.")
105 }
106
108}
void test()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 35 of file Serializer_Text_Test.cpp.

Referenced by main(), testSerializeRead(), and testSerializeWrite().