| [b5ebb5] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
 | 4 |  * Copyright (C)  2011 University of Bonn. All rights reserved.
 | 
|---|
 | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | /*
 | 
|---|
 | 9 |  * FragmentQueueUnitTest.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: Oct 23, 2011
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
 | 21 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
 | 22 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | #include "FragmentQueueUnitTest.hpp"
 | 
|---|
 | 25 | 
 | 
|---|
| [9875cc] | 26 | #include <vector>
 | 
|---|
 | 27 | 
 | 
|---|
| [02f346] | 28 | #include "CodePatterns/Assert.hpp"
 | 
|---|
| [9875cc] | 29 | #include "FragmentQueue.hpp"
 | 
|---|
 | 30 | 
 | 
|---|
| [d6b12c] | 31 | #include "CodePatterns/Observer/Channels.hpp"
 | 
|---|
| [02f346] | 32 | 
 | 
|---|
| [b5ebb5] | 33 | #ifdef HAVE_TESTRUNNER
 | 
|---|
 | 34 | #include "UnitTestMain.hpp"
 | 
|---|
 | 35 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | /********************************************** Test classes **************************************/
 | 
|---|
 | 38 | 
 | 
|---|
| [d920b9] | 39 | #include "stubs/FragmentJobStub.hpp"
 | 
|---|
| [d6b12c] | 40 | #include "unittests/stubs/ObserverStub.hpp"
 | 
|---|
| [d920b9] | 41 | 
 | 
|---|
| [b5ebb5] | 42 | // Registers the fixture into the 'registry'
 | 
|---|
 | 43 | CPPUNIT_TEST_SUITE_REGISTRATION( FragmentQueueTest );
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 | void FragmentQueueTest::setUp()
 | 
|---|
 | 47 | {
 | 
|---|
| [02f346] | 48 |   // Throw assertions
 | 
|---|
 | 49 |   ASSERT_DO(Assert::Throw);
 | 
|---|
 | 50 | 
 | 
|---|
| [b5ebb5] | 51 |   queue = new FragmentQueue();
 | 
|---|
| [d6b12c] | 52 |   addobserver = new NotificationObserver(queue->getChannel(FragmentQueue::JobAdded));
 | 
|---|
 | 53 |   removeobserver = new NotificationObserver(queue->getChannel(FragmentQueue::JobRemoved));
 | 
|---|
 | 54 | 
 | 
|---|
 | 55 |   // and sign on
 | 
|---|
 | 56 |   queue->signOn(addobserver, FragmentQueue::JobAdded);
 | 
|---|
 | 57 |   queue->signOn(removeobserver, FragmentQueue::JobRemoved);
 | 
|---|
| [b5ebb5] | 58 | }
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | void FragmentQueueTest::tearDown()
 | 
|---|
 | 62 | {
 | 
|---|
| [d6b12c] | 63 |   queue->signOff(addobserver, FragmentQueue::JobAdded);
 | 
|---|
 | 64 |   queue->signOff(removeobserver, FragmentQueue::JobRemoved);
 | 
|---|
 | 65 | 
 | 
|---|
| [b5ebb5] | 66 |   delete queue;
 | 
|---|
| [d6b12c] | 67 |   delete removeobserver;
 | 
|---|
 | 68 |   delete addobserver;
 | 
|---|
| [b5ebb5] | 69 | }
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | /** UnitTest for working JobQueue
 | 
|---|
 | 72 |  */
 | 
|---|
| [9875cc] | 73 | void FragmentQueueTest::JobTest()
 | 
