ProteoWizard
Functions | Variables
WhittakerSmootherTest.cpp File Reference
#include "WhittakerSmoother.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

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

Variables

ostream * os_ = 0
 
const double testArrayX []
 
const double testArrayY []
 

Function Documentation

◆ test()

void test ( )

Definition at line 52 of file WhittakerSmootherTest.cpp.

53{
54 // test that invalid value exceptions are thrown
55
56 // lambda too low
58 "[WhittakerSmoother::ctor()] Invalid value for lamda coefficient; valid range is [2, infinity)");
59
60 WhittakerSmoother(100001); // lambda is valid up to numeric limits
61
62 vector<double> testX(testArrayX, testArrayX+(14*4));
63 vector<double> testY(testArrayY, testArrayY+(14*4));
64
65 if (os_)
66 {
67 *os_ << "Unsmoothed data (" << testY.size() << "):\t";
68 copy(testY.begin(), testY.end(), ostream_iterator<double>(*os_, "\t"));
69 *os_ << endl;
70 }
71
72 WhittakerSmoother smoother(10);
73 vector<double> smoothedX, smoothedY;
74 smoother.smooth(testX, testY, smoothedX, smoothedY);
75
76 if (os_)
77 {
78 *os_ << "Smoothed data (" << smoothedY.size() << "):\t";
79 copy(smoothedY.begin(), smoothedY.end(), ostream_iterator<double>(*os_, "\t"));
80 *os_ << endl;
81 }
82
83 // smoothed data should be same size as the unsmoothed data
84 //unit_assert(smoothData.size() == testY.size());
85
86 // TODO: add output testing
87}
const double testArrayY[]
ostream * os_
const double testArrayX[]
#define unit_assert_throws_what(x, exception, whatStr)
Definition unit.hpp:119

References os_, pwiz::analysis::WhittakerSmoother::smooth(), testArrayX, testArrayY, and unit_assert_throws_what.

Referenced by main().

◆ main()

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

Definition at line 90 of file WhittakerSmootherTest.cpp.

91{
92 TEST_PROLOG(argc, argv)
93
94 try
95 {
96 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
97 test();
98 }
99 catch (exception& e)
100 {
101 TEST_FAILED(e.what())
102 }
103 catch (...)
104 {
105 TEST_FAILED("Caught unknown exception.")
106 }
107
109}
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 32 of file WhittakerSmootherTest.cpp.

Referenced by main(), and test().

◆ testArrayX

const double testArrayX[]
Initial value:
=
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56
}

Definition at line 35 of file WhittakerSmootherTest.cpp.

36{
37 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
38 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
39 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
40 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56
41};

Referenced by test().

◆ testArrayY

const double testArrayY[]
Initial value:
=
{
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90
}

Definition at line 43 of file WhittakerSmootherTest.cpp.

44{
45 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
46 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
47 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
48 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90
49};

Referenced by test().