LRAUV  revA
I1D_Test.h
Go to the documentation of this file.
1 /*
2  * I1D.h
3  *
4  * Unit tests of methods for creating and deleting 1D pointer-based matrices.
5  *
6  * Created on: Feb 7, 2014
7  * Author: godin
8  */
9 
10 #ifndef I1D_TEST_H_
11 #define I1D_TEST_H_
12 
13 #include "I1D.h"
14 
15 #include <cxxtest/TestSuite.h>
16 
17 class I1D_Test : public CxxTest::TestSuite
18 {
19 public:
20 
21  // Test basic allocation and access
22  void testNew( void )
23  {
24  int m = 7;
25  float* values = I1D<float>::New1D( m );
26  float inc = 1;
27  for( int i = 0; i < m; ++i )
28  {
29  values[i] = inc;
30  ++inc;
31  }
32  int sum = 0;
33  for( int i = 0; i < m; ++i )
34  {
35  sum = sum + values[i];
36  }
37  TS_ASSERT_DELTA( sum, m * ( m + 1 ) / 2.0f, 0.01 );
38  I1D<float>::Delete1D( values );
39  }
40 };
41 
42 #endif /* I1D_TEST_H_ */
static void Delete1D(T *array)
Definition: I1D.h:39
static T * New1D(int m, bool extra=false)
Definition: I1D.h:28
Definition: I1D_Test.h:17
void testNew(void)
Definition: I1D_Test.h:22