OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
WValueSetBase_test.h
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 WVALUESETBASE_TEST_H
00026 #define WVALUESETBASE_TEST_H
00027 
00028 #include <cxxtest/TestSuite.h>
00029 
00030 #include "../WValueSetBase.h"
00031 #include "../WDataHandlerEnums.h"
00032 
00033 /**
00034  * Dummy class for testing the abstract class WValueSetBase
00035  */
00036 class Dummy : public WValueSetBase
00037 {
00038 friend class WValueSetBaseTest;
00039 
00040 public:
00041     /**
00042      * Standard constructor of Dummy class.
00043      */
00044     Dummy()
00045         : WValueSetBase( 0, 1, W_DT_INT8 )
00046     {
00047     }
00048 
00049     /**
00050      * Constructor of Dummy class for testing
00051      * \param dimension tensor dimension
00052      */
00053     explicit Dummy( char dimension )
00054         : WValueSetBase( 0, dimension, W_DT_INT8 )
00055     {
00056     }
00057 
00058     /**
00059      * Destructor.
00060      */
00061     virtual ~Dummy()
00062     {
00063     }
00064 
00065     /**
00066      * Get the size.
00067      *
00068      * \return The size.
00069      */
00070     virtual size_t size() const
00071     {
00072         return 255;
00073     }
00074 
00075     /**
00076      * Get the raw size.
00077      *
00078      * \return The raw size.
00079      */
00080     virtual size_t rawSize() const
00081     {
00082         return 255;
00083     }
00084 
00085     /**
00086      * Get the value.
00087      *
00088      * \return The value at position i.
00089      */
00090     virtual double getScalarDouble( size_t /* i */ ) const
00091     {
00092         return 255;
00093     }
00094 
00095     /**
00096      * \return The i-th WValue stored in this value set. There are size() such scalars.
00097      */
00098     virtual WValue< double > getWValueDouble( size_t /*i*/ ) const
00099     {
00100         return WValue< double >( size() );
00101     }
00102 
00103     /**
00104      * \return The i-th WValue (stored in this value set) as WVector_2. There are size() such scalars.
00105      */
00106     virtual WVector_2 getWVector( size_t /*i*/ ) const
00107     {
00108         return WVector_2( size() );
00109     }
00110 
00111     /**
00112      * This method returns the smallest value in the valueset. It does not handle vectors, matrices and so on well. It simply returns the
00113      * smallest value in the data array. This is especially useful for texture scaling or other statistic tools (histograms).
00114      *
00115      * \return the smallest value in the data.
00116      */
00117     virtual double getMinimumValue() const
00118     {
00119         return 0.0;
00120     }
00121 
00122     /**
00123      * This method returns the largest value in the valueset. It does not handle vectors, matrices and so on well. It simply returns the
00124      * largest value in the data array. This is especially useful for texture scaling or other statistic tools (histograms).
00125      *
00126      * \return the largest value in the data.
00127      */
00128     virtual double getMaximumValue() const
00129     {
00130         return 255.0;
00131     }
00132 };
00133 
00134 /**
00135  * Testing abstract class via a Dummy class derived esp. for this purpose.
00136  */
00137 class WValueSetBaseTest : public CxxTest::TestSuite
00138 {
00139 public:
00140     /**
00141      *  Checks if the Dummy is instanceable.
00142      */
00143     void testInstantiation( void )
00144     {
00145         Dummy d;
00146     }
00147 
00148     /**
00149      *  Checks if the dimension using the dummy is right
00150      */
00151     void testDimension( void )
00152     {
00153         Dummy d1;
00154         TS_ASSERT_EQUALS( d1.dimension(), 1 );
00155         Dummy d2( 2 );
00156         TS_ASSERT_EQUALS( d2.dimension(), 2 );
00157     }
00158     /**
00159      *  Checks if the dimension using the dummy is right
00160      */
00161     void testDataType( void )
00162     {
00163         Dummy d1;
00164         TS_ASSERT_EQUALS( d1.getDataType(), W_DT_INT8 );
00165     }
00166 };
00167 
00168 #endif  // WVALUESETBASE_TEST_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends