1 #ifndef booleanmatrix_h_ohYeiveiKanashie
2 #define booleanmatrix_h_ohYeiveiKanashie
5 #include <cpptest-suite.h>
7 #include <libstick-0.1/booleanmatrix.h>
9 using namespace libstick
;
12 class BooleanmatrixTestSuite
: public Test::Suite
{
14 BooleanmatrixTestSuite() {
15 TEST_ADD(BooleanmatrixTestSuite::test_getsetsize
<BooleanRowMatrix
<> >);
16 TEST_ADD(BooleanmatrixTestSuite::test_getsetsize
<BooleanColMatrix
<> >);
17 TEST_ADD(BooleanmatrixTestSuite::test_getsetsize
<BooleanColRowMatrix
<> >);
19 TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn
<BooleanColMatrix
<> >);
20 TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn
<BooleanColRowMatrix
<> >);
22 TEST_ADD(BooleanmatrixTestSuite::test_addgetrow
<BooleanRowMatrix
<> >);
23 TEST_ADD(BooleanmatrixTestSuite::test_addgetrow
<BooleanColRowMatrix
<> >);
27 virtual void setup() {
30 virtual void tear_down() {
35 void test_getsetsize() {
36 const unsigned size
= 17;
40 for (unsigned r
=0; r
< size
; ++r
)
41 for (unsigned c
=0; c
< size
; ++c
)
42 TEST_ASSERT(mat
.get(r
, c
) == false);
44 // Set a few of them one
45 for (unsigned r
=0; r
< size
; ++r
)
46 for (unsigned c
=0; c
< size
; ++c
)
47 if ((257*c
+ 65537*r
+ 7)%11 == 0)
50 // Check if they are one
51 for (unsigned r
=0; r
< size
; ++r
)
52 for (unsigned c
=0; c
< size
; ++c
)
53 TEST_ASSERT(((257*c
+ 65537*r
+ 7)%11 == 0) == mat
.get(r
, c
))
57 void test_addgetcolumn() {
58 const unsigned size
= 17;
60 typename
T::column_type col
;
62 // Check if columns are empty
63 for (unsigned c
=0; c
< size
; ++c
)
64 TEST_ASSERT(mat
.getColumn(c
).size() == 0);
71 // Add column and test for values
72 mat
.addColumn(5, col
);
73 for (unsigned c
=0; c
< size
; ++c
) {
75 for (unsigned r
=0; r
< size
; ++r
)
76 TEST_ASSERT(mat
.get(r
,c
) == (r
==0 || r
==3 || r
==8 || r
==14));
78 TEST_ASSERT(mat
.getColumn(c
).size() == 0);
84 void test_addgetrow() {
85 const unsigned size
= 17;
87 typename
T::row_type row
;
89 // Check if rows are empty
90 for (unsigned r
=0; r
< size
; ++r
)
91 TEST_ASSERT(mat
.getRow(r
).size() == 0);
98 // Add row and test for values
100 for (unsigned r
=0; r
< size
; ++r
) {
102 for (unsigned c
=0; c
< size
; ++c
)
103 TEST_ASSERT(mat
.get(r
,c
) == (c
==0 || c
==3 || c
==8 || c
==14));
105 TEST_ASSERT(mat
.getRow(r
).size() == 0);