OpenWalnut  1.4.0
WSubject_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 WSUBJECT_TEST_H
26 #define WSUBJECT_TEST_H
27 
28 #include <string>
29 #include <cxxtest/TestSuite.h>
30 
31 #include "../WSubject.h"
32 #include "../WDataSet.h"
33 
34 /**
35  * The tests for our subject class.
36  */
37 class WSubjectTest : public CxxTest::TestSuite
38 {
39 public:
40  /**
41  * Test instantiation of objects of WSubject class
42  */
43  void testInstantiation( void )
44  {
45  TS_ASSERT_THROWS_NOTHING( WSubject() );
46  }
47 
48  /**
49  * Test instantiation of objects of WSubject class with name
50  */
52  {
54  TS_ASSERT_THROWS_NOTHING( WSubject( testInfo ) );
55  }
56 
57  /**
58  * Test whether we have put the info where it belongs and intialized the rest.
59  */
61  {
63  WSubject dummySubject( testInfo );
64  TS_ASSERT_EQUALS( testInfo, dummySubject.m_personalInfo );
65  }
66 
67 
68  /**
69  * Test whether we can retrieve the right info with getName function.
70  */
71  void testGetName()
72  {
74  testInfo.setSubjectID( 1 );
75  testInfo.setLastName( "Testname" );
76  WSubject dummySubject( testInfo );
77  TS_ASSERT_EQUALS( testInfo.getLastName()+", " , dummySubject.getName() );
78  }
79 
80  /**
81  * Test adding and iterating of data sets.
82  */
84  {
85  boost::shared_ptr< WDataSet > dummyDataSet;
86  dummyDataSet = boost::shared_ptr< WDataSet >( new WDataSet );
87  std::string filename = "Hallo";
88  dummyDataSet->setFilename( filename );
89 
90  WSubject dummySubject;
91  dummySubject.addDataSet( dummyDataSet );
92  TS_ASSERT_EQUALS( 1, dummySubject.m_datasets.size() );
93 
94  // iterate the list and find all textures
96  int count = 0;
97  for( WSubject::DatasetConstIterator iter = a->get().begin(); iter != a->get().end(); ++iter )
98  {
99  count++;
100  TS_ASSERT_EQUALS( filename, ( *iter )->getFilename() );
101  TS_ASSERT_EQUALS( dummyDataSet, ( *iter ) );
102  }
103 
104  TS_ASSERT( count == 1 );
105  }
106 
107  /**
108  * Test getting number of datasets.
109  */
111  {
112  boost::shared_ptr< WDataSet > dummyDataSet;
113  dummyDataSet = boost::shared_ptr< WDataSet >( new WDataSet );
114  std::string filename = "Hallo";
115  dummyDataSet->setFilename( filename );
116 
117  WSubject dummySubject;
118  TS_ASSERT_EQUALS( 0, dummySubject.m_datasets.size() );
119  dummySubject.addDataSet( dummyDataSet );
120  TS_ASSERT_EQUALS( 1, dummySubject.m_datasets.size() );
121  dummySubject.addDataSet( dummyDataSet );
122  TS_ASSERT_EQUALS( 2, dummySubject.m_datasets.size() );
123  dummySubject.addDataSet( dummyDataSet );
124  TS_ASSERT_EQUALS( 3, dummySubject.m_datasets.size() );
125  }
126 };
127 
128 #endif // WSUBJECT_TEST_H
static WPersonalInformation createDummyInformation()
Returns an empty dummy WPersonalInformation object.
void testInstantiationWithName(void)
Test instantiation of objects of WSubject class with name.
Definition: WSubject_test.h:51
void setSubjectID(uint64_t subjectID)
Sets the subjectID of the person.
WPersonalInformation m_personalInfo
Information on the person represented by this WSubject.
Definition: WSubject.h:176
DatasetSharedContainerType m_datasets
A container for all WDataSet.
Definition: WSubject.h:163
The tests for our subject class.
Definition: WSubject_test.h:37
Base class for all data set types.
Definition: WDataSet.h:51
std::string getName() const
Returns the name of the subject.
Definition: WSubject.cpp:57
Container for all WDataSets belonging to one subject or patient.
Definition: WSubject.h:45
size_t size() const
The size of the container.
void addDataSet(boost::shared_ptr< WDataSet > dataset)
Insert a new dataset referenced by a pointer.
Definition: WSubject.cpp:67
void setLastName(std::string lastName)
Sets the last or family name of the person if the object is no dummy anymore.
DatasetContainerType::const_iterator DatasetConstIterator
The dataset const iterator.
Definition: WSubject.h:79
DatasetSharedContainerType::ReadTicket getDatasets() const
Returns read-access to the dataset list.
Definition: WSubject.cpp:101
void testGetName()
Test whether we can retrieve the right info with getName function.
Definition: WSubject_test.h:71
void TestConstructorWithInfo()
Test whether we have put the info where it belongs and intialized the rest.
Definition: WSubject_test.h:60
void testGetNumberOfDataSet()
Test getting number of datasets.
void testInstantiation(void)
Test instantiation of objects of WSubject class.
Definition: WSubject_test.h:43
A structure that holds all relevant information about the subject.
boost::shared_ptr< WSharedObjectTicketRead< DatasetContainerType > > ReadTicket
Type for read tickets.
Definition: WSharedObject.h:62
std::string getLastName() const
Returns the last or family name of the person.
void testAddGetDataSet()
Test adding and iterating of data sets.
Definition: WSubject_test.h:83