| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * ContinuousValueTest.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: Sep 29, 2011
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "ContinuousValueTest.hpp"
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
| 23 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
| 24 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include "Parameters/Value.hpp"
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifdef HAVE_TESTRUNNER
 | 
|---|
| 29 | #include "UnitTestMain.hpp"
 | 
|---|
| 30 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| 31 | 
 | 
|---|
| 32 | // Registers the fixture into the 'registry'
 | 
|---|
| 33 | CPPUNIT_TEST_SUITE_REGISTRATION( ContinuousValueTest );
 | 
|---|
| 34 | 
 | 
|---|
| 35 | 
 | 
|---|
| 36 | void ContinuousValueTest::setUp()
 | 
|---|
| 37 | {
 | 
|---|
| 38 |   // failing asserts should be thrown
 | 
|---|
| 39 |   ASSERT_DO(Assert::Throw);
 | 
|---|
| 40 | 
 | 
|---|
| 41 |   ValidIntRange = new range<int>(1,4);
 | 
|---|
| 42 |   ValidVectorRange = new range<Vector>(Vector(0,1,2), Vector(10,11,12));
 | 
|---|
| 43 | }
 | 
|---|
| 44 | 
 | 
|---|
| 45 | void ContinuousValueTest::tearDown()
 | 
|---|
| 46 | {
 | 
|---|
| 47 |   delete ValidIntRange;
 | 
|---|
| 48 |   delete ValidVectorRange;
 | 
|---|
| 49 | }
 | 
|---|
| 50 | 
 | 
|---|
| 51 | /************************************ tests ***********************************/
 | 
|---|
| 52 | 
 | 
|---|
| 53 | /** Unit test for isValid.
 | 
|---|
| 54 |  *
 | 
|---|
| 55 |  */
 | 
|---|
| 56 | void ContinuousValueTest::isValidIntAsStringTest()
 | 
|---|
| 57 | {
 | 
|---|
| 58 |   // create instance
 | 
|---|
| 59 |   Value<int> test(*ValidIntRange);
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   // checking valid values
 | 
|---|
| 62 |   for (int i=1; i<=4;++i)
 | 
|---|
| 63 |     CPPUNIT_ASSERT_EQUAL(true, test.isValidAsString(toString(i)));
 | 
|---|
| 64 | 
 | 
|---|
| 65 |   // checking invalid values
 | 
|---|
| 66 |   for (int i=-10; i<=0;++i)
 | 
|---|
| 67 |     CPPUNIT_ASSERT_EQUAL(false, test.isValidAsString(toString(i)));
 | 
|---|
| 68 |   for (int i=5; i<=0;++i)
 | 
|---|
| 69 |     CPPUNIT_ASSERT_EQUAL(false, test.isValidAsString(toString(i)));
 | 
|---|
| 70 | }
 | 
|---|
| 71 | 
 | 
|---|
| 72 | /** Unit test for isValid.
 | 
|---|
| 73 |  *
 | 
|---|
| 74 |  */
 | 
|---|
| 75 | void ContinuousValueTest::isValidIntTest()
 | 
|---|
| 76 | {
 | 
|---|
| 77 |   // create instance
 | 
|---|
| 78 |   Value<int> test(*ValidIntRange);
 | 
|---|
| 79 | 
 | 
|---|
| 80 |   // checking valid values
 | 
|---|
| 81 |   for (int i=1; i<=4;++i)
 | 
|---|
| 82 |     CPPUNIT_ASSERT_EQUAL(true, test.isValid(i));
 | 
|---|
| 83 | 
 | 
|---|
| 84 |   // checking invalid values
 | 
|---|
| 85 |   for (int i=-10; i<=0;++i)
 | 
|---|
| 86 |     CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
 | 
|---|
| 87 |   for (int i=5; i<=0;++i)
 | 
|---|
| 88 |     CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
 | 
|---|
| 89 | }
 | 
|---|
| 90 | 
 | 
|---|
| 91 | /** Unit test for setting/getting valid range.
 | 
|---|
| 92 |  *
 | 
|---|
| 93 |  */
 | 
