Index: src/unittests/ParserTremoloUnitTest.cpp
===================================================================
--- src/unittests/ParserTremoloUnitTest.cpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
+++ src/unittests/ParserTremoloUnitTest.cpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -0,0 +1,174 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ParserTremoloUnitTest.cpp
+ *
+ *  Created on: Mar 3, 2010
+ *      Author: metzler
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ParserTremoloUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Parser/MpqcParser.hpp"
+#include "Parser/PdbParser.hpp"
+#include "Parser/PcpParser.hpp"
+#include "Parser/TremoloParser.hpp"
+#include "Parser/XyzParser.hpp"
+#include "World.hpp"
+#include "atom.hpp"
+#include "element.hpp"
+#include "periodentafel.hpp"
+#include "Descriptors/AtomTypeDescriptor.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace std;
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ParserTremoloUnitTest );
+
+static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
+static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
+static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
+static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
+static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
+static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
+static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
+static string Tremolo_full = "# 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\t1\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";
+
+void ParserTremoloUnitTest::setUp() {
+  World::getInstance();
+
+  // we need hydrogens and oxygens in the following tests
+  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
+  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
+}
+
+void ParserTremoloUnitTest::tearDown() {
+  ChangeTracker::purgeInstance();
+  World::purgeInstance();
+}
+
+/************************************ tests ***********************************/
+
+void ParserTremoloUnitTest::readTremoloPreliminaryCommentsTest() {
+  cout << "Testing the tremolo parser." << endl;
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Atomdata beginning with "# ATOMDATA"
+  input << Tremolo_Atomdata1;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str());
+  input.clear();
+  output.clear();
+
+  // Atomdata beginning with "#ATOMDATA"
+  input << Tremolo_Atomdata2;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos);
+  input.clear();
+  output.clear();
+
+  // Invalid key in Atomdata line
+  input << Tremolo_invalidkey;
+  testParser->load(&input);
+  //TODO: proove invalidity
+  input.clear();
+}
+
+void ParserTremoloUnitTest::readTremoloCoordinatesTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // One simple data line
+  input << Tremolo_Atomdata2;
+  testParser->load(&input);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0);
+  input.clear();
+}
+
+void ParserTremoloUnitTest::readTremoloVelocityTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // One simple data line
+  input << Tremolo_velocity;
+  testParser->load(&input);
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0);
+  input.clear();
+}
+
+void ParserTremoloUnitTest::readTremoloNeighborInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input;
+
+  // Neighbor data
+  input << Tremolo_neighbours;
+  testParser->load(&input);
+
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(8))->
+      IsBondedTo(World::getInstance().getAtom(AtomByType(1))));
+  input.clear();
+}
+
+void ParserTremoloUnitTest::readAndWriteTremoloImprDataInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Neighbor data
+  input << Tremolo_improper;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
+  input.clear();
+  output.clear();
+}
+
+void ParserTremoloUnitTest::readAndWriteTremoloTorsionInformationTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream input, output;
+
+  // Neighbor data
+  input << Tremolo_torsion;
+  testParser->load(&input);
+  testParser->save(&output);
+  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+  CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
+  input.clear();
+  output.clear();
+}
+
+void ParserTremoloUnitTest::writeTremoloTest() {
+  TremoloParser* testParser = new TremoloParser();
+  stringstream output;
+
+  // with the maximum number of fields and minimal information, default values are printed
+  atom* newAtom = World::getInstance().createAtom();
+  newAtom->setType(1);
+  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");
+  testParser->save(&output);
+  CPPUNIT_ASSERT(output.str() == Tremolo_full);
+
+  cout << "testing the tremolo parser is done" << endl;
+}
