Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
include(UseGTest)
|
||||
configure_gtest_directory(LINK_LIBRARIES net)
|
||||
|
||||
add_gtest(ChunkPacket chunk_packet.cpp)
|
||||
add_gtest(CohesivePacket cohesive_packet.cpp)
|
||||
add_gtest(MacAddress mac_address.cpp)
|
||||
add_gtest(OsiLayer osi_layer.cpp)
|
||||
|
||||
if(VANETZA_NET_WITH_POSIX)
|
||||
add_gtest(EthernetHeader ethernet_header.cpp)
|
||||
endif()
|
||||
@@ -0,0 +1,145 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vanetza/net/chunk_packet.hpp>
|
||||
|
||||
using vanetza::ByteBuffer;
|
||||
using vanetza::ChunkPacket;
|
||||
using vanetza::OsiLayer;
|
||||
|
||||
TEST(ChunkPacket, ctor)
|
||||
{
|
||||
ChunkPacket packet;
|
||||
EXPECT_EQ(0, packet.size());
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, size_from_to)
|
||||
{
|
||||
ChunkPacket packet;
|
||||
packet[OsiLayer::Link] = ByteBuffer(8);
|
||||
packet[OsiLayer::Session] = ByteBuffer(19);
|
||||
packet[OsiLayer::Application] = ByteBuffer(5);
|
||||
|
||||
EXPECT_EQ(8, packet.size(OsiLayer::Link, OsiLayer::Link));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Network, OsiLayer::Transport));
|
||||
EXPECT_EQ(27, packet.size(OsiLayer::Physical, OsiLayer::Session));
|
||||
EXPECT_EQ(24, packet.size(OsiLayer::Session, OsiLayer::Application));
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, access)
|
||||
{
|
||||
const ByteBuffer data { 3, 8, 7, 5, 6 };
|
||||
ChunkPacket packet;
|
||||
packet[OsiLayer::Transport] = ByteBuffer { data };
|
||||
|
||||
EXPECT_EQ(data.size(), packet.size());
|
||||
EXPECT_EQ(data.size(), packet[OsiLayer::Transport].size());
|
||||
|
||||
ByteBuffer tmp;
|
||||
packet[OsiLayer::Transport].convert(tmp);
|
||||
EXPECT_EQ(data, tmp);
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, copy)
|
||||
{
|
||||
ChunkPacket original;
|
||||
original[OsiLayer::Physical] = ByteBuffer(12);
|
||||
original[OsiLayer::Presentation] = ByteBuffer(34);
|
||||
|
||||
ChunkPacket copy { original };
|
||||
EXPECT_EQ(46, copy.size());
|
||||
EXPECT_EQ(12, copy[OsiLayer::Physical].size());
|
||||
EXPECT_EQ(34, copy[OsiLayer::Presentation].size());
|
||||
|
||||
ChunkPacket tmp;
|
||||
tmp = original;
|
||||
EXPECT_EQ(46, tmp.size());
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, self_assignment)
|
||||
{
|
||||
ChunkPacket data;
|
||||
data[OsiLayer::Physical] = ByteBuffer(20);
|
||||
ASSERT_EQ(20, data.size());
|
||||
data = data;
|
||||
EXPECT_EQ(20, data.size());
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, extract)
|
||||
{
|
||||
std::array<ByteBuffer, 5> buffer;
|
||||
for (unsigned i = 0; i < buffer.size(); ++i) {
|
||||
ByteBuffer tmp;
|
||||
tmp.resize(10, static_cast<ByteBuffer::value_type>(i));
|
||||
buffer[i] = std::move(tmp);
|
||||
}
|
||||
|
||||
ChunkPacket a;
|
||||
a[OsiLayer::Link] = ByteBuffer { buffer[0] };
|
||||
a[OsiLayer::Network] = ByteBuffer { buffer[1] };
|
||||
a[OsiLayer::Transport] = ByteBuffer { buffer[2] };
|
||||
a[OsiLayer::Session] = ByteBuffer { buffer[3] };
|
||||
a[OsiLayer::Application] = ByteBuffer { buffer[4] };
|
||||
EXPECT_EQ(50, a.size());
|
||||
|
||||
ChunkPacket b = a.extract(OsiLayer::Network, OsiLayer::Presentation);
|
||||
EXPECT_EQ(20, a.size());
|
||||
EXPECT_EQ(30, b.size());
|
||||
|
||||
ByteBuffer tmp;
|
||||
a[OsiLayer::Link].convert(tmp);
|
||||
EXPECT_EQ(buffer[0], tmp);
|
||||
a[OsiLayer::Application].convert(tmp);
|
||||
EXPECT_EQ(buffer[4], tmp);
|
||||
|
||||
b[OsiLayer::Network].convert(tmp);
|
||||
EXPECT_EQ(buffer[1], tmp);
|
||||
b[OsiLayer::Transport].convert(tmp);
|
||||
EXPECT_EQ(buffer[2], tmp);
|
||||
b[OsiLayer::Session].convert(tmp);
|
||||
EXPECT_EQ(buffer[3], tmp);
|
||||
}
|
||||
|
||||
TEST(ChunkPacket, merge)
|
||||
{
|
||||
std::array<ByteBuffer, 11> buffer;
|
||||
for (unsigned i = 0; i < buffer.size(); ++i) {
|
||||
ByteBuffer tmp;
|
||||
tmp.resize(10, static_cast<ByteBuffer::value_type>(i));
|
||||
buffer[i] = std::move(tmp);
|
||||
}
|
||||
|
||||
ChunkPacket a;
|
||||
a[OsiLayer::Physical] = ByteBuffer { buffer[0] };
|
||||
a[OsiLayer::Link] = ByteBuffer { buffer[1] };
|
||||
a[OsiLayer::Network] = ByteBuffer { buffer[2] };
|
||||
a[OsiLayer::Transport] = ByteBuffer { buffer[3] };
|
||||
a[OsiLayer::Session] = ByteBuffer { buffer[4] };
|
||||
a[OsiLayer::Application] = ByteBuffer { buffer[5] };
|
||||
ASSERT_EQ(60, a.size());
|
||||
|
||||
ChunkPacket b;
|
||||
b[OsiLayer::Physical] = ByteBuffer { buffer[6] };
|
||||
b[OsiLayer::Link] = ByteBuffer { buffer[7] };
|
||||
b[OsiLayer::Network] = ByteBuffer { buffer[8] };
|
||||
b[OsiLayer::Transport] = ByteBuffer { buffer[9] };
|
||||
b[OsiLayer::Application] = ByteBuffer { buffer[10] };
|
||||
ASSERT_EQ(50, b.size());
|
||||
|
||||
a.merge(b, OsiLayer::Link, OsiLayer::Presentation);
|
||||
EXPECT_EQ(50, a.size());
|
||||
|
||||
ByteBuffer tmp;
|
||||
a[OsiLayer::Physical].convert(tmp);
|
||||
EXPECT_EQ(buffer[0], tmp);
|
||||
a[OsiLayer::Link].convert(tmp);
|
||||
EXPECT_EQ(buffer[7], tmp);
|
||||
a[OsiLayer::Network].convert(tmp);
|
||||
EXPECT_EQ(buffer[8], tmp);
|
||||
a[OsiLayer::Transport].convert(tmp);
|
||||
EXPECT_EQ(buffer[9], tmp);
|
||||
a[OsiLayer::Session].convert(tmp);
|
||||
EXPECT_TRUE(tmp.empty());
|
||||
a[OsiLayer::Presentation].convert(tmp);
|
||||
EXPECT_TRUE(tmp.empty());
|
||||
a[OsiLayer::Application].convert(tmp);
|
||||
EXPECT_EQ(buffer[5], tmp);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vanetza/net/cohesive_packet.hpp>
|
||||
#include <vanetza/common/byte_buffer.hpp>
|
||||
|
||||
using vanetza::ByteBuffer;
|
||||
using vanetza::CohesivePacket;
|
||||
using vanetza::OsiLayer;
|
||||
|
||||
TEST(CohesivePacket, ctor_and_size)
|
||||
{
|
||||
const ByteBuffer buffer(892);
|
||||
CohesivePacket packet(buffer, OsiLayer::Transport);
|
||||
|
||||
EXPECT_EQ(892, packet.size());
|
||||
EXPECT_EQ(892, packet.size(OsiLayer::Transport));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Network));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Session));
|
||||
}
|
||||
|
||||
TEST(CohesivePacket, set_boundary)
|
||||
{
|
||||
CohesivePacket packet(ByteBuffer(512), OsiLayer::Link);
|
||||
ASSERT_EQ(512, packet.size(OsiLayer::Link));
|
||||
|
||||
packet.set_boundary(OsiLayer::Link, 64);
|
||||
EXPECT_EQ(64, packet.size(OsiLayer::Link));
|
||||
EXPECT_EQ(512, packet.size());
|
||||
|
||||
ASSERT_EQ(448, packet.size(OsiLayer::Network));
|
||||
packet.set_boundary(OsiLayer::Network, 128);
|
||||
EXPECT_EQ(128, packet.size(OsiLayer::Network));
|
||||
|
||||
ASSERT_EQ(320, packet.size(OsiLayer::Transport));
|
||||
packet.set_boundary(OsiLayer::Transport, 0);
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Transport));
|
||||
EXPECT_EQ(320, packet.size(OsiLayer::Session));
|
||||
EXPECT_EQ(512, packet.size());
|
||||
|
||||
EXPECT_EQ(448, packet.size(OsiLayer::Network, OsiLayer::Application));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Application, OsiLayer::Network));
|
||||
}
|
||||
|
||||
TEST(CohesivePacket, access)
|
||||
{
|
||||
ByteBuffer buffer;
|
||||
for (unsigned i = 0; i < 512; ++i) {
|
||||
buffer.push_back(i);
|
||||
}
|
||||
CohesivePacket packet(buffer, OsiLayer::Network);
|
||||
|
||||
auto net_range = packet[OsiLayer::Network];
|
||||
ASSERT_EQ(512, net_range.size());
|
||||
|
||||
packet.set_boundary(OsiLayer::Network, 128);
|
||||
auto transport_range = packet[OsiLayer::Transport];
|
||||
ASSERT_EQ(384, transport_range.size());
|
||||
|
||||
ByteBuffer::value_type expected_byte = 128;
|
||||
for (auto byte : transport_range) {
|
||||
EXPECT_EQ(expected_byte, byte);
|
||||
++expected_byte;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CohesivePacket, trim_simple_boundaries)
|
||||
{
|
||||
CohesivePacket packet(ByteBuffer(128), OsiLayer::Link);
|
||||
EXPECT_EQ(128, packet.size());
|
||||
packet.trim(OsiLayer::Physical, 100);
|
||||
EXPECT_EQ(100, packet.size());
|
||||
packet.trim(OsiLayer::Physical, 130);
|
||||
EXPECT_EQ(100, packet.size());
|
||||
}
|
||||
|
||||
TEST(CohesivePacket, trim_advanced_boundaries)
|
||||
{
|
||||
CohesivePacket packet(ByteBuffer(128), OsiLayer::Link);
|
||||
packet.set_boundary(OsiLayer::Link, 12);
|
||||
packet.set_boundary(OsiLayer::Network, 0);
|
||||
packet.set_boundary(OsiLayer::Transport, 24);
|
||||
packet.set_boundary(OsiLayer::Session, 48);
|
||||
EXPECT_EQ(128, packet.size(OsiLayer::Link, OsiLayer::Presentation));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Physical));
|
||||
EXPECT_EQ(12, packet.size(OsiLayer::Link));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Network));
|
||||
EXPECT_EQ(24, packet.size(OsiLayer::Transport));
|
||||
EXPECT_EQ(48, packet.size(OsiLayer::Session));
|
||||
EXPECT_EQ(44, packet.size(OsiLayer::Presentation));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Application));
|
||||
|
||||
packet.trim(OsiLayer::Network, 24 + 48 + 20);
|
||||
EXPECT_EQ(24 + 48 + 20, packet.size(OsiLayer::Network, OsiLayer::Application));
|
||||
EXPECT_EQ(104, packet.size());
|
||||
|
||||
packet.trim(OsiLayer::Network, 24 + 8);
|
||||
EXPECT_EQ(44, packet.size());
|
||||
EXPECT_EQ(24, packet.size(OsiLayer::Transport));
|
||||
EXPECT_EQ(8, packet.size(OsiLayer::Session));
|
||||
EXPECT_EQ(0, packet.size(OsiLayer::Presentation, OsiLayer::Application));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vanetza/common/byte_order.hpp>
|
||||
#include <vanetza/net/ethernet_header.hpp>
|
||||
#include <vanetza/net/mac_address.hpp>
|
||||
|
||||
using namespace vanetza;
|
||||
|
||||
TEST(EthernetHeader, create) {
|
||||
MacAddress dest = { 0x12, 0x34, 0x01, 0x47, 0x43, 0x43 };
|
||||
MacAddress src = { 0xfa, 0xbc, 0x8d, 0x43, 0xcb, 0x00 };
|
||||
|
||||
ByteBuffer header = create_ethernet_header(dest, src, host_cast<uint16_t>(0x3773));
|
||||
ByteBuffer expected = { 0x12, 0x34, 0x01, 0x47, 0x43, 0x43, 0xfa, 0xbc, 0x8d, 0x43, 0xcb, 0x00, 0x37, 0x73 };
|
||||
EXPECT_EQ(expected, header);
|
||||
}
|
||||
|
||||
TEST(EthernetHeader, length) {
|
||||
// magic constants are okay in unit tests
|
||||
EXPECT_EQ(14, ethernet_header_length());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vanetza/net/mac_address.hpp>
|
||||
#include <sstream>
|
||||
|
||||
using namespace vanetza;
|
||||
|
||||
TEST(MacAddress, ctor) {
|
||||
MacAddress empty;
|
||||
EXPECT_EQ(empty.octets.size(), 6);
|
||||
for (uint8_t octet : empty.octets) {
|
||||
EXPECT_EQ(octet, 0x00);
|
||||
}
|
||||
|
||||
MacAddress init = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
EXPECT_EQ(init.octets[0], 0x01);
|
||||
EXPECT_EQ(init.octets[1], 0x02);
|
||||
EXPECT_EQ(init.octets[2], 0x03);
|
||||
EXPECT_EQ(init.octets[3], 0x04);
|
||||
EXPECT_EQ(init.octets[4], 0x05);
|
||||
EXPECT_EQ(init.octets[5], 0x06);
|
||||
}
|
||||
|
||||
TEST(MacAddress, equality) {
|
||||
MacAddress a = { 1, 2, 3, 4, 5, 6 };
|
||||
MacAddress b = { 1, 2, 3, 4, 5, 7 };
|
||||
MacAddress c = { 0, 2, 3, 4, 5, 6 };
|
||||
MacAddress d = { 0, 2, 3, 4, 5, 6 };
|
||||
EXPECT_NE(a, b);
|
||||
EXPECT_NE(b, a);
|
||||
EXPECT_NE(a, c);
|
||||
EXPECT_NE(b, c);
|
||||
EXPECT_EQ(a, a);
|
||||
EXPECT_EQ(c, d);
|
||||
}
|
||||
|
||||
TEST(MacAddress, less) {
|
||||
MacAddress a = { 1, 2, 3, 4, 5, 6};
|
||||
MacAddress b = { 1, 2, 4, 4, 5, 6};
|
||||
MacAddress c = { 250, 0, 0, 0, 0, 0};
|
||||
MacAddress d = { 0, 2, 3, 4, 5, 6};
|
||||
MacAddress e = { 1, 2, 3, 4, 5, 5};
|
||||
EXPECT_LT(a, b);
|
||||
EXPECT_LT(a, b);
|
||||
EXPECT_LT(d, e);
|
||||
EXPECT_LT(e, a);
|
||||
EXPECT_LT(c, d);
|
||||
EXPECT_GT(b, a);
|
||||
}
|
||||
|
||||
TEST(MacAddress, ostream) {
|
||||
MacAddress mac = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
std::stringstream sout;
|
||||
sout << mac;
|
||||
EXPECT_EQ(sout.str(), "01:02:03:04:05:06");
|
||||
}
|
||||
|
||||
TEST(MacAddress, parse) {
|
||||
MacAddress result;
|
||||
|
||||
ASSERT_TRUE(!!parse_mac_address("01:02:03:04:05:06", result));
|
||||
EXPECT_EQ(MacAddress({1, 2, 3, 4, 5, 6}), result);
|
||||
EXPECT_TRUE(!!parse_mac_address("01:02:03:04:05:06"));
|
||||
|
||||
EXPECT_FALSE(!!parse_mac_address(":::::0102040506", result));
|
||||
EXPECT_FALSE(!!parse_mac_address("foobarfoobarfoob", result));
|
||||
EXPECT_FALSE(!!parse_mac_address("01:02:03:04:05", result));
|
||||
EXPECT_FALSE(!!parse_mac_address("01:02:03:04:05:06:07", result));
|
||||
}
|
||||
|
||||
TEST(MacAddress, create) {
|
||||
MacAddress a = create_mac_address(static_cast<uint32_t>(0x12345678));
|
||||
EXPECT_EQ(a, MacAddress({0x12, 0x34, 0x56, 0x78, 0x00, 0x00}));
|
||||
|
||||
MacAddress b = create_mac_address(static_cast<uint64_t>(0x1234567890abcdef));
|
||||
EXPECT_EQ(b, MacAddress({0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}));
|
||||
|
||||
MacAddress c = create_mac_address(static_cast<uint32_t>(0x1234));
|
||||
EXPECT_EQ(c, MacAddress({0x00, 0x00, 0x12, 0x34, 0x00, 0x00}));
|
||||
|
||||
MacAddress d = create_mac_address(static_cast<uint16_t>(0x2156));
|
||||
EXPECT_EQ(d, MacAddress({0x21, 0x56, 0x00, 0x00, 0x00, 0x00}));
|
||||
}
|
||||
|
||||
TEST(MacAddress, hash) {
|
||||
std::hash<MacAddress> hash_fn;
|
||||
|
||||
MacAddress a, b;
|
||||
EXPECT_EQ(hash_fn(a), hash_fn(b));
|
||||
|
||||
MacAddress c = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
EXPECT_NE(hash_fn(a), hash_fn(c));
|
||||
|
||||
MacAddress d = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
|
||||
EXPECT_NE(hash_fn(a), hash_fn(d));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <vanetza/net/osi_layer.hpp>
|
||||
|
||||
using namespace vanetza;
|
||||
|
||||
TEST(OsiLayer, ordering) {
|
||||
EXPECT_LT(OsiLayer::Physical, OsiLayer::Link);
|
||||
EXPECT_LT(OsiLayer::Link, OsiLayer::Network);
|
||||
EXPECT_LT(OsiLayer::Network, OsiLayer::Transport);
|
||||
EXPECT_LT(OsiLayer::Transport, OsiLayer::Session);
|
||||
EXPECT_LT(OsiLayer::Session, OsiLayer::Presentation);
|
||||
EXPECT_LT(OsiLayer::Presentation, OsiLayer::Application);
|
||||
|
||||
EXPECT_EQ(min_osi_layer(), OsiLayer::Physical);
|
||||
EXPECT_EQ(max_osi_layer(), OsiLayer::Application);
|
||||
}
|
||||
|
||||
TEST(OsiLayer, comparison) {
|
||||
EXPECT_LT(OsiLayer::Physical, OsiLayer::Link);
|
||||
EXPECT_GT(OsiLayer::Link, OsiLayer::Physical);
|
||||
EXPECT_EQ(OsiLayer::Physical, OsiLayer::Physical);
|
||||
EXPECT_NE(OsiLayer::Physical, OsiLayer::Link);
|
||||
EXPECT_LE(OsiLayer::Physical, OsiLayer::Physical);
|
||||
EXPECT_GE(OsiLayer::Link, OsiLayer::Link);
|
||||
}
|
||||
|
||||
TEST(OsiLayer, list) {
|
||||
auto list = osi_layers;
|
||||
ASSERT_EQ(list.size(), 7);
|
||||
|
||||
auto it = list.begin();
|
||||
EXPECT_EQ(OsiLayer::Physical, *it++);
|
||||
EXPECT_EQ(OsiLayer::Link, *it++);
|
||||
EXPECT_EQ(OsiLayer::Network, *it++);
|
||||
EXPECT_EQ(OsiLayer::Transport, *it++);
|
||||
EXPECT_EQ(OsiLayer::Session, *it++);
|
||||
EXPECT_EQ(OsiLayer::Presentation, *it++);
|
||||
EXPECT_EQ(OsiLayer::Application, *it++);
|
||||
EXPECT_EQ(list.end(), it);
|
||||
|
||||
auto prev = list.begin();
|
||||
for (it = prev + 1; it != list.end(); prev = it, ++it) {
|
||||
EXPECT_LT(*prev, *it);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(OsiLayer, num) {
|
||||
EXPECT_EQ(7, num_osi_layers(min_osi_layer(), max_osi_layer()));
|
||||
EXPECT_EQ(1, num_osi_layers(OsiLayer::Link, OsiLayer::Link));
|
||||
EXPECT_EQ(2, num_osi_layers(OsiLayer::Link, OsiLayer::Network));
|
||||
EXPECT_EQ(0, num_osi_layers(OsiLayer::Network, OsiLayer::Link));
|
||||
}
|
||||
|
||||
TEST(OsiLayer, distance) {
|
||||
EXPECT_EQ(0, distance(OsiLayer::Session, OsiLayer::Session));
|
||||
EXPECT_EQ(1, distance(OsiLayer::Network, OsiLayer::Transport));
|
||||
EXPECT_EQ(-1, distance(OsiLayer::Transport, OsiLayer::Network));
|
||||
EXPECT_EQ(num_osi_layers(min_osi_layer(), max_osi_layer()) - 1,
|
||||
distance(min_osi_layer(), max_osi_layer()));
|
||||
}
|
||||
|
||||
TEST(OsiLayer, compile_time_range) {
|
||||
const auto r1_ref = osi_layers;
|
||||
ASSERT_EQ(7, r1_ref.size());
|
||||
auto r1 = osi_layer_range<min_osi_layer(), max_osi_layer()>();
|
||||
EXPECT_EQ(r1_ref.size(), r1.size());
|
||||
for (unsigned i = 0; i < r1.size(); ++i) {
|
||||
EXPECT_EQ(r1_ref[i], r1[i]);
|
||||
}
|
||||
|
||||
auto r2 = osi_layer_range<OsiLayer::Link, OsiLayer::Transport>();
|
||||
ASSERT_EQ(3, r2.size());
|
||||
EXPECT_EQ(OsiLayer::Link, r2[0]);
|
||||
EXPECT_EQ(OsiLayer::Network, r2[1]);
|
||||
EXPECT_EQ(OsiLayer::Transport, r2[2]);
|
||||
|
||||
auto r3 = osi_layer_range<OsiLayer::Application, OsiLayer::Application>();
|
||||
EXPECT_EQ(1, r3.size());
|
||||
}
|
||||
|
||||
TEST(OsiLayer, run_time_range) {
|
||||
const auto r1_ref = osi_layers;
|
||||
ASSERT_EQ(7, r1_ref.size());
|
||||
auto r1 = osi_layer_range(min_osi_layer(), max_osi_layer());
|
||||
EXPECT_EQ(r1_ref.size(), r1.size());
|
||||
for (unsigned i = 0; i < r1.size(); ++i) {
|
||||
EXPECT_EQ(r1_ref[i], r1[i]);
|
||||
}
|
||||
|
||||
auto r2 = osi_layer_range(OsiLayer::Link, OsiLayer::Transport);
|
||||
ASSERT_EQ(3, r2.size());
|
||||
EXPECT_EQ(OsiLayer::Link, r2[0]);
|
||||
EXPECT_EQ(OsiLayer::Network, r2[1]);
|
||||
EXPECT_EQ(OsiLayer::Transport, r2[2]);
|
||||
|
||||
auto r3 = osi_layer_range(OsiLayer::Application, OsiLayer::Application);
|
||||
ASSERT_EQ(1, r3.size());
|
||||
EXPECT_EQ(OsiLayer::Application, r3[0]);
|
||||
|
||||
auto r4 = osi_layer_range(OsiLayer::Application, OsiLayer::Transport);
|
||||
EXPECT_EQ(0, r4.size());
|
||||
}
|
||||
Reference in New Issue
Block a user