Index: src/Descriptors/unittests/AtomDescriptorUnitTest.cpp
===================================================================
--- src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision e7da1f59b247209d90468802fd9412179ff04717)
+++ src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision e7da1f59b247209d90468802fd9412179ff04717)
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+/*
+ * AtomDescriptorUnitTest.cpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "AtomDescriptorUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest );
+
+// set up and tear down
+void AtomDescriptorTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= World::getInstance().createAtom();
+    atomIds[i]= atoms[i]->getId();
+  }
+}
+
+void AtomDescriptorTest::tearDown(){
+  World::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
+  for(int i=0;i<ATOM_COUNT;++i){
+    atomId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<atom*>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter)->getId() == id;
+      }
+      if(!res) {
+        cout << "Atom " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){
+  std::set<atomId_t> found;
+  std::vector<atom*>::iterator iter;
+  for(iter=atoms.begin();iter!=atoms.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void AtomDescriptorTest::AtomBaseSetsTest(){
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
+
+  std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
+}
+void AtomDescriptorTest::AtomIdTest(){
+  // test Atoms from boundaries and middle of the set
+  atom* testAtom;
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT/2]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT-1]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
+
+  // find some ID that has not been created
+  atomId_t outsideId=0;
+  bool res = false;
+  for(outsideId=0;!res;++outsideId) {
+    res = true;
+    for(int i = 0; i < ATOM_COUNT; ++i){
+      res &= atomIds[i]!=outsideId;
+    }
+  }
+  // test from outside of set
+  testAtom = World::getInstance().getAtom(AtomById(outsideId));
+  CPPUNIT_ASSERT(!testAtom);
+}
+void AtomDescriptorTest::AtomCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+  // exclude and include some atoms
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
+    std::set<atomId_t> excluded;
+    excluded.insert(atomIds[ATOM_COUNT/2]);
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
+    CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
+  }
+}
Index: src/Descriptors/unittests/AtomDescriptorUnitTest.hpp
===================================================================
--- src/Descriptors/unittests/AtomDescriptorUnitTest.hpp	(revision e7da1f59b247209d90468802fd9412179ff04717)
+++ src/Descriptors/unittests/AtomDescriptorUnitTest.hpp	(revision e7da1f59b247209d90468802fd9412179ff04717)
@@ -0,0 +1,41 @@
+/*
+ * AtomDescriptorUnitTest.hpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMDESCRIPTORUNITTEST_HPP_
+#define ATOMDESCRIPTORUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "types.hpp"
+
+// we prefer enum over define
+enum { ATOM_COUNT = 10 };
+
+class atom;
+
+class AtomDescriptorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( AtomDescriptorTest );
+  CPPUNIT_TEST ( AtomBaseSetsTest );
+  CPPUNIT_TEST ( AtomIdTest );
+  CPPUNIT_TEST ( AtomCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void AtomBaseSetsTest();
+  void AtomIdTest();
+  void AtomCalcTest();
+
+private:
+  atom *atoms [ATOM_COUNT];
+  atomId_t atomIds [ATOM_COUNT];
+};
+
+#endif /* ATOMDESCRIPTORUNITTEST_HPP_ */
Index: src/Descriptors/unittests/Makefile.am
===================================================================
--- src/Descriptors/unittests/Makefile.am	(revision e7da1f59b247209d90468802fd9412179ff04717)
+++ src/Descriptors/unittests/Makefile.am	(revision e7da1f59b247209d90468802fd9412179ff04717)
@@ -0,0 +1,40 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+AM_CPPFLAGS = ${BOOST_CPPFLAGS}
+
+TESTS = \
+  AtomDescriptorUnitTest
+
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS)
+
+BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB)
+GSLLIBS = \
+	../../LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
+	../../Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
+	../../Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
+	$(BOOST_LIB)
+ALLLIBS = \
+	../../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la \
+	../../Actions/libMolecuilderActions-@MOLECUILDER_API_VERSION@.la \
+	${PARSERLIBS} \
+	../../libMolecuilder-@MOLECUILDER_API_VERSION@.la \
+	${GSLLIBS}
+
+PARSERLIBS = ../../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
+UILIBS = ../../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la  
+
+
+AtomDescriptorUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	AtomDescriptorUnitTest.cpp \
+	AtomDescriptorUnitTest.hpp
+AtomDescriptorUnitTest_LDADD = ${ALLLIBS}
+
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
