Commit c2d2c9a9 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] added test that was lying around in my working directory for some time

parent d4033699
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WDATASETSCALAR_TEST_H
#define WDATASETSCALAR_TEST_H
#include <vector>
#include <cxxtest/TestSuite.h>
#include "../WDataSetScalar.h"
/**
* TODO(wiebel): Document this!
*/
class WDataSetScalarTest : public CxxTest::TestSuite
{
public:
/**
* Test if the interpolate function works reasonable.
*/
void testInterpolate( void )
{
// create dummies, since they are needed in almost every test
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3, 1, 1, 1 ) );
std::vector< double > data( grid->size() );
for( size_t i = 0; i < grid->size(); ++i )
{
data[i] = i;
}
boost::shared_ptr< WValueSet< double > > valueSet( new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
WDataSetScalar ds( valueSet, grid );
bool success = false;
TS_ASSERT_EQUALS( ds.interpolate( wmath::WPosition(), &success ), data[0] );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 0 ), &success ), data[1], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 0 ), &success ), data[5], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 0 ), &success ), data[6], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 0, 1 ), &success ), data[15], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 1 ), &success ), data[16], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 1 ), &success ), data[20], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 1 ), &success ), data[21], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.3, 0.4, 0.5 ), &success ), 9.8, 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.5, 0.5, 0.5 ), &success ), 10.5, 1e-9 );
TS_ASSERT( success );
}
};
#endif // WDATASETSCALAR_TEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment