ProteoWizard
SavitzkyGolaySmootherTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6//
7// Copyright 2008 Spielberg Family Center for Applied Proteomics
8// Cedars-Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
27
28using namespace pwiz::util;
29using namespace pwiz::analysis;
30
31
32ostream* os_ = 0;
33
34
35const double testArray[] =
36{
37 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
38 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
39 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
40 1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90
41};
42
43
44void test()
45{
46 vector<double> testData(testArray, testArray+(14*4));
47 if (os_)
48 {
49 *os_ << "Unsmoothed data (" << testData.size() << "):\t";
50 copy(testData.begin(), testData.end(), ostream_iterator<double>(*os_, "\t"));
51 *os_ << endl;
52 }
53
54 vector<double> smoothData = SavitzkyGolaySmoother<double>::smooth_copy(testData);
55
56 if (os_)
57 {
58 *os_ << "Smoothed data (" << smoothData.size() << "):\t";
59 copy(smoothData.begin(), smoothData.end(), ostream_iterator<double>(*os_, "\t"));
60 *os_ << endl;
61 }
62
63 unit_assert(smoothData.size() == testData.size());
64}
65
66
67int main(int argc, char* argv[])
68{
69 TEST_PROLOG(argc, argv)
70
71 try
72 {
73 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
74 test();
75 }
76 catch (exception& e)
77 {
78 TEST_FAILED(e.what())
79 }
80 catch (...)
81 {
82 TEST_FAILED("Caught unknown exception.")
83 }
84
86}
const TestData testData[]
int main(int argc, char *argv[])
ostream * os_
const double testArray[]
static std::vector< T > smooth_copy(const std::vector< T > &data)
#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