25 #ifndef WPROPERTYVARIABLE_TEST_H
26 #define WPROPERTYVARIABLE_TEST_H
30 #include <cxxtest/TestSuite.h>
32 #include "../WPropertyVariable.h"
33 #include "../constraints/WPropertyConstraintMin.h"
34 #include "../constraints/WPropertyConstraintMax.h"
36 #include "../exceptions/WPropertyNotUnique.h"
37 #include "../exceptions/WPropertyUnknown.h"
38 #include "../exceptions/WPropertyNameMalformed.h"
77 boost::shared_ptr< WPropertyVariable< bool > > p;
81 TS_ASSERT( p->getName() ==
"hey" );
82 TS_ASSERT( p->getDescription() ==
"you" );
83 TS_ASSERT( p->getType() == PV_BOOL );
85 TS_ASSERT_THROWS_NOTHING( p.reset() );
95 boost::shared_ptr< WPropertyVariable< bool > > p;
111 boost::shared_ptr< WPropertyVariable< int > > p =
121 boost::shared_ptr< WPropertyVariable< int > > clone = p->clone()->toPropInt();
125 TS_ASSERT( clone->getType() == PV_INT );
126 TS_ASSERT( clone->getName() == p->getName() );
127 TS_ASSERT( clone->getDescription() == p->getDescription() );
128 TS_ASSERT( clone->getPurpose() == p->getPurpose() );
131 TS_ASSERT( p->get() == clone->get() );
134 TS_ASSERT( p->getContraintsChangedCondition() != clone->getContraintsChangedCondition() );
135 TS_ASSERT( p->getUpdateCondition() != clone->getUpdateCondition() );
138 TS_ASSERT( p->getMin() != clone->getMin() );
139 TS_ASSERT( p->getMax() != clone->getMax() );
141 TS_ASSERT( p->getMin()->getMin() == clone->getMin()->getMin() );
143 TS_ASSERT( p->getMax()->getMax() == clone->getMax()->getMax() );
167 clone->removeConstraint( PC_MIN );
174 p->removeConstraint( PC_MIN );
187 boost::shared_ptr< WPropertyVariable< int > > p =
197 TS_ASSERT( p->set( 123 ) );
198 TS_ASSERT( p->get() == 123 );
199 TS_ASSERT( p->accept( 12345 ) );
208 TS_ASSERT( cmin == p->getMin() );
209 TS_ASSERT( cmax == p->
getMax() );
212 TS_ASSERT( p->set( 10 ) );
213 TS_ASSERT( p->get() == 10 );
216 TS_ASSERT( !p->set( 9 ) );
217 TS_ASSERT( p->get() == 10 );
218 TS_ASSERT( !p->set( 16 ) );
219 TS_ASSERT( p->get() == 10 );
224 p->m_constraints->getReadTicket()->get().size();
227 TS_ASSERT( p->set( 9 ) );
228 TS_ASSERT( p->get() == 9 );
229 TS_ASSERT( p->set( 16 ) );
230 TS_ASSERT( p->get() == 16 );
236 TS_ASSERT( p->ensureValidity( 10 ) );
237 TS_ASSERT( p->get() == 16 );
240 TS_ASSERT( p->isValid() );
242 TS_ASSERT( !p->isValid() );
243 TS_ASSERT( p->get() == 16 );
246 TS_ASSERT( p->ensureValidity( 18 ) );
247 TS_ASSERT( p->get() == 18 );
248 TS_ASSERT( p->isValid() );
252 TS_ASSERT( !p->ensureValidity( 16 ) );
253 TS_ASSERT( !p->isValid() );
254 TS_ASSERT( p->get() == 18 );
265 boost::shared_ptr< WPropertyVariable< int > > p =
278 p->addConstraint( cmin );
279 TS_ASSERT( p->m_constraints->getReadTicket()->get().size() == 1 );
287 TS_ASSERT( p->countConstraint( PC_MIN ) == 1 );
288 TS_ASSERT( p->countConstraint( PC_MAX ) == 0 );
292 TS_ASSERT( !p->getFirstConstraint( PC_MAX ) );
304 TS_ASSERT_THROWS_NOTHING( p->replaceConstraint( cmax, PC_MAX ) );
311 p->replaceConstraint( cmax2, PC_MAX );
320 p->removeConstraint( PC_NOTEMPTY );
321 TS_ASSERT( !m_testTemporary1 );
324 m_testTemporary1 =
false;
325 TS_ASSERT( p->countConstraint( PC_MAX ) == 1 );
326 p->removeConstraint( PC_MAX );
327 TS_ASSERT( p->countConstraint( PC_MAX ) == 0 );
328 TS_ASSERT( m_testTemporary1 );
331 m_testTemporary1 =
false;
332 TS_ASSERT( p->countConstraint( PC_MIN ) == 1 );
333 p->removeConstraint( cmin );
334 TS_ASSERT( p->countConstraint( PC_MIN ) == 0 );
335 TS_ASSERT( m_testTemporary1 );
339 #endif // WPROPERTYVARIABLE_TEST_H