1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/CONCEPT/classTest.h>
///////////////////////////
#include <BALL/CONCEPT/composite.h>
#include <BALL/KERNEL/iterator.h>
#include <BALL/CONCEPT/predicate.h>
///////////////////////////
using namespace BALL;
class MyPred
: public UnaryPredicate<Composite>
{
public:
MyPred(const Composite& my_comp)
: composite_(&my_comp)
{
}
virtual bool operator () (const Composite& composite) const throw()
{
return (&composite == composite_);
}
const Composite* composite_;
};
START_TEST(CompositeIteratorTraits)
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
CompositeIteratorTraits* cit_ptr = 0;
CHECK(CompositeIteratorTraits() throw())
cit_ptr = new CompositeIteratorTraits;
TEST_NOT_EQUAL(cit_ptr, 0)
RESULT
CHECK(~CompositeIteratorTraits() throw())
delete cit_ptr;
RESULT
CHECK(Composite* getContainer() throw())
CompositeIteratorTraits t;
TEST_EQUAL(t.getContainer(), 0)
RESULT
Composite a;
Composite b;
Composite c;
Composite d;
Composite e;
Composite f;
a.appendChild(b);
a.appendChild(c);
a.appendChild(d);
c.appendChild(e);
c.appendChild(f);
CHECK(CompositeIteratorTraits(const Composite& composite) throw())
CompositeIteratorTraits t(a);
TEST_EQUAL(t.getContainer(), &a)
MyPred p(c);
TEST_EQUAL(p(a), false)
TEST_EQUAL(p(b), false)
TEST_EQUAL(p(c), true)
TEST_EQUAL(p(d), false)
TEST_EQUAL(p(e), false)
TEST_EQUAL(p(f), false)
STATUS(" &a = " << (void*)&a)
STATUS(" &b = " << (void*)&b)
STATUS(" &c = " << (void*)&c)
STATUS(" &d = " << (void*)&d)
STATUS(" &e = " << (void*)&e)
STATUS(" &f = " << (void*)&f)
t.setPredicate(p);
t.toBegin();
TEST_EQUAL(t.isValid(), true)
TEST_EQUAL(&t.getData(), &c)
t.forward();
TEST_EQUAL(t.isValid(), false)
TEST_EQUAL(t.isEnd(), true)
TEST_EQUAL(t.getPredicate(), &p)
RESULT
CHECK(Composite& getData() throw())
// ???
RESULT
CHECK(Composite::SubcompositeIterator& getPosition() throw())
// ???
RESULT
CHECK(CompositeIteratorTraits& operator = (const CompositeIteratorTraits& traits) throw())
// ???
RESULT
CHECK(CompositeIteratorTraits(const CompositeIteratorTraits& traits) throw())
// ???
RESULT
CHECK(void toBegin())
// ???
RESULT
CHECK(void toEnd())
// ???
RESULT
CHECK(bool isBegin() const throw())
CompositeIteratorTraits t(a);
TEST_EQUAL(t.getContainer(), &a)
MyPred p(c);
t.setPredicate(p);
t.toBegin();
TEST_EQUAL(t.isBegin(), true)
t.forward();
TEST_EQUAL(t.isBegin(), false)
RESULT
CHECK(bool isEnd() const throw())
CompositeIteratorTraits t(a);
TEST_EQUAL(t.getContainer(), &a)
MyPred p(c);
t.setPredicate(p);
t.toBegin();
TEST_EQUAL(t.isEnd(), false)
t.toEnd();
TEST_EQUAL(t.isEnd(), true)
RESULT
CHECK(bool isRBegin() const throw())
// ???
RESULT
CHECK(bool isREnd() const throw())
// ???
RESULT
CHECK(bool isSingular() const throw())
// ???
RESULT
CHECK(bool isValid() const throw())
// ???
RESULT
CHECK(bool operator != (const CompositeIteratorTraits& traits) const throw())
// ???
RESULT
CHECK(bool operator == (const CompositeIteratorTraits& traits) const throw())
// ???
RESULT
CHECK(const Composite& getData() const throw())
// ???
RESULT
CHECK(const Composite* getContainer() const throw())
// ???
RESULT
CHECK(const Composite::SubcompositeIterator& getPosition() const throw())
// ???
RESULT
CHECK(const UnaryPredicate<Composite>* getPredicate() const throw())
// ???
RESULT
CHECK(void backward() throw())
// ???
RESULT
CHECK(void forward() throw())
// ???
RESULT
CHECK(void invalidate() throw())
// ???
RESULT
CHECK(void setPredicate(const UnaryPredicate<Composite>& predicate) throw())
// ???
RESULT
CHECK(void toRBegin())
// ???
RESULT
CHECK(void toREnd())
// ???
RESULT
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
|