00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00039
00040 class WDataSetDTITest : public CxxTest::TestSuite
00041 {
00042 public:
00043
00044
00045
00046 void setUp()
00047 {
00048 WLogger::startup();
00049 }
00050
00051
00052
00053
00054 void testInstanziation( void )
00055 {
00056 float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
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
00067
00068
00069 void testTensorAccess( void )
00070 {
00071 float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
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