Changeset db6b872 for molecuilder/src/unittests/AtomDescriptorTest.cpp
- Timestamp:
- Mar 4, 2010, 10:34:52 AM (16 years ago)
- Children:
- fe3540
- Parents:
- d50264 (diff), f058ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
molecuilder/src/unittests/AtomDescriptorTest.cpp (moved) (moved from molecuilder/src/unittests/DescriptorUnittest.cpp ) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/unittests/AtomDescriptorTest.cpp
rd50264 rdb6b872 6 6 */ 7 7 8 #include " DescriptorUnittest.hpp"8 #include "AtomDescriptorTest.hpp" 9 9 10 10 #include <cppunit/CompilerOutputter.h> … … 25 25 /********************************************** Test classes **************************************/ 26 26 // Registers the fixture into the 'registry' 27 CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest );27 CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest ); 28 28 29 29 // set up and tear down 30 void DescriptorUnittest::setUp(){30 void AtomDescriptorTest::setUp(){ 31 31 World::get(); 32 32 for(int i=0;i<ATOM_COUNT;++i){ 33 33 atoms[i]= World::get()->createAtom(); 34 atomIds[i] = atoms[i]->getId();34 atomIds[i]= atoms[i]->getId(); 35 35 } 36 36 } 37 void DescriptorUnittest::tearDown(){ 37 38 void AtomDescriptorTest::tearDown(){ 38 39 World::destroy(); 39 40 } 40 41 41 42 // some helper functions 42 bool hasAll(std::vector<atom*> atoms,int ids[ATOM_COUNT], std::set<int> excluded = std::set<int>()){43 static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){ 43 44 for(int i=0;i<ATOM_COUNT;++i){ 44 int id = ids[i];45 atomId_t id = ids[i]; 45 46 if(!excluded.count(id)){ 46 47 std::vector<atom*>::iterator iter; … … 58 59 } 59 60 60 bool hasNoDuplicates(std::vector<atom*> atoms){61 std::set< int> found;61 static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){ 62 std::set<atomId_t> found; 62 63 std::vector<atom*>::iterator iter; 63 64 for(iter=atoms.begin();iter!=atoms.end();++iter){ … … 71 72 72 73 73 void DescriptorUnittest::AtomBaseSetsTest(){74 void AtomDescriptorTest::AtomBaseSetsTest(){ 74 75 std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms()); 75 CPPUNIT_ASSERT_EQUAL( true , hasAll (allAtoms,atomIds));76 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicate s(allAtoms));76 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds)); 77 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms)); 77 78 78 79 std::vector<atom*> noAtoms = World::get()->getAllAtoms(NoAtoms()); 79 80 CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty()); 80 81 } 81 void DescriptorUnittest::AtomIdTest(){82 void AtomDescriptorTest::AtomIdTest(){ 82 83 // test Atoms from boundaries and middle of the set 83 84 atom* testAtom; … … 93 94 94 95 // find some ID that has not been created 95 int outsideId =-1;96 atomId_t outsideId=0; 96 97 bool res = false; 97 while(!res) { 98 ++outsideId; 98 for(outsideId=0;!res;++outsideId) { 99 99 res = true; 100 100 for(int i = 0; i < ATOM_COUNT; ++i){ … … 106 106 CPPUNIT_ASSERT(!testAtom); 107 107 } 108 void DescriptorUnittest::AtomCalcTest(){108 void AtomDescriptorTest::AtomCalcTest(){ 109 109 // test some elementary set operations 110 110 { 111 111 std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()||NoAtoms()); 112 CPPUNIT_ASSERT_EQUAL( true , hasAll (testAtoms,atomIds));113 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicate s(testAtoms));112 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 113 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); 114 114 } 115 115 116 116 { 117 117 std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||AllAtoms()); 118 CPPUNIT_ASSERT_EQUAL( true , hasAll (testAtoms,atomIds));119 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicate s(testAtoms));118 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 119 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); 120 120 } 121 121 … … 137 137 { 138 138 std::vector<atom*> testAtoms = World::get()->getAllAtoms(!NoAtoms()); 139 CPPUNIT_ASSERT_EQUAL( true , hasAll (testAtoms,atomIds));140 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicate s(testAtoms));139 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds)); 140 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); 141 141 } 142 142 … … 144 144 { 145 145 std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2]))); 146 std::set< int> excluded;146 std::set<atomId_t> excluded; 147 147 excluded.insert(atomIds[ATOM_COUNT/2]); 148 CPPUNIT_ASSERT_EQUAL( true , hasAll (testAtoms,atomIds,excluded));149 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicate s(testAtoms));148 CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded)); 149 CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms)); 150 150 CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size()); 151 151 }
Note:
See TracChangeset
for help on using the changeset viewer.
