Index: src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.cpp
===================================================================
--- src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.cpp	(revision 160ad726dba0237d66decaa364adaad56621cba1)
+++ src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.cpp	(revision 160ad726dba0237d66decaa364adaad56621cba1)
@@ -0,0 +1,154 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2016 Frederik Heber. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * ExportGraph_ToJobsUnitTest.cpp
+ *
+ *  Created on: Mar 10, 2016
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "ExportGraph_ToJobsUnitTest.hpp"
+
+#include <limits>
+#include <vector>
+
+#include <boost/assign.hpp>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "Fragmentation/Exporters/ExportGraph_ToJobs.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ExportGraph_ToJobsTest );
+
+
+void ExportGraph_ToJobsTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+//  setVerbosity(6);
+}
+
+
+void ExportGraph_ToJobsTest::tearDown()
+{
+  World::purgeInstance();
+}
+
+/** UnitTest for getGridExtentsForGivenBoundingBox().
+ */
+void ExportGraph_ToJobsTest::getGridExtentsForGivenBoundingBox_Test()
+{
+  double begin[NDIM] = { 0., 0., 0. };
+  double end[NDIM] = { 40., 40., 40. };
+  double level = 5;
+  const SamplingGridProperties domain(begin, end, level);
+  double empty_boundary = 5.;
+
+  std::vector< Vector > fragment_extents =
+      boost::assign::list_of
+      ( Vector( 5.2, 5.2, 5.2) ) // simple test
+      ( Vector( 5., 5., 5.) ); // simple test: higher and lower center is same point
+
+  const double delta = 2.1;
+  for (std::vector< Vector >::const_iterator iter = fragment_extents.begin();
+      iter != fragment_extents.end(); ++iter)
+  {
+    const Vector &fragment_extent = *iter;
+    for (double x = 0.; x <= end[0]-fragment_extent[0]; x+= delta)
+      for (double y = 0.; y <= end[1]-fragment_extent[1]; y+= delta)
+        for (double z = 0.; z <= end[2]-fragment_extent[2]; z+= delta) {
+          Vector minimum( x, y, z);
+          Vector maximum = minimum+fragment_extent;
+          const SamplingGridProperties grid =
+              ExportGraph_ToJobs::getGridExtentsForGivenBoundingBox(
+                  std::make_pair(minimum, maximum), domain, empty_boundary);
+          for (size_t i=0;i<NDIM;++i) {
+            CPPUNIT_ASSERT( grid.begin[i] >= domain.begin[i] );
+            CPPUNIT_ASSERT( grid.end[i] <= domain.end[i] );
+            // check the desired fragment extent plus boundary is contained
+            const double extent = grid.end[i] - grid.begin[i];
+            CPPUNIT_ASSERT (extent > (2.*empty_boundary+fragment_extent[i]));
+            // check the number of grid points of the grid is divisible integer and ...
+            const double delta = domain.getDeltaPerAxis(i); // grid would give a screwed delta that matches
+            const unsigned int gridpoints = extent/delta;
+            CPPUNIT_ASSERT ( fabs( extent/delta - (double)gridpoints) < std::numeric_limits<double>::epsilon()*1e4 );
+            // ... divisible by 2
+            const double power = log(extent/delta)/log(2.);
+            const unsigned int power_of_two = power;
+            CPPUNIT_ASSERT_EQUAL( (int)power_of_two, grid.level );
+            CPPUNIT_ASSERT ( fabs( power - (double)power_of_two) < std::numeric_limits<double>::epsilon()*1e4 );
+            CPPUNIT_ASSERT ( fabs( ::pow(2., power_of_two) - gridpoints) < std::numeric_limits<double>::epsilon()*1e4);
+            // check that fragment grid's begin and end are on domain discrete points
+            const double lower_begin = domain.getNearestLowerGridPoint(grid.begin[i], i);
+            const double higher_begin = domain.getNearestHigherGridPoint(grid.begin[i], i);
+            CPPUNIT_ASSERT( fabs( lower_begin - higher_begin) < std::numeric_limits<double>::epsilon()*1e4 );
+            const double lower_end = domain.getNearestLowerGridPoint(grid.end[i], i);
+            const double higher_end = domain.getNearestHigherGridPoint(grid.end[i], i);
+            CPPUNIT_ASSERT( fabs( lower_end - higher_end) < std::numeric_limits<double>::epsilon()*1e4 );
+          }
+        }
+  }
+}
+
+/** UnitTest for setAcceptableFragmentLevel().
+ */
+void ExportGraph_ToJobsTest::setAcceptableFragmentLevel_Test()
+{
+  double begin[NDIM] = { 0., 0., 0. };
+  double end[NDIM] = { 20., 20., 20. };
+  double level = 5;
+
+  const double min_meshwidth = 20./::pow(2., level);
+  const unsigned int threshold_level = 9;
+  const double threshold = 20./::pow(2., threshold_level);
+  const double delta = 0.05;
+
+  for (double max_meshwidth = min_meshwidth+1.; max_meshwidth >= threshold; max_meshwidth -= delta) {
+    SamplingGridProperties domain(begin, end, level);
+    ExportGraph_ToJobs::setAcceptableFragmentLevel(domain, max_meshwidth);
+    // may never get smaller than initial value
+    CPPUNIT_ASSERT( (unsigned int)domain.level >= level );
+    // cannot get larger than upper most level
+    CPPUNIT_ASSERT( (unsigned int)domain.level <= threshold_level );
+  }
+}
Index: src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.hpp
===================================================================
--- src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.hpp	(revision 160ad726dba0237d66decaa364adaad56621cba1)
+++ src/Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.hpp	(revision 160ad726dba0237d66decaa364adaad56621cba1)
@@ -0,0 +1,40 @@
+/*
+ * ExportGraph_ToJobsUnitTest.hpp
+ *
+ *  Created on: Mar 10, 2016
+ *      Author: heber
+ */
+
+#ifndef EXPORTGRAPH_TOJOBSUNITTEST_HPP_
+#define EXPORTGRAPH_TOJOBSUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Graph;
+
+/********************************************** Test classes **************************************/
+
+class ExportGraph_ToJobsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( ExportGraph_ToJobsTest) ;
+    CPPUNIT_TEST ( getGridExtentsForGivenBoundingBox_Test );
+    CPPUNIT_TEST ( setAcceptableFragmentLevel_Test );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void getGridExtentsForGivenBoundingBox_Test();
+      void setAcceptableFragmentLevel_Test();
+
+private:
+      Graph *Totalgraph;
+};
+
+#endif /* EXPORTGRAPH_TOJOBSUNITTEST_HPP_ */
Index: src/Fragmentation/Exporters/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Exporters/unittests/Makefile.am	(revision c6ddcb49851617a614ac989bfeae41c91886a779)
+++ src/Fragmentation/Exporters/unittests/Makefile.am	(revision 160ad726dba0237d66decaa364adaad56621cba1)
@@ -3,4 +3,5 @@
 
 FRAGMENTATIONEXPORTERSSOURCES = \
+	../Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.cpp \
 	../Fragmentation/Exporters/unittests/HydrogenPoolUnitTest.cpp \
 	../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.cpp \
@@ -9,4 +10,5 @@
 
 FRAGMENTATIONEXPORTERSTESTSHEADERS = \
+	../Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.hpp \
 	../Fragmentation/Exporters/unittests/HydrogenPoolUnitTest.hpp \
 	../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.hpp \
@@ -16,4 +18,5 @@
 
 FRAGMENTATIONEXPORTERSTESTS = \
+	ExportGraph_ToJobsUnitTest \
 	HydrogenPoolUnitTest \
 	SaturatedFragmentUnitTest \
@@ -31,4 +34,12 @@
 	${CodePatterns_LIBS} \
 	$(BOOST_LIB)
+
+ExportGraph_ToJobsUnitTest_SOURCES = \
+	../Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.cpp \
+	../Fragmentation/Exporters/unittests/ExportGraph_ToJobsUnitTest.hpp
+ExportGraph_ToJobsUnitTest_LDADD = \
+	../libMolecuilderUI.la \
+	../libMolecuilderFragmentationSetValues.la \
+	${ALLLIBS}
 
 HydrogenPoolUnitTest_SOURCES = \