|---|
| 94 | void ContinuousValueTest::setgetValidIntRangeTest()
 | 
|---|
| 95 | {
 | 
|---|
| 96 |   {
 | 
|---|
| 97 |     // create instance
 | 
|---|
| 98 |     Value<int> test(*ValidIntRange);
 | 
|---|
| 99 | 
 | 
|---|
| 100 |     // extending range and checking
 | 
|---|
| 101 |     for (int i=5; i<=6;++i)
 | 
|---|
| 102 |       CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
 | 
|---|
| 103 |     test.setValidRange(range<int>(1,6));
 | 
|---|
| 104 |     for (int i=5; i<=6;++i)
 | 
|---|
| 105 |       CPPUNIT_ASSERT_EQUAL(true, test.isValid(i));
 | 
|---|
| 106 |   }
 | 
|---|
| 107 | 
 | 
|---|
| 108 |   {
 | 
|---|
| 109 |     // create instance
 | 
|---|
| 110 |     Value<int> test(*ValidIntRange);
 | 
|---|
| 111 | 
 | 
|---|
| 112 |     // lowering range with set value
 | 
|---|
| 113 |     test.set(4);
 | 
|---|
| 114 |     CPPUNIT_ASSERT_EQUAL(true, test.ValueSet);
 | 
|---|
| 115 |     std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 116 |     CPPUNIT_ASSERT_THROW(test.setValidRange(range<int>(1,3)), ParameterValueException);
 | 
|---|
| 117 | 
 | 
|---|
| 118 |     // no value is not set
 | 
|---|
| 119 |     std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 120 |     CPPUNIT_ASSERT_THROW(test.get(), ParameterValueException);
 | 
|---|
| 121 | 
 | 
|---|
| 122 |     // value gets invalidated in either case
 | 
|---|
| 123 |     CPPUNIT_ASSERT_EQUAL(false, test.ValueSet);
 | 
|---|
| 124 |   }
 | 
|---|
| 125 | }
 | 
|---|
| 126 | 
 | 
|---|
| 127 | /** Unit test for setValue and getValue.
 | 
|---|
| 128 |  *
 | 
|---|
| 129 |  */
 | 
|---|
| 130 | void ContinuousValueTest::settergetterIntAsStringTest()
 | 
|---|
| 131 | {
 | 
|---|
| 132 |   // create instance
 | 
|---|
| 133 |   Value<int> test(*ValidIntRange);
 | 
|---|
| 134 | 
 | 
|---|
| 135 |   // unset calling of get, throws ParameterValueException
 | 
|---|
| 136 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 137 |   CPPUNIT_ASSERT_THROW(test.getAsString(), ParameterValueException);
 | 
|---|
| 138 | 
 | 
|---|
| 139 |   // setting invalid, throws ParameterValueException
 | 
|---|
| 140 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 141 |   CPPUNIT_ASSERT_THROW(test.setAsString(toString(5)), ParameterValueException);
 | 
|---|
| 142 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 143 |   CPPUNIT_ASSERT_THROW(test.setAsString(toString(0)), ParameterValueException);
 | 
|---|
| 144 | 
 | 
|---|
| 145 |   CPPUNIT_ASSERT_EQUAL(false, test.ValueSet);
 | 
|---|
| 146 |   // checking all valid ones
 | 
|---|
| 147 |   for (int i=1; i<=4;++i) {
 | 
|---|
| 148 |     test.setAsString(toString(i));
 | 
|---|
| 149 |     CPPUNIT_ASSERT_EQUAL(true, test.ValueSet);
 | 
|---|
| 150 |     CPPUNIT_ASSERT_EQUAL(toString(i), test.getAsString());
 | 
|---|
| 151 |   }
 | 
|---|
| 152 | }
 | 
|---|
| 153 | 
 | 
|---|
| 154 | /** Unit test for setters and getters.
 | 
|---|
| 155 |  *
 | 
|---|
| 156 |  */
 | 
|---|
| 157 | void ContinuousValueTest::settergetterIntTest()
 | 
