OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WDATASETDTI_TEST_H 00026 #define WDATASETDTI_TEST_H 00027 00028 #include <vector> 00029 00030 #include <cxxtest/TestSuite.h> 00031 00032 #include "../../common/math/test/WTensorTraits.h" 00033 #include "../../common/WLogger.h" 00034 #include "../WDataSetDTI.h" 00035 #include "../WGridRegular3D.h" 00036 00037 /** 00038 * Testsuite for unit tests of the WDataSetDTI class. 00039 */ 00040 class WDataSetDTITest : public CxxTest::TestSuite 00041 { 00042 public: 00043 /** 00044 * Setup logger and other stuff for each test. 00045 */ 00046 void setUp() 00047 { 00048 WLogger::startup(); 00049 } 00050 00051 /** 00052 * Only values sets of order 1, dim 6 should be used to construct DTI datasets. 00053 */ 00054 void testInstanziation( void ) 00055 { 00056 float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list 00057 boost::shared_ptr< std::vector< float > > data = 00058 boost::shared_ptr< std::vector< float > >( 00059 new std::vector< float >( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) ) ); 00060 boost::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) ); 00061 boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) ); 00062 TS_ASSERT_THROWS_NOTHING( WDataSetDTI( newValueSet, newGrid ) ); 00063 } 00064 00065 /** 00066 * Accessing the i'th tensor is: getting the WValue at that position and 00067 * transform it to a WTensorSym< 2, 3 >. 00068 */ 00069 void testTensorAccess( void ) 00070 { 00071 float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list 00072 boost::shared_ptr< std::vector< float > > data = 00073 boost::shared_ptr< std::vector< float > >( 00074 new std::vector< float >( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) ) ); 00075 boost::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) ); 00076 boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) ); 00077 WDataSetDTI dataset( newValueSet, newGrid ); 00078 WTensorSym< 2, 3, float > expected; 00079 expected( 0, 0 ) = 0.0; 00080 expected( 0, 1 ) = 1.0; 00081 expected( 0, 2 ) = 2.0; 00082 expected( 1, 1 ) = 3.0; 00083 expected( 1, 2 ) = 4.0; 00084 expected( 2, 2 ) = 5.0; 00085 TS_ASSERT_EQUALS( dataset.getTensor( 0 ), expected ); 00086 } 00087 }; 00088 00089 #endif // WDATASETDTI_TEST_H