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).
36 lines
756 B
C++
36 lines
756 B
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/common/byte_buffer.hpp>
|
|
#include <cstring>
|
|
|
|
using namespace vanetza;
|
|
|
|
struct A
|
|
{
|
|
char b[10];
|
|
};
|
|
|
|
TEST(ByteBuffer, buffer_cast) {
|
|
ByteBuffer buf = { 'A', ' ', 't', 'e', 's', 't', ' ', 'b', 'u', 'f', 'f', 'e', 'r' };
|
|
ASSERT_GE(buf.size(), sizeof(A));
|
|
A* a = buffer_cast<A>(buf);
|
|
ASSERT_NE(nullptr, a);
|
|
EXPECT_EQ(a->b[0], 'A');
|
|
EXPECT_EQ(a->b[4], 's');
|
|
EXPECT_EQ(a->b[9], 'f');
|
|
}
|
|
|
|
TEST(ByteBuffer, buffer_copy) {
|
|
A a;
|
|
strcpy(a.b, "123456789");
|
|
auto copy = buffer_copy(a);
|
|
ASSERT_EQ(copy.size(), 10);
|
|
EXPECT_EQ(copy[0], '1');
|
|
EXPECT_EQ(copy[3], '4');
|
|
EXPECT_EQ(copy[8], '9');
|
|
EXPECT_EQ(copy[9], '\0');
|
|
|
|
a.b[0] = 'X';
|
|
EXPECT_EQ(copy[0], '1');
|
|
}
|
|
|