obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
73 lines
2.3 KiB
C++
73 lines
2.3 KiB
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/asn1/security_profile.hpp>
|
|
#include VANETZA_ASN1_SECURITY_HEADER(Latitude.h)
|
|
#include VANETZA_ASN1_SECURITY_HEADER(Longitude.h)
|
|
#include VANETZA_ASN1_SECURITY_HEADER(TwoDLocation.h)
|
|
#include <vanetza/common/position_fix.hpp>
|
|
#include <vanetza/security/v3/distance.hpp>
|
|
#include <boost/units/cmath.hpp>
|
|
|
|
using namespace vanetza::security::v3;
|
|
namespace units = vanetza::units;
|
|
|
|
namespace boost {
|
|
namespace units {
|
|
|
|
void PrintTo(const vanetza::units::Length& l, std::ostream* out)
|
|
{
|
|
*out << l.value() << " m";
|
|
}
|
|
|
|
void PrintTo(const vanetza::units::GeoAngle& a, std::ostream* out)
|
|
{
|
|
*out << a.value() << " deg";
|
|
}
|
|
|
|
} // namespace units
|
|
} // namespace boost
|
|
|
|
#define EXPECT_ANGLE_EQ(a, b) { \
|
|
double a_value = units::GeoAngle { a }.value(); \
|
|
double b_value = units::GeoAngle { b }.value(); \
|
|
EXPECT_NEAR(a_value, b_value, 1e-6); \
|
|
}
|
|
|
|
#define EXPECT_LENGTH_EQ(a, b) { \
|
|
double a_value = units::Length { a }.value(); \
|
|
double b_value = units::Length { b }.value(); \
|
|
EXPECT_NEAR(a_value, b_value, 1.0); \
|
|
}
|
|
|
|
TEST(Distance, distance)
|
|
{
|
|
vanetza::PositionFix one;
|
|
one.latitude = 48.0 * units::degree;
|
|
one.longitude = 11.0 * units::degree;
|
|
|
|
asn1::TwoDLocation other;
|
|
other.latitude = 480000000;
|
|
other.longitude = 110000000;
|
|
EXPECT_LENGTH_EQ(distance(one, other), 0.0 * units::si::meter);
|
|
|
|
other.latitude = 481234000;
|
|
other.longitude = 109876000;
|
|
EXPECT_LENGTH_EQ(distance(one, other), 13752.4 * units::si::meter);
|
|
}
|
|
|
|
TEST(Distance, convert_latitude)
|
|
{
|
|
EXPECT_ANGLE_EQ(convert_latitude(Vanetza_Security_NinetyDegreeInt_min), -90.0 * units::degree);
|
|
EXPECT_ANGLE_EQ(convert_latitude(Vanetza_Security_NinetyDegreeInt_max), 90 * units::degree);
|
|
EXPECT_ANGLE_EQ(convert_latitude(0), 0 * units::degree);
|
|
EXPECT_FALSE(boost::units::isfinite(convert_latitude(Vanetza_Security_NinetyDegreeInt_unknown)));
|
|
}
|
|
|
|
TEST(Distance, convert_longitude)
|
|
{
|
|
EXPECT_ANGLE_EQ(convert_longitude(Vanetza_Security_OneEightyDegreeInt_min), -179.999999 * units::degree);
|
|
EXPECT_ANGLE_EQ(convert_longitude(Vanetza_Security_OneEightyDegreeInt_max), 180 * units::degree);
|
|
EXPECT_ANGLE_EQ(convert_longitude(0), 0 * units::degree);
|
|
EXPECT_FALSE(boost::units::isfinite(convert_longitude(Vanetza_Security_OneEightyDegreeInt_unknown)));
|
|
}
|
|
|