LRAUV  revA
I3D_Test.h
Go to the documentation of this file.
1 /*
2  * I3D.h
3  *
4  * unit test of methods for creating and deleting 3D pointer-based matrices.
5  *
6  * Created on: Feb 7, 2014
7  * Author: godin
8  */
9 
10 #ifndef I3D_TEST_H_
11 #define I3D_TEST_H_
12 
13 #include "I3D.h"
14 
15 #include <cxxtest/TestSuite.h>
16 
17 class I3D_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, o = 5;
25  float*** values = I3D<float>::New3D( m, n, o );
26  float inc = 1;
27  for( int i = 0; i < m; ++i )
28  {
29  for( int j = 0; j < n; ++j )
30  {
31  for( int k = 0; k < o; ++k )
32  {
33  values[i][j][k] = inc;
34  inc = inc + 1.0f;
35  }
36  }
37  }
38  int sum = 0;
39  for( int i = 0; i < m; ++i )
40  {
41  for( int j = 0; j < n; ++j )
42  {
43  for( int k = 0; k < o; ++k )
44  {
45  sum = sum + values[i][j][k];
46  }
47  }
48  }
49  TS_ASSERT_DELTA( sum, ( m * n * o ) * ( m * n * o + 1 ) / 2.0f, 0.01 );
50  I3D<float>::Delete3D( values );
51  }
52 };
53 
54 #endif /* I3D_TEST_H_ */
void testNew(void)
Definition: I3D_Test.h:22
Definition: I3D_Test.h:17
static T *** New3D(int m, int n, int o, bool extra=false)
Definition: I3D.h:33
static void Delete3D(T ***array)
Definition: I3D.h:58