13 #include <gtest/gtest.h>
14 #include "../../include/ecl/containers/array.hpp"
15 #include "../../include/ecl/containers/fifo.hpp"
28 TEST(FiFoTest,constructors)
31 EXPECT_EQ(2.0, fifo[0]);
32 EXPECT_EQ(2.0, fifo[1]);
33 EXPECT_EQ(2.0, fifo[2]);
34 EXPECT_EQ(2.0, fifo[3]);
40 for(
int i=0; i<4; i++ )
45 EXPECT_EQ(0.0, fifo[0]);
46 EXPECT_EQ(1.0, fifo[1]);
47 EXPECT_EQ(2.0, fifo[2]);
48 EXPECT_EQ(3.0, fifo[3]);
57 movingAvg(
const unsigned int widowsSize ) :
60 windows_size(widowsSize),
63 fifo.resize( windows_size );
72 void update(
const double & incomingData )
76 fifo.fill( incomingData );
82 fifo.push_back( incomingData );
83 average = sum/(double)(windows_size);
87 unsigned int windows_size;
97 TEST(FiFoTest, application )
101 for(
int i=0; i<50; i++ )
103 mavg.update( (
double)i );
107 EXPECT_EQ(44.5, mavg.average );
123 template<
typename N,
int KernelSize>
124 class DifferentialOfGaussian1D
127 DifferentialOfGaussian1D()
133 bool updateData(
const N & incomingDatum, N & resultOfDOG )
135 resultOfDOG =
static_cast<N
>(0);
136 data.push_back( incomingDatum );
137 for(
int i=0; i<KernelSize; i++ )
139 resultOfDOG += (data[i]*kernel[i]);
142 if( number_of_incoming < 5 )
144 number_of_incoming++;
153 number_of_incoming = 0;
159 int number_of_incoming;
168 kernel.resize(KernelSize);
172 kernel[3] = -0.2642f;
173 kernel[4] = -0.1179f;
177 std::cout <<
"class DifferentialOfGaussian1D<N," << KernelSize <<
"have no kernel information " << std::endl;
192 int main(
int argc,
char **argv) {
194 testing::InitGoogleTest(&argc,argv);
195 return RUN_ALL_TESTS();