ADD: added a sanitising function for the tracklist and tests
This commit is contained in:
110
tests/test_tracklist.cpp
Normal file
110
tests/test_tracklist.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
|
||||
|
||||
#include "SimControl/Tracklist.hpp"
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "SimCore/Messages/SimTrack.hpp"
|
||||
#include "SimCore/Position.hpp"
|
||||
#include "SimCore/SimCore.hpp"
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "SimControl/PodList.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include "string.cpp"
|
||||
|
||||
|
||||
|
||||
void createScenario(SimControl::TrackList *list,std::vector<std::string> *ids)
|
||||
{
|
||||
GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
double lat = 54, lon = 1;
|
||||
int counter = 0;
|
||||
double distance = 10000;
|
||||
|
||||
int rasterSize = 5;
|
||||
|
||||
for (int i = 0; i < rasterSize; i++ )
|
||||
{
|
||||
double lonTmp = lon;
|
||||
for (int a = 0; a < rasterSize; a++)
|
||||
{
|
||||
|
||||
std::string name = "test";
|
||||
name += std::to_string(counter);
|
||||
double lat2, lon2;
|
||||
geod.Direct(lat, lonTmp, 90, distance, lat2, lon2);
|
||||
|
||||
SimCore::Identifier id;
|
||||
ids->push_back(id.getUUID());
|
||||
|
||||
SimCore::Position pos;
|
||||
pos.setGeodesicPos(lat2, lon2, 0);
|
||||
auto track = std::make_shared<SimCore::SimTrack>(id,name,SimCore::Kind::EntityKind::SURFACE,SimCore::Side::NEUTRAL);
|
||||
track->setPosition(pos);
|
||||
list->addTrack(track);
|
||||
// SimControl::startNewShip(name, std::to_string(lat2), std::to_string(lon2), "0", "0", "0");
|
||||
lonTmp = lon2;
|
||||
counter ++;
|
||||
}
|
||||
double lat2, lon2;
|
||||
|
||||
geod.Direct(lat, lon, 0, distance, lat2, lon2);
|
||||
|
||||
lat = lat2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
SCENARIO("Testing the the podlist")
|
||||
{
|
||||
|
||||
std::vector<std::string> ids;
|
||||
SimControl::TrackList list;
|
||||
|
||||
createScenario(&list,&ids);
|
||||
|
||||
auto track = list.getTrackBySringID(ids[3]);
|
||||
|
||||
// list.deleteTrack(track->getIdentifier());
|
||||
|
||||
// list.addTrack(track);
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||
|
||||
|
||||
GIVEN("different Attributes for a Track in different forms")
|
||||
{
|
||||
|
||||
WHEN("constructing Track Object with data")
|
||||
{
|
||||
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(ids.size() == 25);
|
||||
REQUIRE(list.getTracklistSize() == 25);
|
||||
|
||||
list.deleteTrack(track->getIdentifier());
|
||||
|
||||
list.addTrack(track);
|
||||
REQUIRE(list.getTracklistSize() == 24);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(7500));
|
||||
LOG_S(INFO)<<"add saved track";
|
||||
list.addTrack(track);
|
||||
LOG_S(INFO)<<"added saved track";
|
||||
|
||||
REQUIRE(list.getTracklistSize() == 25);
|
||||
|
||||
|
||||
|
||||
} //THEN
|
||||
} // WHEN
|
||||
} // GIVEN
|
||||
} //SCENARIO
|
||||
Reference in New Issue
Block a user