Add focused backend tests
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
#include <drogon/drogon.h>
|
||||
#include <drogon/drogon_test.h>
|
||||
|
||||
#include "common/GeoJson.h"
|
||||
#include "common/Validation.h"
|
||||
|
||||
#include <future>
|
||||
|
||||
using namespace drogon;
|
||||
@@ -44,6 +47,44 @@ DROGON_TEST(HealthEndpoint)
|
||||
"visione-backend");
|
||||
}
|
||||
|
||||
DROGON_TEST(ValidationRejectsMalformedIdentity)
|
||||
{
|
||||
CHECK(visione::validation::isValidEmail("[email protected]"));
|
||||
CHECK(!visione::validation::isValidEmail("not-an-email"));
|
||||
CHECK(visione::validation::isValidFiscalCode("RSSMRA80A01H501U"));
|
||||
CHECK(!visione::validation::isValidFiscalCode("short"));
|
||||
}
|
||||
|
||||
DROGON_TEST(GeoJsonMatchesPointInsidePolygon)
|
||||
{
|
||||
Json::Value polygon;
|
||||
polygon["type"] = "Polygon";
|
||||
Json::Value ring(Json::arrayValue);
|
||||
|
||||
Json::Value a(Json::arrayValue);
|
||||
a.append(12.0);
|
||||
a.append(41.0);
|
||||
Json::Value b(Json::arrayValue);
|
||||
b.append(13.0);
|
||||
b.append(41.0);
|
||||
Json::Value c(Json::arrayValue);
|
||||
c.append(13.0);
|
||||
c.append(42.0);
|
||||
Json::Value d(Json::arrayValue);
|
||||
d.append(12.0);
|
||||
d.append(42.0);
|
||||
|
||||
ring.append(a);
|
||||
ring.append(b);
|
||||
ring.append(c);
|
||||
ring.append(d);
|
||||
ring.append(a);
|
||||
polygon["coordinates"].append(ring);
|
||||
|
||||
CHECK(visione::geojson::pointInPolygon(41.5, 12.5, polygon));
|
||||
CHECK(!visione::geojson::pointInPolygon(43.0, 12.5, polygon));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::promise<void> startedPromise;
|
||||
|
||||
Reference in New Issue
Block a user