1 #ifndef booleanvector_h_MeiTephaijaequuy
2 #define booleanvector_h_MeiTephaijaequuy
5 #include <cpptest-suite.h>
7 #include <libstick-0.1/booleanvector.h>
9 using namespace libstick
;
12 class boolean_vector_TestSuite
: public Test::Suite
{
14 boolean_vector_TestSuite() {
15 TEST_ADD(boolean_vector_TestSuite::test
<sorted_boolean_vector
<int> >);
16 TEST_ADD(boolean_vector_TestSuite::test
<heapsorted_boolean_vector
<int> >);
18 //TEST_ADD(boolean_vector_TestSuite::test_performance<sorted_boolean_vector<int> >);
19 //TEST_ADD(boolean_vector_TestSuite::test_performance<heapsorted_boolean_vector<int> >);
23 virtual void setup() {
26 virtual void tear_down() {
32 const int size
= 1000;
35 for (int i
=1; 2*i
<= size
; ++i
)
38 // We added size/2 ones, all of them at even indices.
39 TEST_ASSERT(even
.get_ones().size() == size
/2);
40 for (typename
T::indexarray::const_iterator it
= even
.get_ones().begin();
41 it
!= even
.get_ones().end(); ++it
)
42 TEST_ASSERT(*it
% 2 == 0);
43 for (int i
=1; i
<= size
; ++i
)
44 TEST_ASSERT(even
.get(i
) == (i
% 2 == 0));
48 for (int i
=1; i
<= size
; ++i
)
51 // A vector with all odd entries
55 // Again size/2 entries in odd.
56 TEST_ASSERT(odd
.get_ones().size() == size
/2);
57 // Check whether we really have odd indices only
58 for (typename
T::indexarray::const_iterator it
= odd
.get_ones().begin();
59 it
!= odd
.get_ones().end(); ++it
)
60 TEST_ASSERT(*it
% 2 == 1);
61 for (int i
=1; i
<= size
; ++i
)
62 TEST_ASSERT(odd
.get(i
) == (i
% 2 == 1));
69 TEST_ASSERT(all2
== all
);
73 void test_performance() {
76 const int size
= 1000;
80 for (int a
=0; a
< cnt
; ++a
) {
82 for (int i
=0; i
< size
; ++i
)
83 summand
.set(a
*(size
/2) + i
, true);
87 //for (int i=0; i < size/2; ++i) {
88 //TEST_ASSERT(sum.get(i) == true);
89 //TEST_ASSERT(sum.get(i + size/2) == false);
90 //TEST_ASSERT(sum.get(i + (cnt-1)*(size/2)) == false);
91 //TEST_ASSERT(sum.get(i + (cnt)*(size/2)) == true);
94 //std::cout << std::endl << sum << std::endl;