25 #ifndef WMATRIX_TEST_H
26 #define WMATRIX_TEST_H
28 #include <cxxtest/TestSuite.h>
30 #include "../WMatrix.h"
61 const size_t nbRows = 3, nbCols = 2;
63 TS_ASSERT_EQUALS( matrix.
getNbRows(), nbRows );
64 TS_ASSERT_EQUALS( matrix.
getNbCols(), nbCols );
72 const size_t nbRows = 3, nbCols = 2;
74 TS_ASSERT_EQUALS( matrix( 0 , 0 ), 0. );
75 TS_ASSERT_EQUALS( matrix( 0 , 1 ), 0. );
76 TS_ASSERT_EQUALS( matrix( 1 , 0 ), 0. );
77 TS_ASSERT_EQUALS( matrix( 1 , 1 ), 0. );
78 TS_ASSERT_EQUALS( matrix( 2 , 0 ), 0. );
79 TS_ASSERT_EQUALS( matrix( 2 , 1 ), 0. );
81 const double a = 3.14;
83 TS_ASSERT_EQUALS( matrix( 2, 1 ), a );
91 const size_t nbRows = 3, nbCols = 2;
93 TS_ASSERT_EQUALS( matrix( 0 , 0 ), 0. );
94 TS_ASSERT_EQUALS( matrix( 0 , 1 ), 0. );
95 TS_ASSERT_EQUALS( matrix( 1 , 0 ), 0. );
96 TS_ASSERT_EQUALS( matrix( 1 , 1 ), 0. );
97 TS_ASSERT_EQUALS( matrix( 2 , 0 ), 0. );
98 TS_ASSERT_EQUALS( matrix( 2 , 1 ), 0. );
106 const size_t nbRows = 3, nbCols = 2;
107 const double a = 1.2, b = 2.3, c = 3.4, d = 4.5, e = 5.6, f = 6.7;
133 TS_ASSERT_EQUALS( matrix1 == matrix2,
true );
134 TS_ASSERT_EQUALS( matrix1 == matrix3,
false );
136 matrix2( 0, 0 ) += 1.;
138 TS_ASSERT_EQUALS( matrix1 == matrix2,
false );
146 const size_t nbRows = 3, nbCols = 2;
147 const double a = 1.2, b = 2.3, c = 3.4, d = 4.5, e = 5.6, f = 6.7;
173 TS_ASSERT_EQUALS( matrix1 != matrix2,
false );
174 TS_ASSERT_EQUALS( matrix1 != matrix3,
true );
176 matrix2( 0, 0 ) += 1.;
178 TS_ASSERT_EQUALS( matrix1 != matrix2,
true );
186 const size_t nbRows = 3, nbCols = 2;
187 const double a = 1.2, b = 2.3, c = 3.4, d = 4.5, e = 5.6, f = 6.7;
198 matrix2( 0, 0 ) = a + 1.;
199 matrix2( 0, 1 ) = b + 2.;
200 matrix2( 1, 0 ) = c + 3.;
201 matrix2( 1, 1 ) = d + 4.;
202 matrix2( 2, 0 ) = e + 5.;
203 matrix2( 2, 1 ) = f + 6.;
206 TS_ASSERT_EQUALS( matrix1 == matrix2,
false );
210 TS_ASSERT_EQUALS( matrix1 == matrix2,
true );
216 TS_ASSERT_EQUALS( matrix2 == matrix3,
false );
217 TS_ASSERT_EQUALS( matrix2 == matrix4,
false );
221 matrix4 = matrix3 = matrix2;
222 TS_ASSERT_EQUALS( matrix2 == matrix3,
true );
223 TS_ASSERT_EQUALS( matrix2 == matrix4,
true );
224 TS_ASSERT_EQUALS( matrix3 == matrix4,
true );
232 const size_t nbRows = 3, nbCols = 2;
235 for(
size_t row = 0; row < nbRows; row++ )
236 for(
size_t col = 0; col < nbCols; col++ )
237 matrix( row, col ) = ( row+1 )*10 + col+1;
246 for(
size_t row = 0; row < nbRows; row++ )
247 for(
size_t col = 0; col < nbCols; col++ )
248 TS_ASSERT_EQUALS( matrixTransposed( col, row ), ( row+1 )*10 + col + 1 );
266 TS_ASSERT_EQUALS( b.
isIdentity( 1e-3 ),
true );
269 TS_ASSERT_EQUALS( b.
isIdentity( 1e-3 ),
false );
270 TS_ASSERT_EQUALS( b.
isIdentity( 2e-3 ),
true );
void testAssignmentOperator(void)
Test assignment operator of WMatrix.
void testGetNbRowsAndCols(void)
Number of rows and columns should be return correctly.
void testInstantiation(void)
Instantiation should throw nothing.
void testInequalityOperator(void)
Test for inequality comparison of two matrices.
void testTransposed(void)
Test transposed method of WMatrix.
void testEqualityOperator(void)
Test for equality comparison of two matrices.
void testCopyInstantiation(void)
Instantiation with copy constructor should throw nothing.
void testElementAccessOperator(void)
Element access operator should work correctly.
void testIsIdentity(void)
Test isIdentity method of WMatrix.
void testConstElementAccessOperator(void)
Constant element access operator should work correctly.
size_t getNbRows() const
Get number of rows.
bool isIdentity(T delta=T(0.0)) const
Returns true if the matrix is a identity matrix.
WMatrix transposed() const
Returns the transposed matrix.
size_t getNbCols() const
Get number of columns.
WMatrix & makeIdentity()
Makes the matrix contain the identity matrix, i.e.