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