/*
 * Project: MoleCuilder
 * Description: creates and alters molecular systems
 * Copyright (C)  2010-2012 University of Bonn. 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 .
 */
/*
 * IsInsideDomain_FillPredicateUnitTest.cpp
 *
 *  Created on: Jan 19, 2012
 *      Author: heber
 */
// include config.h
#ifdef HAVE_CONFIG_H
#include 
#endif
#include 
#include 
#include 
#include "CodePatterns/Assert.hpp"
#include "Box.hpp"
#include "Filling/Predicates/IsInsideDomain_FillPredicate.hpp"
#include "LinearAlgebra/RealSpaceMatrix.hpp"
#include "Filling/NodeTypes.hpp"
#include "IsInsideDomain_FillPredicateUnitTest.hpp"
#ifdef HAVE_TESTRUNNER
#include "UnitTestMain.hpp"
#endif /*HAVE_TESTRUNNER*/
/********************************************** Test classes **************************************/
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( IsInsideDomain_FillPredicateTest );
void IsInsideDomain_FillPredicateTest::setUp()
{
  // failing asserts should be thrown
  ASSERT_DO(Assert::Throw);
  M = new RealSpaceMatrix;
  M->setIdentity();
  (*M) *= 20.;
  domain = new Box(*M);
  predicate = new FillPredicate(IsInsideDomain_FillPredicate(*domain));
}
void IsInsideDomain_FillPredicateTest::tearDown()
{
  delete predicate;
  delete domain;
  delete M;
}
/** Test whether operator() returns as desired
 *
 */
void IsInsideDomain_FillPredicateTest::operatorTest()
{
  Node origin(0.,0.,0.);
  Node center(10.,10.,10.);
  Node corner(20.,20.,20.);
  Node outside(30.,30.,30.);
  {
    // origin is inside
    CPPUNIT_ASSERT( (*predicate)(origin) );
    // center is inside
    CPPUNIT_ASSERT( (*predicate)(center) );
    // corner is inside
    CPPUNIT_ASSERT( (*predicate)(corner) );
    // outside is outside
    CPPUNIT_ASSERT( !(*predicate)(outside) );
  }
}