Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/geonet/tests/basic_header.cpp
T
Ashin Walpola 0e9525162d Keep the colleague's microbu-esp32c5 tree in this repository
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).
2026-09-23 17:46:40 +02:00

44 lines
1.2 KiB
C++

#include <gtest/gtest.h>
#include <vanetza/geonet/basic_header.hpp>
#include <vanetza/geonet/data_request.hpp>
#include <vanetza/geonet/tests/serialization.hpp>
using namespace vanetza::geonet;
using vanetza::units::si::seconds;
TEST(BasicHeader, ctor) {
MIB mib;
BasicHeader a(mib);
EXPECT_EQ(a.lifetime, mib.itsGnDefaultPacketLifetime);
EXPECT_EQ(a.hop_limit, mib.itsGnDefaultHopLimit);
DataRequest req(mib);
req.maximum_lifetime.encode(31.0 * seconds);
req.max_hop_limit = 4;
BasicHeader b(req, mib);
EXPECT_EQ(b.lifetime.decode(), 31.0 * seconds);
EXPECT_EQ(b.hop_limit, 4);
ShbDataRequest shb(mib);
BasicHeader c(shb, mib);
EXPECT_EQ(c.hop_limit, 1);
}
TEST(BasicHeader, serialization) {
BasicHeader a;
a.version = 2;
a.next_header = NextHeaderBasic::Secured;
a.reserved = 0xC3;
a.lifetime.raw(0x89);
a.hop_limit = 218;
BasicHeader b = serialize_roundtrip(a);
EXPECT_EQ(a.version, b.version);
EXPECT_EQ(a.next_header, b.next_header);
EXPECT_EQ(a.reserved, b.reserved);
EXPECT_EQ(a.lifetime, b.lifetime);
EXPECT_EQ(a.hop_limit, b.hop_limit);
EXPECT_EQ(BasicHeader::length_bytes, serialize_length(a));
}