ProteoWizard
Functions | Variables
SampleDatumTest.cpp File Reference
#include "SampleDatum.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <complex>
#include <cstring>

Go to the source code of this file.

Functions

template<typename abscissa_type , typename ordinate_type >
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ test()

template<typename abscissa_type , typename ordinate_type >
void test ( )

Definition at line 39 of file SampleDatumTest.cpp.

40{
42
43 vector<sd_type> v;
44 v.push_back(sd_type(1,2));
45 v.push_back(sd_type(3,4));
46 v.push_back(sd_type(5,6));
47
48 // write the pairs out to a stream
49 ostringstream oss;
50 copy(v.begin(), v.end(), ostream_iterator<sd_type>(oss, "\n"));
51 if (os_) *os_ << oss.str();
52
53 // read them back in
54 vector<sd_type> w;
55 istringstream iss(oss.str());
56 copy(istream_iterator<sd_type>(iss), istream_iterator<sd_type>(), back_inserter(w));
57
58 // compare the two vectors
59 unit_assert(v == w);
60}
ostream * os_
#define unit_assert(x)
Definition unit.hpp:85

References os_, and unit_assert.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 63 of file SampleDatumTest.cpp.

64{
65 TEST_PROLOG(argc, argv)
66
67 try
68 {
69 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
70 if (os_) *os_ << "SampleDatumTest\n";
71
72 test<int,int>();
73 test<double,double>();
74 test< double,complex<double> >();
75 test< complex<double>,complex<double> >();
76
77 }
78 catch (exception& e)
79 {
80 TEST_FAILED(e.what())
81 }
82 catch (...)
83 {
84 TEST_FAILED("Caught unknown exception.")
85 }
86
88}
#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_EPILOG, TEST_FAILED, and TEST_PROLOG.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 35 of file SampleDatumTest.cpp.

Referenced by main(), and test().