84 lines
2.1 KiB
C++
84 lines
2.1 KiB
C++
|
#include <cxxtest/TestSuite.h>
|
||
|
|
||
|
#include "topologyreadercsv.hh"
|
||
|
|
||
|
class TopologyReaderCSV_test: public CxxTest::TestSuite
|
||
|
{
|
||
|
private:
|
||
|
std::string topology_file_name ;
|
||
|
|
||
|
public:
|
||
|
|
||
|
TopologyReaderCSV_test(void):
|
||
|
topology_file_name("/tmp/TopologyReaderCSV_topology_file.csv")
|
||
|
{
|
||
|
Stock::clear() ;
|
||
|
|
||
|
std::ofstream topology_file(topology_file_name.c_str()) ;
|
||
|
topology_file
|
||
|
<< "My building;My room #1;1;2;3;9;8;7\n"
|
||
|
<< "My building;Room #2;4;5;6;6;5;4\n"
|
||
|
<< "Building #2;My room #1;1;2;3;9;8;7\n"
|
||
|
<< "My building;Room #2;4;5;6;6;5;4\n"
|
||
|
<< "My building;Room #2;4;5;6;6;5;4\n" ;
|
||
|
topology_file.close() ;
|
||
|
}
|
||
|
|
||
|
|
||
|
~TopologyReaderCSV_test(void)
|
||
|
{
|
||
|
Stock::clear() ;
|
||
|
TestUtil::remove_file(topology_file_name) ;
|
||
|
}
|
||
|
|
||
|
|
||
|
static TopologyReaderCSV_test* createSuite(void)
|
||
|
{
|
||
|
return new TopologyReaderCSV_test() ;
|
||
|
}
|
||
|
|
||
|
|
||
|
static void destroySuite(TopologyReaderCSV_test *suite)
|
||
|
{
|
||
|
delete suite ;
|
||
|
}
|
||
|
|
||
|
|
||
|
void test_topologyreadercsv(void)
|
||
|
{
|
||
|
TS_ASSERT_THROWS_NOTHING(
|
||
|
TopologyReaderCSV toporeader(topology_file_name)) ;
|
||
|
|
||
|
Building *building1 ;
|
||
|
TS_ASSERT_THROWS_NOTHING(
|
||
|
building1 = const_cast<Building*>(
|
||
|
&Stock::get_building("My building"))) ;
|
||
|
Building *building2 ;
|
||
|
TS_ASSERT_THROWS_NOTHING(
|
||
|
building2 = const_cast<Building*>(
|
||
|
&Stock::get_building("Building #2"))) ;
|
||
|
|
||
|
TS_ASSERT_EQUALS(building1->get_areas().size(), 2u) ;
|
||
|
|
||
|
Area *area_ptr ;
|
||
|
area_ptr = building1->get_areas().find("My room #1")->second ;
|
||
|
Area area1(building1, "My room #1",
|
||
|
Point3D(1,2,3), Point3D(9,8,7)) ;
|
||
|
assert(area_ptr) ;
|
||
|
TS_ASSERT_EQUALS(*area_ptr, area1) ;
|
||
|
|
||
|
area_ptr = building1->get_areas().find("Room #2")->second ;
|
||
|
assert(area_ptr) ;
|
||
|
Area area2(building1, "Room #2",
|
||
|
Point3D(4,5,6), Point3D(6,5,4)) ;
|
||
|
TS_ASSERT_EQUALS(*area_ptr, area2) ;
|
||
|
|
||
|
TS_ASSERT_EQUALS(building2->get_areas().size(), 1u) ;
|
||
|
area1.set_building(building2) ;
|
||
|
area_ptr = building2->get_areas().find("My room #1")->second ;
|
||
|
assert(area_ptr) ;
|
||
|
TS_ASSERT_EQUALS(*area_ptr, area1) ;
|
||
|
}
|
||
|
|
||
|
} ;
|