OpenWalnut  1.5.0dev
WDataSetSingle_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WDATASETSINGLE_TEST_H
26 #define WDATASETSINGLE_TEST_H
27 
28 #include <memory>
29 #include <stdint.h>
30 #include <vector>
31 
32 #include <cxxtest/TestSuite.h>
33 
34 #include "../../common/WLogger.h"
35 #include "../WDataHandlerEnums.h"
36 #include "../WDataSetSingle.h"
37 #include "../WGrid.h"
38 #include "../WGridRegular3D.h"
39 #include "../WValueSet.h"
40 
41 /**
42  * Test important functionality of WDataSetSingle class
43  */
44 class WDataSetSingleTest : public CxxTest::TestSuite
45 {
46 public:
47  std::shared_ptr< WGrid > gridDummy; //!< Dummy grid used in the tests.
48  std::shared_ptr< WValueSetBase > valueSetDummy; //!< Dummy value set used in the tests.
49 
50  /**
51  * Constructs unit test environment.
52  */
53  void setUp( void )
54  {
56 
57  // create dummies, since they are needed in almost every test
58  gridDummy = std::shared_ptr< WGrid >( new WGridRegular3D( 1, 1, 1 ) );
59  std::shared_ptr< std::vector< int8_t > > data( new std::vector< int8_t >( 1, 1 ) );
60  valueSetDummy = std::shared_ptr< WValueSet< int8_t > >( new WValueSet< int8_t >( 0, 1, data, W_DT_INT8 ) );
61  }
62 
63  /**
64  * During instantiation nothing should be thrown.
65  */
66  void testInstantiation( void )
67  {
68  TS_ASSERT_THROWS_NOTHING( WDataSetSingle ds( valueSetDummy, gridDummy ) );
69  }
70 
71  /**
72  * Retrieving a WValueSetBase should always give the original pointer.
73  */
74  void testGetValueSet( void )
75  {
76  std::shared_ptr< std::vector< double > > data( new std::vector< double >( 1, 3.1415 ) );
77  std::shared_ptr< WValueSet< double > > other;
78  other = std::shared_ptr< WValueSet< double > >( new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
79  WDataSetSingle dataSetSingle( valueSetDummy, gridDummy );
80  TS_ASSERT_EQUALS( dataSetSingle.getValueSet(), valueSetDummy );
81  TS_ASSERT_DIFFERS( dataSetSingle.getValueSet(), other );
82  }
83 
84  /**
85  * Retrieving a WGrid should always give the original pointer.
86  */
87  void testGetGrid( void )
88  {
89  std::shared_ptr< WGrid > other = std::shared_ptr< WGridRegular3D >( new WGridRegular3D( 1, 1, 1 ) );
90  WDataSetSingle dataSetSingle( valueSetDummy, gridDummy );
91  TS_ASSERT_EQUALS( dataSetSingle.getGrid(), gridDummy );
92  TS_ASSERT_DIFFERS( dataSetSingle.getGrid(), other );
93  }
94 };
95 #endif // WDATASETSINGLE_TEST_H
Test important functionality of WDataSetSingle class.
std::shared_ptr< WValueSetBase > valueSetDummy
Dummy value set used in the tests.
void testInstantiation(void)
During instantiation nothing should be thrown.
void setUp(void)
Constructs unit test environment.
void testGetGrid(void)
Retrieving a WGrid should always give the original pointer.
void testGetValueSet(void)
Retrieving a WValueSetBase should always give the original pointer.
std::shared_ptr< WGrid > gridDummy
Dummy grid used in the tests.
A data set consisting of a set of values based on a grid.
std::shared_ptr< WGrid > getGrid() const
A grid that has parallelepiped cells which all have the same proportion.
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
Definition: WLogger.cpp:41
Base Class for all value set types.
Definition: WValueSet.h:47