testFFTDataContainerAlgorithm.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 #include <vector>
12 
13 #include <boost/rational.hpp>
14 
15 #include <tst/Verify.h>
16 
17 #include <utl/AugerException.h>
18 #include <utl/AugerUnits.h>
19 #include <utl/FFTDataContainerAlgorithm.h>
20 
21 #include <cppunit/extensions/HelperMacros.h>
22 
23 using namespace std;
24 using namespace utl;
25 using namespace tst;
26 
30 class testFFTDataContainerAlgorithm : public CppUnit::TestFixture {
31 
32  CPPUNIT_TEST_SUITE(testFFTDataContainerAlgorithm);
33 //CPPUNIT_TEST(testTimeShifting);
34 //CPPUNIT_TEST(testUpsampling);
35 //CPPUNIT_TEST(testResampling);
36 //CPPUNIT_TEST(testThinOut);
37  CPPUNIT_TEST(testDoubleToRational);
38  CPPUNIT_TEST_SUITE_END();
39 
40 private:
41 
42 public:
43  void
45  {
46  }
47 
48  void
50  {
51  }
52 
53 /*void
54  testTimeShifting()
55  {
56  //#warning Tests for FFTDataContainerAlgorithm have yet to be implemented
57  }
58 
59  void
60  testUpsampling()
61  {
62  //#warning Tests for FFTDataContainerAlgorithm have yet to be implemented
63  }
64 
65  void
66  testResampling()
67  {
68  //#warning Tests for FFTDataContainerAlgorithm have yet to be implemented
69  }
70 
71  void
72  testThinOut()
73  {
74  //#warning Tests for FFTDataContainerAlgorithm have yet to be implemented
75  } */
76 
77  void
79  {
80  typedef boost::rational<long> rational;
81 
82  vector<double> doubles;
83  vector<rational> rationals;
84 
85  // push value pairs to be tested into the vectors
86  doubles.push_back(0.3);
87  rationals.push_back(rational(3,10));
88 
89  doubles.push_back(1./3.);
90  rationals.push_back(rational(1,3));
91 
92  doubles.push_back(1./7.);
93  rationals.push_back(rational(1,7));
94 
95  doubles.push_back(0.101);
96  rationals.push_back(rational(101,1000));
97 
98  doubles.push_back(0.123401); // four significant digits plus a rounding error
99  rationals.push_back(rational(1234,10000));
100 
101  // compare the converted rationals with the true values
102  for (unsigned int i=0; i<doubles.size(); ++i)
103  CPPUNIT_ASSERT(Verify<Equal>(rationals[i],FFTDataContainerAlgorithm::ConvertDecimalDoubleToRational(doubles[i], false)));
104  }
105 
106 
107 };
108 
110 
111 // Configure (x)emacs for this file ...
112 // Local Variables:
113 // mode: c++
114 // End:
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)

, generated on Tue Sep 26 2023.