ADD: updated Tracklist and TracklistItem with tests
This commit is contained in:
@@ -22,20 +22,57 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
|
||||
SimCore::Identifier OwnID;
|
||||
TrackList::TrackList List(OwnID);
|
||||
List.setTrackTimeout(5000);
|
||||
|
||||
double speed = 10;
|
||||
double course = 90;
|
||||
SimCore::Identifier id;
|
||||
auto track = std::make_shared<SimCore::SimTrack>(id,"Hamburg", SimCore::Kind::EntityKind::SURFACE,SimCore::Side::FRIEND);
|
||||
SimCore::Position pos;
|
||||
pos.setGeodesicPos(55, 8, 0);
|
||||
track->setPosition(pos);
|
||||
track->Speed.setValue(speed);
|
||||
track->Course.setValue(course);
|
||||
|
||||
|
||||
TrackList::SensorData Sensor1 =
|
||||
{
|
||||
.sensorID = SimCore::Identifier(),
|
||||
.Sensorname = "ARPA"
|
||||
};
|
||||
|
||||
TrackList::SensorData Sensor2 =
|
||||
{
|
||||
.sensorID = SimCore::Identifier(),
|
||||
.Sensorname = "SMART-L"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
List.addTrack(track,Sensor1);
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
|
||||
// REQUIRE(InternalTracklist.size() == 1);
|
||||
|
||||
REQUIRE(List.size() == 1);
|
||||
REQUIRE(List.getTrack(id)->getPosition().getGeocentricPos() == pos.getGeocentricPos());
|
||||
REQUIRE(List.getTrack(id)->Speed.getValue() == speed);
|
||||
REQUIRE(List.getTrack(id)->Course.getValue() == course);
|
||||
REQUIRE(List.getTrack(id)->getSensorCount() == 1);
|
||||
track->Course.setValue(270);
|
||||
List.addTrack(track,Sensor2);
|
||||
// REQUIRE(List.getTrack(id)->Course.getValue() == 270);
|
||||
REQUIRE(List.getTrack(id)->getSensorCount() == 2);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5500));
|
||||
REQUIRE(List.size() == 0);
|
||||
|
||||
List.stopSanitizer();
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
|
||||
79
tests/test_TracklistItem.cpp
Normal file
79
tests/test_TracklistItem.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
#include "Entities/Tracklist/Tracklist.hpp"
|
||||
#include "Entities/Tracklist/TracklistItem.hpp"
|
||||
#include "SimCore/IdentifierMaker.hpp"
|
||||
#include "SimCore/Messages/SimTrack.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#include "WHISPER/Messages/Message.hpp"
|
||||
#include <SimCore/Identifier.hpp>
|
||||
#include <SimCore/SimCore.hpp>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SCENARIO("Testing the SimCore Sensor")
|
||||
{
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
double speed = 10;
|
||||
double course = 90;
|
||||
SimCore::Identifier id;
|
||||
auto track = std::make_shared<SimCore::SimTrack>(id,"Hamburg", SimCore::Kind::EntityKind::SURFACE,SimCore::Side::FRIEND);
|
||||
SimCore::Position pos;
|
||||
pos.setGeodesicPos(55, 8, 0);
|
||||
track->setPosition(pos);
|
||||
track->Speed.setValue(speed);
|
||||
track->Course.setValue(course);
|
||||
|
||||
TrackList::TracklistItem item(track);
|
||||
|
||||
TrackList::SensorData Sensor1 =
|
||||
{
|
||||
.sensorID = SimCore::Identifier(),
|
||||
.Sensorname = "ARPA"
|
||||
};
|
||||
|
||||
TrackList::SensorData Sensor2 =
|
||||
{
|
||||
.sensorID = SimCore::Identifier(),
|
||||
.Sensorname = "SMART-L"
|
||||
};
|
||||
|
||||
item.addSensorDataToSensorList(Sensor1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
track->Course.setValue(270);
|
||||
|
||||
item.updateTrack(track,Sensor2);
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
|
||||
REQUIRE(item.getPosition().getGeocentricPos() == pos.getGeocentricPos());
|
||||
REQUIRE(item.Speed.getValue() == speed);
|
||||
REQUIRE(item.Course.getValue() != course);
|
||||
REQUIRE(item.isSensorIDKnown(Sensor1.sensorID) == true);
|
||||
|
||||
REQUIRE(item.getSensorCount() == 2);
|
||||
REQUIRE(item.getLastUpdateTimestamp() < std::chrono::steady_clock::now());
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
Reference in New Issue
Block a user