|---|
| 158 | {
 | 
|---|
| 159 |   // create instance
 | 
|---|
| 160 |   Value<int> test(*ValidIntRange);
 | 
|---|
| 161 | 
 | 
|---|
| 162 |   // unset calling of get, throws ParameterValueException
 | 
|---|
| 163 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 164 |   CPPUNIT_ASSERT_THROW(test.get(), ParameterValueException);
 | 
|---|
| 165 | 
 | 
|---|
| 166 |   // setting invalid, throws ParameterValueException
 | 
|---|
| 167 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 168 |   CPPUNIT_ASSERT_THROW(test.set(5), ParameterValueException);
 | 
|---|
| 169 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 170 |   CPPUNIT_ASSERT_THROW(test.set(0), ParameterValueException);
 | 
|---|
| 171 | 
 | 
|---|
| 172 |   // checking all valid ones
 | 
|---|
| 173 |   for (int i=1; i<=4;++i) {
 | 
|---|
| 174 |     test.set(i);
 | 
|---|
| 175 |     CPPUNIT_ASSERT_EQUAL(i, test.get());
 | 
|---|
| 176 |   }
 | 
|---|
| 177 | }
 | 
|---|
| 178 | 
 | 
|---|
| 179 | /** Unit test for comparator.
 | 
|---|
| 180 |  *
 | 
|---|
| 181 |  */
 | 
|---|
| 182 | void ContinuousValueTest::comparatorIntTest()
 | 
|---|
| 183 | {
 | 
|---|
| 184 |   {
 | 
|---|
| 185 |     // create instance
 | 
|---|
| 186 |     Value<int> test(*ValidIntRange);
 | 
|---|
| 187 |     Value<int> instance(*ValidIntRange);
 | 
|---|
| 188 |     test.set(1);
 | 
|---|
| 189 |     instance.set(1);
 | 
|---|
| 190 | 
 | 
|---|
| 191 |     // same value, same range
 | 
|---|
| 192 |     {
 | 
|---|
| 193 |       CPPUNIT_ASSERT(test == instance);
 | 
|---|
| 194 |     }
 | 
|---|
| 195 | 
 | 
|---|
| 196 |     // different value, same range
 | 
|---|
| 197 |     {
 | 
|---|
| 198 |       const int oldvalue = instance.get();
 | 
|---|
| 199 |       instance.set(2);
 | 
|---|
| 200 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 201 |       instance.set(oldvalue);
 | 
|---|
| 202 |     }
 | 
|---|
| 203 |   }
 | 
|---|
| 204 |   {
 | 
|---|
| 205 |     Value<int> test(*ValidIntRange);
 | 
|---|
| 206 |     range<int> OtherValidIntRange(1,5);
 | 
|---|
| 207 |     Value<int> instance(OtherValidIntRange);
 | 
|---|
| 208 | 
 | 
|---|
| 209 |     test.set(1);
 | 
|---|
| 210 |     instance.set(1);
 | 
|---|
| 211 | 
 | 
|---|
| 212 |     // same value, same range
 | 
|---|
| 213 |     {
 | 
|---|
| 214 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 215 |     }
 | 
|---|
| 216 | 
 | 
|---|
| 217 |     // different value, same range
 | 
|---|
| 218 |     {
 | 
|---|
| 219 |       const int oldvalue = instance.get();
 | 
|---|
| 220 |       instance.set(2);
 | 
|---|
| 221 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 222 |       instance.set(oldvalue);
 | 
|---|
| 223 |     }
 | 
|---|
| 224 |   }
 | 
|---|
| 225 | }
 | 
|---|
| 226 | 
 | 
|---|
| 227 | 
 | 
|---|
| 228 | 
 | 
|---|
| 229 | /***************************** vector tests ***********************************/
 | 
|---|
| 230 | 
 | 
|---|
| 231 | /** Unit test for isValid.
 | 
|---|
| 232 |  *
 | 
|---|
| 233 |  */
 | 
|---|
| 234 | void ContinuousValueTest::isValidVectorAsStringTest()
 | 