|---|
| [b5ebb5] | 74 | {
 | 
|---|
| [d920b9] | 75 |   FragmentJob::ptr testJob(new FragmentJobStub(JobId::IllegalJob));
 | 
|---|
| [02f346] | 76 |   /// check for illegal id
 | 
|---|
 | 77 | #ifndef NDEBUG
 | 
|---|
 | 78 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 79 |   CPPUNIT_ASSERT_THROW( queue->pushJob(testJob), Assert::AssertionFailure );
 | 
|---|
 | 80 | #endif
 | 
|---|
 | 81 |   // set to valid id
 | 
|---|
| [78ad7d] | 82 |   testJob->setId(1);
 | 
|---|
| [02f346] | 83 | 
 | 
|---|
| [12d15a] | 84 |   CPPUNIT_ASSERT_EQUAL(false, queue->isJobPresent() );
 | 
|---|
 | 85 | 
 | 
|---|
| [02f346] | 86 | #ifndef NDEBUG
 | 
|---|
 | 87 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) );
 | 
|---|
 | 88 | #else
 | 
|---|
 | 89 |   queue->pushJob(testJob);
 | 
|---|
 | 90 | #endif
 | 
|---|
| [d6b12c] | 91 |   CPPUNIT_ASSERT( addobserver->wasNotified );
 | 
|---|
 | 92 |   CPPUNIT_ASSERT( !removeobserver->wasNotified );
 | 
|---|
 | 93 |   addobserver->wasNotified = false;
 | 
|---|
| [02f346] | 94 | 
 | 
|---|
 | 95 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size());
 | 
|---|
| [12d15a] | 96 |   CPPUNIT_ASSERT_EQUAL(true, queue->isJobPresent() );
 | 
|---|
 | 97 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
| [9875cc] | 98 |   {
 | 
|---|
 | 99 |     FragmentQueue::ResultMap::const_iterator iter = queue->results.find((JobId_t)1);
 | 
|---|
 | 100 |     CPPUNIT_ASSERT( iter != queue->results.end() );
 | 
|---|
 | 101 |     CPPUNIT_ASSERT( FragmentQueue::NoResult == iter->second );
 | 
|---|
 | 102 |   }
 | 
|---|
| [02f346] | 103 | 
 | 
|---|
 | 104 |   // push same id again
 | 
|---|
 | 105 | #ifndef NDEBUG
 | 
|---|
 | 106 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 107 |   CPPUNIT_ASSERT_THROW( queue->pushJob(testJob), Assert::AssertionFailure );
 | 
|---|
 | 108 | #endif
 | 
|---|
 | 109 | 
 | 
|---|
 | 110 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size());
 | 
|---|
| [12d15a] | 111 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
 | 112 | 
 | 
|---|
| [78ad7d] | 113 |   FragmentJob::ptr poppedJob;
 | 
|---|
| [12d15a] | 114 | #ifndef NDEBUG
 | 
|---|
 | 115 |   CPPUNIT_ASSERT_NO_THROW( poppedJob = queue->popJob() );
 | 
|---|
 | 116 | #else
 | 
|---|
 | 117 |   poppedJob = queue->popJob();
 | 
|---|
 | 118 | #endif
 | 
|---|
| [d6b12c] | 119 |   CPPUNIT_ASSERT( !addobserver->wasNotified );
 | 
|---|
 | 120 |   CPPUNIT_ASSERT( removeobserver->wasNotified );
 | 
|---|
| [12d15a] | 121 |   CPPUNIT_ASSERT( poppedJob == testJob );
 | 
|---|
 | 122 | 
 | 
|---|
 | 123 |   CPPUNIT_ASSERT_EQUAL((size_t)0, queue->jobs.size());
 | 
|---|
 | 124 |   CPPUNIT_ASSERT_EQUAL(false, queue->isJobPresent() );
 | 
|---|
 | 125 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
| [9875cc] | 126 |   {
 | 
|---|
 | 127 |     FragmentQueue::ResultMap::const_iterator iter = queue->results.find((JobId_t)1);
 | 
|---|
 | 128 |     CPPUNIT_ASSERT( iter != queue->results.end() );
 | 
|---|
 | 129 |     CPPUNIT_ASSERT( FragmentQueue::NoResultQueued == iter->second );
 | 
|---|
 | 130 |   }
 | 
|---|
| [12d15a] | 131 | 
 | 
