| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * IteratorAdaptorsUnitTest.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: Nov 25, 2009
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | using namespace std;
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
| 23 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
| 24 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include <iostream>
 | 
|---|
| 27 | #include <stdio.h>
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #include "IteratorAdaptors.hpp"
 | 
|---|
| 30 | #include "Log.hpp"
 | 
|---|
| 31 | 
 | 
|---|
| 32 | #include "IteratorAdaptorsUnitTest.hpp"
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #ifdef HAVE_TESTRUNNER
 | 
|---|
| 35 | #include "UnitTestMain.hpp"
 | 
|---|
| 36 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| 37 | 
 | 
|---|
| 38 | /********************************************** Test classes **************************************/
 | 
|---|
| 39 | 
 | 
|---|
| 40 | // Registers the fixture into the 'registry'
 | 
|---|
| 41 | CPPUNIT_TEST_SUITE_REGISTRATION( IteratorAdaptorsTest );
 | 
|---|
| 42 | 
 | 
|---|
| 43 | 
 | 
|---|
| 44 | void IteratorAdaptorsTest::setUp()
 | 
|---|
| 45 | {
 | 
|---|
| 46 |   vecKeys.push_back(31);
 | 
|---|
| 47 |   vecKeys.push_back(59);
 | 
|---|
| 48 |   vecValues.push_back(41);
 | 
|---|
| 49 |   vecValues.push_back(26);
 | 
|---|
| 50 |   map[31] = 41;
 | 
|---|
| 51 |   map[59] = 26;
 | 
|---|
| 52 | }
 | 
|---|
| 53 | 
 | 
|---|
| 54 | 
 | 
|---|
| 55 | void IteratorAdaptorsTest::tearDown()
 | 
|---|
| 56 | {
 | 
|---|
| 57 |   vecKeys.clear();
 | 
|---|
| 58 |   vecValues.clear();
 | 
|---|
| 59 |   map.clear();
 | 
|---|
| 60 | }
 | 
|---|
| 61 | 
 | 
|---|
| 62 | /** UnitTest for FunctionTest().
 | 
|---|
| 63 |  */
 | 
|---|
| 64 | void IteratorAdaptorsTest::FunctionTest()
 | 
|---|
| 65 | {
 | 
|---|
| 66 | 
 | 
|---|
| 67 |   typedef MapValueIterator< std::map<int,int>::iterator > ValueIter;
 | 
|---|
| 68 |   typedef MapKeyIterator< std::map<int,int>::iterator > KeyIter;
 | 
|---|
| 69 |   typedef std::vector<int>::iterator vecIter;
 | 
|---|
| 70 |   ValueIter value_iter = ValueIter(map.begin());
 | 
|---|
| 71 |   KeyIter key_iter = KeyIter(map.begin());
 | 
|---|
| 72 |   vecIter value_iter2 = vecValues.begin();
 | 
|---|
| 73 |   vecIter key_iter2 = vecKeys.begin();
 | 
|---|
| 74 |   while ( (value_iter != ValueIter(map.end())) && (value_iter2 != vecValues.end())
 | 
|---|
| 75 |       && (key_iter != KeyIter(map.end())) && (key_iter2 != vecKeys.end()) ) {
 | 
|---|
| 76 |     CPPUNIT_ASSERT( *key_iter == *key_iter2 );
 | 
|---|
| 77 |     CPPUNIT_ASSERT( *value_iter == *value_iter2 );
 | 
|---|
| 78 |     ++key_iter;
 | 
|---|
| 79 |     ++key_iter2;
 | 
|---|
| 80 |     ++value_iter;
 | 
|---|
| 81 |     ++value_iter2;
 | 
|---|
| 82 |   }
 | 
|---|
| 83 | }
 | 
|---|