|---|
| 235 | {
 | 
|---|
| 236 |   // create instance
 | 
|---|
| 237 |   /*ContinuousValue<Vector> test(*ValidVectorRange);
 | 
|---|
| 238 | 
 | 
|---|
| 239 |   // checking valid values
 | 
|---|
| 240 |   CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(Vector(0,1,2)));
 | 
|---|
| 241 |   CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(Vector(9.9,10.9,11.9)));
 | 
|---|
| 242 |   CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(Vector(5,5,5)));
 | 
|---|
| 243 | 
 | 
|---|
| 244 |   // checking invalid values
 | 
|---|
| 245 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(-0.1,0.9,1.9)));
 | 
|---|
| 246 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(10.1,11.1,12.1)));
 | 
|---|
| 247 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,5,-1)));
 | 
|---|
| 248 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,-1,5)));
 | 
|---|
| 249 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(-1,5,5)));
 | 
|---|
| 250 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,5,20)));
 | 
|---|
| 251 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,20,5)));
 | 
|---|
| 252 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(20,5,5)));
 | 
|---|
| 253 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(0,0,0)));
 | 
|---|
| 254 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,-1,-1)));
 | 
|---|
| 255 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(-1,5,-1)));
 | 
|---|
| 256 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(-1,-1,5)));
 | 
|---|
| 257 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(5,20,20)));
 | 
|---|
| 258 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(20,5,20)));
 | 
|---|
| 259 |   CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(Vector(20,20,5)));*/
 | 
|---|
| 260 | }
 | 
|---|
| 261 | 
 | 
|---|
| 262 | /** Unit test for isValid.
 | 
|---|
| 263 |  *
 | 
|---|
| 264 |  */
 | 
|---|
| 265 | void ContinuousValueTest::isValidVectorTest()
 | 
|---|
| 266 | {
 | 
|---|
| 267 |   // create instance
 | 
|---|
| 268 |   Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 269 | 
 | 
|---|
| 270 |   // checking valid values
 | 
|---|
| 271 |   CPPUNIT_ASSERT_EQUAL(true, test.isValid(Vector(0,1,2)));
 | 
|---|
| 272 |   CPPUNIT_ASSERT_EQUAL(true, test.isValid(Vector(9.9,10.9,11.9)));
 | 
|---|
| 273 |   CPPUNIT_ASSERT_EQUAL(true, test.isValid(Vector(5,5,5)));
 | 
|---|
| 274 | 
 | 
|---|
| 275 |   // checking invalid values
 | 
|---|
| 276 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(-0.1,0.9,1.9)));
 | 
|---|
| 277 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(10.1,11.1,12.1)));
 | 
|---|
| 278 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,5,-1)));
 | 
|---|
| 279 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,-1,5)));
 | 
|---|
| 280 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(-1,5,5)));
 | 
|---|
| 281 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,5,20)));
 | 
|---|
| 282 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,20,5)));
 | 
|---|
| 283 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(20,5,5)));
 | 
|---|
| 284 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(0,0,0)));
 | 
|---|
| 285 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,-1,-1)));
 | 
|---|
| 286 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(-1,5,-1)));
 | 
|---|
| 287 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(-1,-1,5)));
 | 
|---|
| 288 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(5,20,20)));
 | 
|---|
| 289 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(20,5,20)));
 | 
|---|
| 290 |   CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(20,20,5)));
 | 
|---|
| 291 | }
 | 
|---|
| 292 | 
 | 
|---|
| 293 | /** Unit test for setting/getting valid range.
 | 
|---|
| 294 |  *
 | 
|---|
| 295 |  */
 | 
|---|
| 296 | void ContinuousValueTest::setgetValidVectorRangeTest()
 | 
