1
0
Fork 0
mirror of https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git synced 2025-07-29 18:20:07 +02:00

Add test for non-empty waypoint file

This commit is contained in:
Tim Schubert 2020-07-07 15:21:14 +02:00
parent 42787c2b41
commit e1bca0b7d9
3 changed files with 57 additions and 5 deletions

View file

@ -32,9 +32,49 @@ LeoWaypointFileEmptyTestCase::DoRun (void)
container->SetAttribute("LastTime", TimeValue (Time (1)));
Waypoint wp;
bool res = container->GetNextSample(wp);
uint32_t i = 0;
while (container->GetNextSample (wp))
{
i ++;
}
NS_TEST_ASSERT_MSG_EQ (res, false, "Reading from empty stream fails");
NS_TEST_ASSERT_MSG_EQ ((i == 0), true, "Reading waypoints from empty");
}
class LeoWaypointSomeEntriesTestCase : public TestCase
{
public:
LeoWaypointSomeEntriesTestCase ();
virtual ~LeoWaypointSomeEntriesTestCase ();
private:
virtual void DoRun (void);
};
LeoWaypointSomeEntriesTestCase::LeoWaypointSomeEntriesTestCase ()
: TestCase ("Test reading from non-empty file")
{
}
LeoWaypointSomeEntriesTestCase::~LeoWaypointSomeEntriesTestCase ()
{
}
void
LeoWaypointSomeEntriesTestCase::DoRun (void)
{
Ptr<LeoWaypointInputFileStreamContainer> container = CreateObject<LeoWaypointInputFileStreamContainer> ();
container->SetAttribute("File", StringValue ("contrib/leo/data/waypoints.txt"));
container->SetAttribute("LastTime", TimeValue (Time (1)));
Waypoint wp;
uint32_t i = 0;
while (container->GetNextSample (wp))
{
i ++;
}
NS_TEST_ASSERT_MSG_EQ ((i > 0), true, "Reading from non-empty stream succeeds");
}
class LeoWaypointsTestSuite : public TestSuite
@ -48,6 +88,7 @@ LeoWaypointsTestSuite::LeoWaypointsTestSuite ()
{
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
AddTestCase (new LeoWaypointFileEmptyTestCase, TestCase::QUICK);
AddTestCase (new LeoWaypointSomeEntriesTestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite