Index: src/Descriptors/unittests/AtomDescriptorUnitTest.cpp
===================================================================
--- src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision b49568059bb63eb10a31cce9ac87e75d9a32c8e6)
+++ src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision db89600810e8e7e4f9a3b70c23556f264f49cdb6)
@@ -28,8 +28,10 @@
 #include <Descriptors/AtomIdDescriptor.hpp>
 #include <Descriptors/AtomOfMoleculeDescriptor.hpp>
+#include <Descriptors/AtomsWithinDistanceOfDescriptor.hpp>
 
 #include "World.hpp"
 #include "Atom/atom.hpp"
 #include "molecule.hpp"
+#include "LinearAlgebra/Vector.hpp"
 
 #ifdef HAVE_TESTRUNNER
@@ -42,5 +44,6 @@
 
 // set up and tear down
-void AtomDescriptorTest::setUp(){
+void AtomDescriptorTest::setUp()
+{
   World::getInstance();
   for(int i=0;i<ATOM_COUNT;++i){
@@ -50,10 +53,12 @@
 }
 
-void AtomDescriptorTest::tearDown(){
+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>()){
+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];
@@ -73,5 +78,6 @@
 }
 
-static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){
+static bool hasNoDuplicateAtoms(std::vector<atom*> atoms)
+{
   std::set<atomId_t> found;
   std::vector<atom*>::iterator iter;
@@ -86,5 +92,6 @@
 
 
-void AtomDescriptorTest::AtomBaseSetsTest(){
+void AtomDescriptorTest::AtomBaseSetsTest()
+{
   std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
   CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
@@ -94,5 +101,7 @@
   CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
 }
-void AtomDescriptorTest::AtomIdTest(){
+
+void AtomDescriptorTest::AtomIdTest()
+{
   // test Atoms from boundaries and middle of the set
   atom* testAtom;
@@ -120,5 +129,7 @@
   CPPUNIT_ASSERT(!testAtom);
 }
-void AtomDescriptorTest::AtomOfMoleculeTest(){
+
+void AtomDescriptorTest::AtomOfMoleculeTest()
+{
   // test Atoms from boundaries and middle of the set
   atom* testAtom;
@@ -141,5 +152,68 @@
   World::getInstance().destroyMolecule(newmol);
 }
-void AtomDescriptorTest::AtomCalcTest(){
+
+std::set<atomId_t> getDistanceList(const double distance, const Vector &position, atom **list)
+{
+  const double distanceSquared = distance*distance;
+  std::set<atomId_t> reflist;
+  for (size_t i=0; i<ATOM_COUNT;++i)
+    if (list[i]->getPosition().DistanceSquared(position) < distanceSquared)
+      reflist.insert ( list[i]->getId() );
+  return reflist;
+}
+
+
+std::set<atomId_t> getIdList(const World::AtomComposite &list)
+{
+  std::set<atomId_t> testlist;
+  for (World::AtomComposite::const_iterator iter = list.begin();
+      iter != list.end(); ++iter)
+    testlist.insert( (*iter)->getId() );
+  return testlist;
+}
+
+void AtomDescriptorTest::AtomsWithinDistanceOfTest()
+{
+  // align atoms along an axis
+  for(int i=0;i<ATOM_COUNT;++i) {
+    atoms[i]->setPosition(Vector((double)i, 0., 0.));
+    //std::cout << "atoms[" << i << "]: " << atoms[i]->getId() << " at " << atoms[i]->getPosition() << std::endl;
+  }
+
+  // get atom by descriptor ...
+  // ... from origin up to 2.5
+  {
+    const double distance = 1.5;
+    Vector position(0.,0.,0.);
+    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, position));
+    CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() );
+    std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
+    std::set<atomId_t> testlist = getIdList(atomlist);
+    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+  }
+  // ... from (4,0,0) up to 2.9 (i.e. more shells or different view)
+  {
+    const double distance = 2.9;
+    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, Vector(4.,0.,0.)));
+    CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() );
+    std::set<atomId_t> reflist = getDistanceList(distance, Vector(4.,0.,0.), atoms);
+    std::set<atomId_t> testlist = getIdList(atomlist);
+    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+  }
+  // ... from (10,0,0) up to 1.5
+  {
+    const double distance = 1.5;
+    Vector *position = new Vector(10.,0.,0.);
+    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsWithinDistanceOf(distance, *position));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() );
+    std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms);
+    std::set<atomId_t> testlist = getIdList(atomlist);
+    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+    delete position;
+  }
+}
+
+void AtomDescriptorTest::AtomCalcTest()
+{
   // test some elementary set operations
   {