|---|
 | 132 | #ifndef NDEBUG
 | 
|---|
 | 133 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 134 |   CPPUNIT_ASSERT_THROW( queue->popJob(), Assert::AssertionFailure );
 | 
|---|
 | 135 | #endif
 | 
|---|
| [b5ebb5] | 136 | }
 | 
|---|
 | 137 | 
 | 
|---|
| [9875cc] | 138 | /** UnitTest for adding multiple jobs at a time.
 | 
|---|
 | 139 |  */
 | 
|---|
 | 140 | void FragmentQueueTest::JobsTest()
 | 
|---|
 | 141 | {
 | 
|---|
 | 142 |   // prepare some jobs
 | 
|---|
| [d920b9] | 143 |   FragmentJob::ptr testJob(new FragmentJobStub(JobId::IllegalJob));
 | 
|---|
| [78ad7d] | 144 |   testJob->setId((JobId_t)1);
 | 
|---|
| [d920b9] | 145 |   FragmentJob::ptr anothertestJob(new FragmentJobStub(JobId::IllegalJob));
 | 
|---|
| [78ad7d] | 146 |   anothertestJob->setId((JobId_t)2);
 | 
|---|
| [9875cc] | 147 | 
 | 
|---|
 | 148 |   // prepare a vector of them
 | 
|---|
| [78ad7d] | 149 |   std::vector<FragmentJob::ptr> testjobs;
 | 
|---|
| [9875cc] | 150 |   testjobs.push_back(testJob);
 | 
|---|
 | 151 |   testjobs.push_back(anothertestJob);
 | 
|---|
 | 152 | 
 | 
|---|
 | 153 |   // prepare another vector of them
 | 
|---|
| [78ad7d] | 154 |   std::vector<FragmentJob::ptr> sametestjobs;
 | 
|---|
| [9875cc] | 155 |   sametestjobs.push_back(testJob);
 | 
|---|
 | 156 |   sametestjobs.push_back(anothertestJob);
 | 
|---|
 | 157 | 
 | 
|---|
 | 158 |   // push the vector
 | 
|---|
 | 159 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->jobs.size() );
 | 
|---|
 | 160 | #ifndef NDEBUG
 | 
|---|
 | 161 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJobs(testjobs) );
 | 
|---|
 | 162 | #else
 | 
|---|
 | 163 |   queue->pushJobs(testjobs);
 | 
|---|
 | 164 | #endif
 | 
|---|
 | 165 |   CPPUNIT_ASSERT_EQUAL( (size_t)2, queue->jobs.size() );
 | 
|---|
 | 166 |   CPPUNIT_ASSERT_EQUAL((size_t)2, queue->results.size());
 | 
|---|
 | 167 |   {
 | 
|---|
 | 168 |     FragmentQueue::ResultMap::const_iterator iter = queue->results.find((JobId_t)1);
 | 
|---|
 | 169 |     CPPUNIT_ASSERT( iter != queue->results.end() );
 | 
|---|
 | 170 |     CPPUNIT_ASSERT( FragmentQueue::NoResult == iter->second );
 | 
|---|
 | 171 |   }
 | 
|---|
 | 172 |   {
 | 
|---|
 | 173 |     FragmentQueue::ResultMap::const_iterator iter = queue->results.find((JobId_t)2);
 | 
|---|
 | 174 |     CPPUNIT_ASSERT( iter != queue->results.end() );
 | 
|---|
 | 175 |     CPPUNIT_ASSERT( FragmentQueue::NoResult == iter->second );
 | 
|---|
 | 176 |   }
 | 
|---|
 | 177 |   // push again
 | 
|---|
 | 178 | #ifndef NDEBUG
 | 
|---|
 | 179 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 180 |   CPPUNIT_ASSERT_THROW( queue->pushJobs(testjobs), Assert::AssertionFailure );
 | 
|---|
 | 181 | #endif
 | 
|---|
 | 182 | 
 | 
|---|
 | 183 |   CPPUNIT_ASSERT_EQUAL( (size_t)2, queue->jobs.size() );
 | 