|---|
| 297 | {
 | 
|---|
| 298 |   {
 | 
|---|
| 299 |     // create instance
 | 
|---|
| 300 |     Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 301 | 
 | 
|---|
| 302 |     // extending range and checking
 | 
|---|
| 303 |     for (int i=15; i<=16;++i)
 | 
|---|
| 304 |       CPPUNIT_ASSERT_EQUAL(false, test.isValid(Vector(i,5,5)));
 | 
|---|
| 305 |     test.setValidRange(range<Vector>(Vector(0,1,2),Vector(20,11,12)));
 | 
|---|
| 306 |     for (int i=15; i<=16;++i)
 | 
|---|
| 307 |       CPPUNIT_ASSERT_EQUAL(true, test.isValid(Vector(i,5,5)));
 | 
|---|
| 308 |   }
 | 
|---|
| 309 | 
 | 
|---|
| 310 |   {
 | 
|---|
| 311 |     // create instance
 | 
|---|
| 312 |     Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 313 | 
 | 
|---|
| 314 |     // lowering range with set value
 | 
|---|
| 315 |     test.set(Vector(4,4,4));
 | 
|---|
| 316 |     CPPUNIT_ASSERT_EQUAL(true, test.ValueSet);
 | 
|---|
| 317 |     std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 318 |     CPPUNIT_ASSERT_THROW(test.setValidRange(range<Vector>(Vector(1,1,1),Vector(3,3,3))), ParameterValueException);
 | 
|---|
| 319 | 
 | 
|---|
| 320 |     // no value is not set
 | 
|---|
| 321 |     std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 322 |     CPPUNIT_ASSERT_THROW(test.get(), ParameterException);
 | 
|---|
| 323 | 
 | 
|---|
| 324 |     // value gets invalidated in either case
 | 
|---|
| 325 |     CPPUNIT_ASSERT_EQUAL(false, test.ValueSet);
 | 
|---|
| 326 |   }
 | 
|---|
| 327 | }
 | 
|---|
| 328 | 
 | 
|---|
| 329 | /** Unit test for setValue and getValue.
 | 
|---|
| 330 |  *
 | 
|---|
| 331 |  */
 | 
|---|
| 332 | void ContinuousValueTest::settergetterVectorAsStringTest()
 | 
|---|
| 333 | {
 | 
|---|
| 334 |   // create instance
 | 
|---|
| 335 |   /*Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 336 | 
 | 
|---|
| 337 |   // unset calling of get, throws
 | 
|---|
| 338 | #ifndef NDEBUG
 | 
|---|
| 339 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 340 |   CPPUNIT_ASSERT_THROW(test.getValue(), Assert::AssertionFailure);
 | 
|---|
| 341 | #endif
 | 
|---|
| 342 | 
 | 
|---|
| 343 |   // setting invalid, throws
 | 
|---|
| 344 | #ifndef NDEBUG
 | 
|---|
| 345 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 346 |   CPPUNIT_ASSERT_THROW(test.setValue(Vector(5,0,0)), Assert::AssertionFailure);
 | 
|---|
| 347 | #endif
 | 
|---|
| 348 | #ifndef NDEBUG
 | 
|---|
| 349 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 350 |   CPPUNIT_ASSERT_THROW(test.setValue(Vector(5,20,5)), Assert::AssertionFailure);
 | 
|---|
| 351 | #endif
 | 
|---|
| 352 | 
 | 
|---|
| 353 |   CPPUNIT_ASSERT_EQUAL(false, test.ValueSet);
 | 
|---|
| 354 |   // checking some valid ones
 | 
|---|
| 355 |   for (int i=1; i<=4;++i) {
 | 
|---|
| 356 |     Vector v(i,5,5);
 | 
|---|
| 357 |     test.setValue(v);
 | 
|---|
| 358 |     CPPUNIT_ASSERT_EQUAL(true, test.ValueSet);
 | 
|---|
| 359 |     CPPUNIT_ASSERT_EQUAL(v, test.getValue());
 | 
|---|
| 360 |   }*/
 | 
|---|
| 361 | }
 | 
|---|
| 362 | 
 | 
|---|
| 363 | /** Unit test for setters and getters.
 | 
|---|
| 364 |  *
 | 
|---|
| 365 |  */
 | 
|---|
| 366 | void ContinuousValueTest::settergetterVectorTest()
 | 
