#include "StationTest.h" #include "Station.h" #include "Error.h" #include "Logger.h" #include #include using namespace std; CPPUNIT_TEST_SUITE_REGISTRATION (StationTest); void StationTest::setUp (void) { logTest(); try { mpStation = NULL; string stationExecutable; mpStation = new Station(stationExecutable, 0); } catch ( Error &e ) { e.display(); } } void StationTest::tearDown (void) { logTest(); if (NULL != mpStation) { delete (mpStation); mpStation = NULL; } } void StationTest::setStationNameTest (void) { logTest(); if (NULL == mpStation) { CPPUNIT_FAIL ( "The initialized Station pointer is NULL" ); } else { string stationName = "This is my station name"; CPPUNIT_ASSERT_MESSAGE ( "setStationName failed", mpStation->setStationName(stationName) ); } } void StationTest::setHiddenStationsListTest (void) { logTest (); HiddenStationsList hiddenStationsList; /* set some initial values: 10 20 30 40 50 */ for (int i = 1; i <= 5; i++) hiddenStationsList.insert (i*10); CPPUNIT_ASSERT_MESSAGE ("setHiddenStationsList failed", mpStation->setHiddenStationsList (hiddenStationsList)); CPPUNIT_ASSERT_MESSAGE ("getHiddenStationsList failed", hiddenStationsList == mpStation->getHiddenStationsList ()); } void StationTest::hideStationTest (void) { logTest (); /* hide a station */ Sci_Msg_Station_Id stationId = 111; CPPUNIT_ASSERT_MESSAGE ("hideStation TRUE failed", mpStation->hideStation (stationId, true)); set::iterator it = mpStation->getHiddenStationsList ().find (stationId); CPPUNIT_ASSERT_MESSAGE ("hideStation failed", *it == stationId); /* make the station visible */ CPPUNIT_ASSERT_MESSAGE ("hideStation FALSE failed", mpStation->hideStation (stationId, false) && mpStation->getHiddenStationsList ().empty ()); }