|---|
 | 184 |   CPPUNIT_ASSERT_EQUAL((size_t)2, queue->results.size());
 | 
|---|
 | 185 | }
 | 
|---|
 | 186 | 
 | 
|---|
| [b5ebb5] | 187 | /** UnitTest for working ResultMap
 | 
|---|
 | 188 |  */
 | 
|---|
 | 189 | void FragmentQueueTest::ResultsTest()
 | 
|---|
 | 190 | {
 | 
|---|
| [02f346] | 191 |   // prepare a job
 | 
|---|
| [d920b9] | 192 |   FragmentJob::ptr testJob(new FragmentJobStub(JobId::IllegalJob));
 | 
|---|
| [78ad7d] | 193 |   testJob->setId(1);
 | 
|---|
| [12d15a] | 194 | #ifndef NDEBUG
 | 
|---|
 | 195 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) );
 | 
|---|
 | 196 | #else
 | 
|---|
| [02f346] | 197 |   queue->pushJob(testJob);
 | 
|---|
| [12d15a] | 198 | #endif
 | 
|---|
| [bf56f6] | 199 | 
 | 
|---|
 | 200 |   // check for present job to do
 | 
|---|
 | 201 |   CPPUNIT_ASSERT_EQUAL( (size_t)1, queue->getPresentJobs() );
 | 
|---|
 | 202 | 
 | 
|---|
| [12d15a] | 203 | #ifndef NDEBUG
 | 
|---|
 | 204 |   CPPUNIT_ASSERT_NO_THROW( queue->popJob() );
 | 
|---|
 | 205 | #else
 | 
|---|
 | 206 |   queue->popJob();
 | 
|---|
 | 207 | #endif
 | 
|---|
 | 208 | 
 | 
|---|
| [bf56f6] | 209 |   // check for present job to do
 | 
|---|
 | 210 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->getPresentJobs() );
 | 
|---|
| [02f346] | 211 | 
 | 
|---|
 | 212 |   // prepare a result
 | 
|---|
| [35f587] | 213 |   FragmentResult::ptr testResult( new FragmentResult(1) );
 | 
|---|
 | 214 |   FragmentResult::ptr wrongIdResult( new FragmentResult(2) );
 | 
|---|
| [02f346] | 215 | 
 | 
|---|
| [b0b64c] | 216 |   // check that none are present and we can't get result yet
 | 
|---|
| [8ee5ac] | 217 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->getDoneJobs() );
 | 
|---|
| [02f346] | 218 |   CPPUNIT_ASSERT( !queue->isResultPresent(1) );
 | 
|---|
 | 219 |   CPPUNIT_ASSERT( !queue->isResultPresent(2) );
 | 
|---|
 | 220 | #ifndef NDEBUG
 | 
|---|
 | 221 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 222 |   CPPUNIT_ASSERT_THROW( queue->getResult(1), Assert::AssertionFailure );
 | 
|---|
 | 223 | #endif
 | 
|---|
 | 224 | 
 | 
|---|
| [b0b64c] | 225 |   /// check for admonishing wrong id
 | 
|---|
| [02f346] | 226 | #ifndef NDEBUG
 | 
|---|
 | 227 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 228 |   CPPUNIT_ASSERT_THROW( queue->pushResult(wrongIdResult), Assert::AssertionFailure );
 | 
|---|
 | 229 | #endif
 | 
|---|
| [b0b64c] | 230 | 
 | 
|---|
 | 231 |   // push correct result
 | 
|---|
| [02f346] | 232 | #ifndef NDEBUG
 | 
|---|
 | 233 |   CPPUNIT_ASSERT_NO_THROW( queue->pushResult(testResult) );
 | 
|---|
 | 234 | #else
 | 
|---|
 | 235 |   queue->pushResult(testResult);
 | 
|---|
 | 236 | #endif
 | 
|---|
 | 237 | 
 | 
|---|
 | 238 |   // check presence again
 | 
