LRAUV  revA
Mtx_Test.h
Go to the documentation of this file.
1 
9 #ifndef _MTX_TEST_H_
10 #define _MTX_TEST_H_
11 
12 
13 #include "Mtx.h"
14 #include "io/StrIOStream.h"
15 
16 #include <cxxtest/TestSuite.h>
17 
23 class Mtx_Test : public CxxTest::TestSuite
24 {
25 public:
26 
28  void testShellSort( void )
29  {
30  Logger logger( "Mtx_Test" );
31  Mtx mtx( logger, 3, 4 );
32  mtx[ 0 ][ 0 ] = 5.0f;
33  mtx[ 1 ][ 0 ] = 4.0f;
34  mtx[ 2 ][ 0 ] = 1.0f;
35  mtx[ 0 ][ 1 ] = 2.0f;
36  mtx[ 1 ][ 1 ] = 5.0f;
37  mtx[ 2 ][ 1 ] = 5.0f;
38  mtx[ 0 ][ 2 ] = 1.0f;
39  mtx[ 1 ][ 2 ] = 2.0f;
40  mtx[ 2 ][ 2 ] = 5.0f;
41  mtx[ 0 ][ 3 ] = 1.0f;
42  mtx[ 1 ][ 3 ] = 3.0f;
43  mtx[ 2 ][ 3 ] = 3.0f;
44 
45  mtx.shellSort( Mtx::Comp1 );
46 
47  TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
48  TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
49  TS_ASSERT_EQUALS( mtx( 0, 2 ), 5.0f );
50  TS_ASSERT_EQUALS( mtx( 0, 3 ), 2.0f );
51  TS_ASSERT_EQUALS( mtx( 1, 0 ), 2.0f );
52  TS_ASSERT_EQUALS( mtx( 1, 1 ), 3.0f );
53  TS_ASSERT_EQUALS( mtx( 1, 2 ), 4.0f );
54  TS_ASSERT_EQUALS( mtx( 1, 3 ), 5.0f );
55  TS_ASSERT_EQUALS( mtx( 2, 0 ), 5.0f );
56  TS_ASSERT_EQUALS( mtx( 2, 1 ), 3.0f );
57  TS_ASSERT_EQUALS( mtx( 2, 2 ), 1.0f );
58  TS_ASSERT_EQUALS( mtx( 2, 3 ), 5.0f );
59 
60  mtx.shellSort( Mtx::Comp01 );
61 
62  TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
63  TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
64  TS_ASSERT_EQUALS( mtx( 0, 2 ), 2.0f );
65  TS_ASSERT_EQUALS( mtx( 0, 3 ), 5.0f );
66  TS_ASSERT_EQUALS( mtx( 1, 0 ), 2.0f );
67  TS_ASSERT_EQUALS( mtx( 1, 1 ), 3.0f );
68  TS_ASSERT_EQUALS( mtx( 1, 2 ), 5.0f );
69  TS_ASSERT_EQUALS( mtx( 1, 3 ), 4.0f );
70  TS_ASSERT_EQUALS( mtx( 2, 0 ), 5.0f );
71  TS_ASSERT_EQUALS( mtx( 2, 1 ), 3.0f );
72  TS_ASSERT_EQUALS( mtx( 2, 2 ), 5.0f );
73  TS_ASSERT_EQUALS( mtx( 2, 3 ), 1.0f );
74 
75  mtx.shellSort( Mtx::Comp02 );
76 
77  TS_ASSERT_EQUALS( mtx( 0, 0 ), 1.0f );
78  TS_ASSERT_EQUALS( mtx( 0, 1 ), 1.0f );
79  TS_ASSERT_EQUALS( mtx( 0, 2 ), 2.0f );
80  TS_ASSERT_EQUALS( mtx( 0, 3 ), 5.0f );
81  TS_ASSERT_EQUALS( mtx( 1, 0 ), 3.0f );
82  TS_ASSERT_EQUALS( mtx( 1, 1 ), 2.0f );
83  TS_ASSERT_EQUALS( mtx( 1, 2 ), 5.0f );
84  TS_ASSERT_EQUALS( mtx( 1, 3 ), 4.0f );
85  TS_ASSERT_EQUALS( mtx( 2, 0 ), 3.0f );
86  TS_ASSERT_EQUALS( mtx( 2, 1 ), 5.0f );
87  TS_ASSERT_EQUALS( mtx( 2, 2 ), 5.0f );
88  TS_ASSERT_EQUALS( mtx( 2, 3 ), 1.0f );
89  }
90 
91 };
92 
93 #endif // _MTX_TEST_H
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
static int Comp02(const Mtx &lhs, int lhsJ, const Mtx &rhs, int rhsJ)
Comparison function for indexM = 0 AND indexM = 2;.
Definition: Mtx.cpp:376
Unit tests for Mtx class.
Definition: Mtx_Test.h:23
Definition: Mtx.h:24
static int Comp01(const Mtx &lhs, int lhsJ, const Mtx &rhs, int rhsJ)
Comparison function for indexM = 0 AND indexM = 1;.
Definition: Mtx.cpp:365
static int Comp1(const Mtx &lhs, int lhsJ, const Mtx &rhs, int rhsJ)
Comparison function for indexM = 1;.
Definition: Mtx.cpp:353
Contains the StrIOStream class declaration.
bool shellSort(int(&comp)(const Mtx &, int, const Mtx &, int))
Simple sort routine, invented by Donald Shell 1959.
Definition: Mtx.cpp:298
void testShellSort(void)
Test Mtx::shellSort.
Definition: Mtx_Test.h:28