|---|
| 367 | {
 | 
|---|
| 368 |   // create instance
 | 
|---|
| 369 |   Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 370 | 
 | 
|---|
| 371 |   // unset calling of get, throws
 | 
|---|
| 372 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 373 |   CPPUNIT_ASSERT_THROW(test.get(), ParameterValueException);
 | 
|---|
| 374 | 
 | 
|---|
| 375 |   // setting invalid, throws
 | 
|---|
| 376 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 377 |   CPPUNIT_ASSERT_THROW(test.set(Vector(5,0,0)), ParameterValueException);
 | 
|---|
| 378 |   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
 | 
|---|
| 379 |   CPPUNIT_ASSERT_THROW(test.set(Vector(5,20,5)), ParameterValueException);
 | 
|---|
| 380 | 
 | 
|---|
| 381 |   CPPUNIT_ASSERT_EQUAL(false, test.ValueSet);
 | 
|---|
| 382 |   // checking some valid ones
 | 
|---|
| 383 |   for (int i=1; i<=4;++i) {
 | 
|---|
| 384 |     Vector v(i,5,5);
 | 
|---|
| 385 |     test.set(v);
 | 
|---|
| 386 |     CPPUNIT_ASSERT_EQUAL(true, test.ValueSet);
 | 
|---|
| 387 |     CPPUNIT_ASSERT_EQUAL(v, test.get());
 | 
|---|
| 388 |   }
 | 
|---|
| 389 | }
 | 
|---|
| 390 | 
 | 
|---|
| 391 | /** Unit test for comparator.
 | 
|---|
| 392 |  *
 | 
|---|
| 393 |  */
 | 
|---|
| 394 | void ContinuousValueTest::comparatorVectorTest()
 | 
|---|
| 395 | {
 | 
|---|
| 396 |   {
 | 
|---|
| 397 |     // create instance
 | 
|---|
| 398 |     Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 399 |     Value<Vector> instance(*ValidVectorRange);
 | 
|---|
| 400 |     test.set(Vector(5,6,7));
 | 
|---|
| 401 |     instance.set(Vector(5,6,7));
 | 
|---|
| 402 | 
 | 
|---|
| 403 |     // same value, same range
 | 
|---|
| 404 |     {
 | 
|---|
| 405 |       CPPUNIT_ASSERT(test == instance);
 | 
|---|
| 406 |     }
 | 
|---|
| 407 | 
 | 
|---|
| 408 |     // different value, same range
 | 
|---|
| 409 |     {
 | 
|---|
| 410 |       const Vector oldvalue = instance.get();
 | 
|---|
| 411 |       instance.set(Vector(2,3,4));
 | 
|---|
| 412 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 413 |       instance.set(oldvalue);
 | 
|---|
| 414 |     }
 | 
|---|
| 415 |   }
 | 
|---|
| 416 |   {
 | 
|---|
| 417 |     Value<Vector> test(*ValidVectorRange);
 | 
|---|
| 418 |     range<Vector> OtherValidVectorRange(Vector(0,1,2), Vector(20,21,22));
 | 
|---|
| 419 |     Value<Vector> instance(OtherValidVectorRange);
 | 
|---|
| 420 | 
 | 
|---|
| 421 |     test.set(Vector(1,2,3));
 | 
|---|
| 422 |     instance.set(Vector(1,2,3));
 | 
|---|
| 423 | 
 | 
|---|
| 424 |     // same value, same range
 | 
|---|
| 425 |     {
 | 
|---|
| 426 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 427 |     }
 | 
|---|
| 428 | 
 | 
|---|
| 429 |     // different value, same range
 | 
|---|
| 430 |     {
 | 
|---|
| 431 |       const Vector oldvalue = instance.get();
 | 
|---|
| 432 |       instance.set(Vector(2,3,4));
 | 
|---|
| 433 |       CPPUNIT_ASSERT(test != instance);
 | 
|---|
| 434 |       instance.set(oldvalue);
 | 
|---|
| 435 |     }
 | 
|---|
| 436 |   }
 | 
|---|
| 437 | }
 | 
|---|