|---|
 | 239 |   CPPUNIT_ASSERT( queue->isResultPresent(1) );
 | 
|---|
| [8ee5ac] | 240 |   CPPUNIT_ASSERT_EQUAL( (size_t)1, queue->getDoneJobs() );
 | 
|---|
| [bf56f6] | 241 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->getPresentJobs() );
 | 
|---|
| [02f346] | 242 | 
 | 
|---|
| [b0b64c] | 243 |   // obtain result again
 | 
|---|
| [02f346] | 244 | #ifndef NDEBUG
 | 
|---|
 | 245 |   CPPUNIT_ASSERT_NO_THROW( queue->getResult(1) );
 | 
|---|
 | 246 | #else
 | 
|---|
 | 247 |   queue->getResult(1);
 | 
|---|
 | 248 | #endif
 | 
|---|
 | 249 | 
 | 
|---|
 | 250 |   // check presence one more time
 | 
|---|
| [8ee5ac] | 251 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->getDoneJobs() );
 | 
|---|
| [bf56f6] | 252 |   CPPUNIT_ASSERT_EQUAL( (size_t)0, queue->getPresentJobs() );
 | 
|---|
| [02f346] | 253 |   CPPUNIT_ASSERT( !queue->isResultPresent(1) );
 | 
|---|
 | 254 |   CPPUNIT_ASSERT( !queue->isResultPresent(2) );
 | 
|---|
 | 255 | #ifndef NDEBUG
 | 
|---|
 | 256 |   std::cout << "The following assertion is intended and does not indicate a failure." << std::endl;
 | 
|---|
 | 257 |   CPPUNIT_ASSERT_THROW( queue->getResult(1), Assert::AssertionFailure );
 | 
|---|
 | 258 | #endif
 | 
|---|
| [b5ebb5] | 259 | }
 | 
|---|
| [b9c486] | 260 | 
 | 
|---|
 | 261 | /** UnitTest for working ResultMap
 | 
|---|
 | 262 |  */
 | 
|---|
 | 263 | void FragmentQueueTest::AllResultsTest()
 | 
|---|
 | 264 | {
 | 
|---|
 | 265 |   // prepare a job
 | 
|---|
| [d920b9] | 266 |   FragmentJob::ptr testJob( new FragmentJobStub(JobId::IllegalJob) );
 | 
|---|
 | 267 |   testJob->setId((JobId_t)1);
 | 
|---|
 | 268 |   FragmentJob::ptr anothertestJob( new FragmentJobStub(JobId::IllegalJob) );
 | 
|---|
 | 269 |   anothertestJob->setId((JobId_t)2);
 | 
|---|
| [b9c486] | 270 | 
 | 
|---|
 | 271 | #ifndef NDEBUG
 | 
|---|
 | 272 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) );
 | 
|---|
 | 273 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJob(anothertestJob) );
 | 
|---|
 | 274 | #else
 | 
|---|
 | 275 |   queue->pushJob(testJob);
 | 
|---|
 | 276 |   queue->pushJob(anothertestJob);
 | 
|---|
 | 277 | #endif
 | 
|---|
 | 278 | 
 | 
|---|
 | 279 |   // check that no results are returned.
 | 
|---|
 | 280 |   {
 | 
|---|
| [35f587] | 281 |     const std::vector<FragmentResult::ptr> results = queue->getAllResults();
 | 
|---|
| [b9c486] | 282 |     CPPUNIT_ASSERT_EQUAL( (size_t)0, results.size() );
 | 
|---|
 | 283 |   }
 | 
|---|
 | 284 | 
 | 
|---|
 | 285 |   // pop both as if some work was being done
 | 
|---|
 | 286 | #ifndef NDEBUG
 | 
|---|
 | 287 |   CPPUNIT_ASSERT_NO_THROW( queue->popJob() );
 | 
|---|
 | 288 |   CPPUNIT_ASSERT_NO_THROW( queue->popJob() );
 | 
