--- /dev/null
+#ifndef booleanmatrix_h_ohYeiveiKanashie
+#define booleanmatrix_h_ohYeiveiKanashie
+
+#include <cpptest.h>
+#include <cpptest-suite.h>
+
+#include <libstick-0.1/booleanmatrix.h>
+
+using namespace libstick;
+
+
+class BooleanmatrixTestSuite: public Test::Suite {
+ public:
+ BooleanmatrixTestSuite() {
+ TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanRowMatrix<> >);
+ TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanColMatrix<> >);
+ TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanColRowMatrix<> >);
+
+ TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn<BooleanColMatrix<> >);
+ TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn<BooleanColRowMatrix<> >);
+
+ TEST_ADD(BooleanmatrixTestSuite::test_addgetrow<BooleanRowMatrix<> >);
+ TEST_ADD(BooleanmatrixTestSuite::test_addgetrow<BooleanColRowMatrix<> >);
+ }
+
+ protected:
+ virtual void setup() {
+ }
+
+ virtual void tear_down() {
+ }
+
+ private:
+ template<typename T>
+ void test_getsetsize() {
+ const unsigned size = 17;
+ T mat(size);
+
+ // Must all be zero
+ for (unsigned r=0; r < size; ++r)
+ for (unsigned c=0; c < size; ++c)
+ TEST_ASSERT(mat.get(r, c) == false);
+
+ // Set a few of them one
+ for (unsigned r=0; r < size; ++r)
+ for (unsigned c=0; c < size; ++c)
+ if ((257*c + 65537*r + 7)%11 == 0)
+ mat.set(r, c, true);
+
+ // Check if they are one
+ for (unsigned r=0; r < size; ++r)
+ for (unsigned c=0; c < size; ++c)
+ TEST_ASSERT(((257*c + 65537*r + 7)%11 == 0) == mat.get(r, c))
+ }
+
+ template<typename T>
+ void test_addgetcolumn() {
+ const unsigned size = 17;
+ T mat(size);
+ typename T::column_type col;
+
+ // Check if columns are empty
+ for (unsigned c=0; c < size; ++c)
+ TEST_ASSERT(mat.getColumn(c).size() == 0);
+
+ col.push_back(3);
+ col.push_back(14);
+ col.push_back(8);
+ col.push_back(0);
+
+ // Add column and test for values
+ mat.add_column(5, col);
+ for (unsigned c=0; c < size; ++c) {
+ if (c==5) {
+ for (unsigned r=0; r < size; ++r )
+ TEST_ASSERT(mat.get(r,c) == (r==0 || r==3 || r==8 || r==14));
+ } else {
+ TEST_ASSERT(mat.getColumn(c).size() == 0);
+ }
+ }
+ }
+
+ template<typename T>
+ void test_addgetrow() {
+ const unsigned size = 17;
+ T mat(size);
+ typename T::row_type row;
+
+ // Check if rows are empty
+ for (unsigned r=0; r < size; ++r)
+ TEST_ASSERT(mat.getRow(r).size() == 0);
+
+ row.push_back(0);
+ row.push_back(8);
+ row.push_back(14);
+ row.push_back(3);
+
+ // Add row and test for values
+ mat.add_row(5, row);
+ for (unsigned r=0; r < size; ++r) {
+ if (r==5) {
+ for (unsigned c=0; c < size; ++c )
+ TEST_ASSERT(mat.get(r,c) == (c==0 || c==3 || c==8 || c==14));
+ } else {
+ TEST_ASSERT(mat.getRow(r).size() == 0);
+ }
+ }
+ }
+};
+
+#endif