MDA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
Matrix_test.hpp
1 /*
2  * Matrix_test.hpp
3  *
4  * Created on: 3 Oct 2013
5  * Author: ck
6  */
7 
8 #ifndef MATRIX_TEST_HPP_
9 #define MATRIX_TEST_HPP_
10 
11 #include "../lib/utils/Matrix1Line.hpp"
12 #include <cxxtest/TestSuite.h>
13 
14 class Matrix_Test : public CxxTest::TestSuite
15 {
16 public:
17 
18  void test_1line_mat()
19  {
20  MDAT::Matrix1Line<int> mat(4, 3, 2);
21  TS_ASSERT_EQUALS(mat.dim1(), 4);
22  TS_ASSERT_EQUALS(mat.dim2(), 3);
23  TS_ASSERT_EQUALS(mat.size(), 12);
24  TS_ASSERT_EQUALS(mat[3][2], 2);
25 
26  mat[1][5]=7;
27  TS_ASSERT_EQUALS(mat[1][5], 7);
28 
29  for (size_t i=0; i<4; ++i)
30  {
31  for (size_t j=0; j<3; ++j)
32  mat[i][j]=i;
33  }
34 
35  std::vector<int>::iterator it, it_end=mat.end(1);
36  for (it=mat.begin(1); it!=it_end; ++it)
37  TS_ASSERT_EQUALS(*it, 1);
38  TS_ASSERT_EQUALS(*it_end, 2);
39  TS_ASSERT_EQUALS(*(mat.begin(1)-1), 0);
40  }
41 
42 };
43 
44 
45 #endif /* MATRIX_TEST_HPP_ */