Index: src/Jobs/Grid/unittests/SamplingGridUnitTest.cpp
===================================================================
--- src/Jobs/Grid/unittests/SamplingGridUnitTest.cpp	(revision 3d9a8d42283c7e552de1b62b094fae5646d71ce4)
+++ src/Jobs/Grid/unittests/SamplingGridUnitTest.cpp	(revision 1a00bbfd3d648bf38e39a80bc5a7461e50177425)
@@ -82,9 +82,7 @@
 }
 
-#define NUMBEROFSAMPLES(n) pow(pow(2,n),3)
-
-/** UnitTest for operator+=()
- */
-void SamplingGridTest::superposeOtherGrid_Test()
+/** UnitTest on compatible combination of props and values
+ */
+void SamplingGridTest::compatibleGrids_Test()
 {
   // check illegal grid
@@ -92,16 +90,22 @@
   const double end[3] = { 2., 2., 2. };
   SamplingGridProperties illegal_props(begin, end, 1);
+  SamplingGridProperties legal_props(begin, end, 2);
   CPPUNIT_ASSERT( !grid->isCompatible(illegal_props) );
+  CPPUNIT_ASSERT( grid->isCompatible(legal_props) );
   SamplingGrid::sampledvalues_t illegal_values;
   for (size_t i=0; i< NUMBEROFSAMPLES(1); ++i)
     illegal_values += 1.5;
-  SamplingGrid illegal_grid(illegal_props, illegal_values);
+  SamplingGrid::sampledvalues_t legal_values;
+  for (size_t i=0; i< NUMBEROFSAMPLES(2); ++i)
+    illegal_values += 1.5;
 #ifndef NDEBUG
-  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
-  CPPUNIT_ASSERT_THROW( *grid += illegal_grid, Assert::AssertionFailure );
-#else
-  *grid += illegal_grid;
+  // throws because props and size of illegal_values don't match
+  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
+  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, illegal_values), Assert::AssertionFailure );
+  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
+  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(legal_props, illegal_values), Assert::AssertionFailure );
+  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
+  CPPUNIT_ASSERT_THROW( SamplingGrid illegal_grid(illegal_props, legal_values), Assert::AssertionFailure );
 #endif
-
   // check that grid is still the same
   for (SamplingGrid::sampledvalues_t::const_iterator iter = grid->sampled_grid.begin();
@@ -115,4 +119,66 @@
 {
   CPPUNIT_ASSERT_EQUAL( 1., grid->getVolume() );
+}
+
+/** UnitTest for getWindowSize_Test
+ */
+void SamplingGridTest::getWindowSize_Test()
+{
+  // check size of default grid
+  CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(2), grid->getWindowGridPoints() );
+
+  // create another one and check its size, too
+  const double begin[3] = { 0., 0., 0. };
+  const double end[3] = { 1., 1., 1. };
+  for (size_t level = 3; level<=6; ++level) {
+    values.clear();
+    for (size_t i=0; i< NUMBEROFSAMPLES(level); ++i)
+      values += grid_value;
+    delete grid;
+    grid = new SamplingGrid(begin, end, level, values);
+    CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(level), grid->getWindowGridPoints() );
+  }
+}
+
+/** UnitTest for extendWindow()
+ */
+void SamplingGridTest::extendWindow_Test()
+{
+  // we have a grid with size of two, extend to twice the size and check
+  const double begin[3] = { 0., 0., 0. };
+  const double end[3] = { 2., 2., 2. };
+  grid->extendWindow(begin, end);
+
+  // check integral
+  CPPUNIT_ASSERT_EQUAL( NUMBEROFSAMPLES(2)*grid_value, grid->integral() );
+
+  // check number of points
+  CPPUNIT_ASSERT_EQUAL( (size_t)NUMBEROFSAMPLES(3), grid->getWindowGridPoints() );
+}
+
+/** UnitTest for addOntoWindow()
+ */
+void SamplingGridTest::addOntoWindow_Test()
+{
+  // first window is from (0,0,0) to (1,1,1)
+  CPPUNIT_ASSERT_EQUAL( 1.*grid_value, grid->integral() );
+
+  // create another window from (.5,.5,.5) to (1., 1., 1.)
+  const double begin[3] = { .5, .5, .5 };
+  const double end[3] = { 1., 1., 1. };
+  values.clear();
+  for (size_t i=0; i< NUMBEROFSAMPLES(2)/pow(2,3); ++i) // cut in half
+    values += grid_value;
+  // check that too large a window throws
+#ifndef NDEBUG
+  const double wrongend[3] = { 1.5, 1.5, 1.5 };
+  std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
+  CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values), Assert::AssertionFailure );
+#endif
+  // now perform working operation
+  grid->addOntoWindow(begin, end, values);
+
+  // check integral to be one and half times the old value
+  CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,3))*grid_value, grid->integral() );
 }
 
