Changeset d3513b for molecuilder/src/unittests
- Timestamp:
- May 2, 2010, 4:47:18 PM (15 years ago)
- Children:
- 0647f4
- Parents:
- 0f7883
- Location:
- molecuilder/src/unittests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/unittests/ParserUnitTest.cpp
r0f7883 rd3513b 15 15 #include "Parser/TremoloParser.hpp" 16 16 #include "World.hpp" 17 #include "atom.hpp" 17 18 #include "element.hpp" 18 19 #include "periodentafel.hpp" 20 #include "Descriptors/AtomTypeDescriptor.hpp" 19 21 20 22 #ifdef HAVE_TESTRUNNER … … 41 43 42 44 void ParserUnitTest::tearDown() { 45 World::purgeInstance(); 43 46 } 44 47 … … 63 66 } 64 67 65 void ParserUnitTest::re writeTremoloTest() {68 void ParserUnitTest::readTremoloPreliminaryCommentsTest() { 66 69 cout << "Testing the tremolo parser." << endl; 67 70 TremoloParser* testParser = new TremoloParser(); 68 stringstream input; 71 stringstream input, output; 72 string waterTremolo; 69 73 70 74 // Atomdata beginning with "# ATOMDATA" 71 string waterTremolo = "#\n# ATOMDATA Id name Type x=3\n\n\n";75 waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n"; 72 76 input << waterTremolo; 73 77 testParser->load(&input); 78 testParser->save(&output); 79 CPPUNIT_ASSERT(waterTremolo == output.str()); 74 80 input.clear(); 81 output.clear(); 75 82 76 83 // Atomdata beginning with "#ATOMDATA" 77 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 H hydrogen3.0 4.5 0.1\n\n";84 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 78 85 input << waterTremolo; 79 86 testParser->load(&input); 87 testParser->save(&output); 88 CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos); 80 89 input.clear(); 81 82 // One simple data line 83 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 H hydrogen 3.0 4.5 0.1\n\n"; 84 input << waterTremolo; 85 testParser->load(&input); 86 input.clear(); 90 output.clear(); 87 91 88 92 // Invalid key in Atomdata line … … 90 94 input << waterTremolo; 91 95 testParser->load(&input); 96 //TODO: proove invalidity 92 97 input.clear(); 98 } 99 100 void ParserUnitTest::readTremoloCoordinatesTest() { 101 TremoloParser* testParser = new TremoloParser(); 102 stringstream input; 103 string waterTremolo; 104 105 // One simple data line 106 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 107 input << waterTremolo; 108 testParser->load(&input); 109 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x.x[0] == 3.0); 110 input.clear(); 111 } 112 113 void ParserUnitTest::readTremoloVelocityTest() { 114 TremoloParser* testParser = new TremoloParser(); 115 stringstream input; 116 string waterTremolo; 117 118 // One simple data line 119 waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 120 input << waterTremolo; 121 testParser->load(&input); 122 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v.x[0] == 3.0); 123 input.clear(); 124 } 125 126 void ParserUnitTest::readTremoloNeighborInformationTest() { 127 TremoloParser* testParser = new TremoloParser(); 128 stringstream input; 129 string waterTremolo; 130 131 // Neighbor data 132 waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 133 input << waterTremolo; 134 testParser->load(&input); 135 136 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 137 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(8))-> 138 IsBondedTo(World::getInstance().getAtom(AtomByType(1)))); 139 input.clear(); 140 } 141 142 void ParserUnitTest::readAndWriteTremoloImprDataInformationTest() { 143 TremoloParser* testParser = new TremoloParser(); 144 stringstream input, output; 145 string waterTremolo; 146 147 // Neighbor data 148 waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 149 input << waterTremolo; 150 testParser->load(&input); 151 testParser->save(&output); 152 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 153 CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); 154 input.clear(); 155 output.clear(); 156 } 157 158 void ParserUnitTest::readAndWriteTremoloTorsionInformationTest() { 159 TremoloParser* testParser = new TremoloParser(); 160 stringstream input, output; 161 string waterTremolo; 162 163 // Neighbor data 164 waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 165 input << waterTremolo; 166 testParser->load(&input); 167 testParser->save(&output); 168 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 169 CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos); 170 input.clear(); 171 output.clear(); 172 } 173 174 void ParserUnitTest::writeTremoloTest() { 175 TremoloParser* testParser = new TremoloParser(); 176 stringstream output; 177 178 // with the maximum number of fields and minimal information, default values are printed 179 atom* newAtom = World::getInstance().createAtom(); 180 newAtom->type = World::getInstance().getPeriode()->FindElement(1); 181 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 182 testParser->save(&output); 183 CPPUNIT_ASSERT(output.str() == "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"); 93 184 94 185 cout << "testing the tremolo parser is done" << endl; -
molecuilder/src/unittests/ParserUnitTest.hpp
r0f7883 rd3513b 15 15 CPPUNIT_TEST_SUITE( ParserUnitTest ) ; 16 16 CPPUNIT_TEST ( rewriteAnXyzTest ); 17 CPPUNIT_TEST ( rewriteTremoloTest ); 17 CPPUNIT_TEST ( readTremoloPreliminaryCommentsTest ); 18 CPPUNIT_TEST ( readTremoloCoordinatesTest ); 19 CPPUNIT_TEST ( readTremoloVelocityTest ); 20 CPPUNIT_TEST ( readTremoloNeighborInformationTest ); 21 CPPUNIT_TEST ( readAndWriteTremoloImprDataInformationTest ); 22 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 CPPUNIT_TEST ( writeTremoloTest ); 18 24 CPPUNIT_TEST_SUITE_END(); 19 25 … … 23 29 24 30 void rewriteAnXyzTest(); 25 void rewriteTremoloTest(); 31 void readTremoloPreliminaryCommentsTest(); 32 void readTremoloCoordinatesTest(); 33 void readTremoloVelocityTest(); 34 void readTremoloNeighborInformationTest(); 35 void readAndWriteTremoloImprDataInformationTest(); 36 void readAndWriteTremoloTorsionInformationTest(); 37 void writeTremoloTest(); 26 38 }; 27 39 -
molecuilder/src/unittests/SingletonTest.cpp
r0f7883 rd3513b 52 52 count1++; 53 53 } 54 // explicit copy constructor to catch if th siis ever called54 // explicit copy constructor to catch if this is ever called 55 55 SingletonStub2(const SingletonStub2&){ 56 56 CPPUNIT_FAIL ( "Copy constructor of Singleton called" );
Note:
See TracChangeset
for help on using the changeset viewer.