|---|
 | 289 | #else
 | 
|---|
 | 290 |   queue->popJob();
 | 
|---|
 | 291 |   queue->popJob();
 | 
|---|
 | 292 | #endif
 | 
|---|
 | 293 | 
 | 
|---|
 | 294 |   // prepare a result
 | 
|---|
| [35f587] | 295 |   FragmentResult::ptr testResult( new FragmentResult(1) );
 | 
|---|
 | 296 |   FragmentResult::ptr anothertestResult( new FragmentResult(2) );
 | 
|---|
| [b9c486] | 297 | 
 | 
|---|
 | 298 |   // push correct result
 | 
|---|
 | 299 | #ifndef NDEBUG
 | 
|---|
 | 300 |   CPPUNIT_ASSERT_NO_THROW( queue->pushResult(testResult) );
 | 
|---|
 | 301 |   CPPUNIT_ASSERT_NO_THROW( queue->pushResult(anothertestResult) );
 | 
|---|
 | 302 | #else
 | 
|---|
 | 303 |   queue->pushResult(testResult);
 | 
|---|
 | 304 |   queue->pushResult(anothertestResult);
 | 
|---|
 | 305 | #endif
 | 
|---|
 | 306 | 
 | 
|---|
 | 307 |   // check that two results are returned.
 | 
|---|
 | 308 |   {
 | 
|---|
| [35f587] | 309 |     const std::vector<FragmentResult::ptr> results = queue->getAllResults();
 | 
|---|
| [b9c486] | 310 |     CPPUNIT_ASSERT_EQUAL( (size_t)2, results.size() );
 | 
|---|
 | 311 |   }
 | 
|---|
 | 312 | }
 | 
|---|
 | 313 | 
 | 
|---|
| [fe95b7] | 314 | /** Unit test for resubmitJob().
 | 
|---|
 | 315 |  *
 | 
|---|
 | 316 |  */
 | 
|---|
 | 317 | void FragmentQueueTest::resubmitTest()
 | 
|---|
 | 318 | {
 | 
|---|
 | 319 |   FragmentJob::ptr testJob(new FragmentJobStub(1));
 | 
|---|
 | 320 | 
 | 
|---|
 | 321 |   // push a Job into queue
 | 
|---|
 | 322 | #ifndef NDEBUG
 | 
|---|
 | 323 |   CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) );
 | 
|---|
 | 324 | #else
 | 
|---|
 | 325 |   queue->pushJob(testJob);
 | 
|---|
 | 326 | #endif
 | 
|---|
 | 327 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size());
 | 
|---|
 | 328 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
 | 329 | 
 | 
|---|
 | 330 |   // pop the job
 | 
|---|
 | 331 |   // pop both as if some work was being done
 | 
|---|
 | 332 | #ifndef NDEBUG
 | 
|---|
 | 333 |   CPPUNIT_ASSERT_NO_THROW( queue->popJob() );
 | 
|---|
 | 334 | #else
 | 
|---|
 | 335 |   queue->popJob();
 | 
|---|
 | 336 | #endif
 | 
|---|
 | 337 |   CPPUNIT_ASSERT_EQUAL((size_t)0, queue->jobs.size());
 | 
|---|
 | 338 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
 | 339 | 
 | 
|---|
 | 340 |   // resubmit
 | 
|---|
 | 341 | #ifndef NDEBUG
 | 
|---|
 | 342 |   CPPUNIT_ASSERT_NO_THROW( queue->resubmitJob((JobId_t)1) );
 | 
|---|
 | 343 | #else
 | 
|---|
 | 344 |   queue->resubmitJob((JobId_t)1);
 | 
|---|
 | 345 | #endif
 | 
|---|
 | 346 | 
 | 
|---|
 | 347 |   // check whethers it's present again
 | 
|---|
 | 348 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->jobs.size());
 | 
|---|
 | 349 |   CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size());
 | 
|---|
 | 350 | }
 | 
|---|
 | 351 | 
 | 
|---|