1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
25
#ifndef WMIXINVECTOR_TEST_H
26
#define WMIXINVECTOR_TEST_H
31
#include <cxxtest/TestSuite.h>
33
#include "../WMixinVector.h"
34
#include "WMixinVectorTraits.h"
36
// \cond Suppress_Doxygen
37
// This is just a dummy class to test if the default constructor is called when
38
// not specified by WMixinVector instanziation.
39
class A {public: A(){m_x = 3.1415;} bool operator==(double x){return m_x == x;} double m_x; }; // NOLINT
43
* Unit tests the WMixinVector copy from OSG
44
* \warning THIS IS FAR AWAY FROM BEING A COMPLETE UNIT TEST SUIT FOR WMIXINVECTOR!!!
46
class WMixinVectorTest : public CxxTest::TestSuite
50
* Test the default Ctor
52
void testDefaultCtor( void )
54
TS_ASSERT_THROWS_NOTHING( WMixinVector< double >() );
58
* You may initialize a vector with a given size and optionally with
59
* a default value of the elments.
61
void testSizeValueCtor( void )
63
WMixinVector< std::string > stringV( 2, "bla" );
64
TS_ASSERT( stringV.size() == 2 );
65
TS_ASSERT_EQUALS( stringV[0], "bla" );
66
TS_ASSERT_EQUALS( stringV[1], "bla" );
67
WMixinVector< A > aV( 5 );
68
TS_ASSERT_EQUALS( aV.size(), 5 );
69
for( size_t i = 0; i < 5; ++i )
71
TS_ASSERT_EQUALS( aV[i], 3.1415 );
76
* If you have another WMixinVector a copy construction should be possible
78
void testCopyCtorOnWMixinVector( void )
80
WMixinVector< int > intV( 4, -1 );
81
WMixinVector< int > intV2( intV );
82
TS_ASSERT_EQUALS( intV, intV2 );
84
TS_ASSERT_DIFFERS( intV, intV2 );
88
* If you have a std::vector< T > copy construction should still be possible.
90
void testCopyCtorOnRealSTDVector( void )
92
std::vector< char > charV( 5, 's' );
93
WMixinVector< char > charV2( charV );
94
TS_ASSERT_EQUALS( charV, charV2 );
96
TS_ASSERT_DIFFERS( charV, charV2 );
100
* A creation should also be possible out of iterators
102
void testIteratorConstructor( void )
104
int myints[] = { 16, 2, 77, 29 }; // NOLINT
105
WMixinVector< int > v( myints, myints + sizeof( myints ) / sizeof( int ) );
106
TS_ASSERT_EQUALS( v.size(), 4 );
107
TS_ASSERT_EQUALS( v[0], 16 );
108
TS_ASSERT_EQUALS( v[1], 2 );
109
TS_ASSERT_EQUALS( v[2], 77 );
110
TS_ASSERT_EQUALS( v[3], 29 );
114
#endif // WMIXINVECTOR_TEST_H