OpenRTX/tests/unit/M17_callsign.cpp
Ryan Turner e63214e7c0 M17: remove M17 name from namespaced classes
M17 protocol code is already namespaced in M17, so it's redundant to name every class M17*. This change removes the leading M17 from all of the namespaced things.

Co-authored-by: GitHub Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ryan Turner <ryan@turnrye.com>
2026-03-21 10:05:33 +01:00

45 lines
1.2 KiB
C++

/*
* SPDX-FileCopyrightText: Copyright 2020-2026 OpenRTX Contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <catch2/catch_test_macros.hpp>
#include <cstdint>
#include <cstring>
#include <array>
#include <algorithm>
#include "protocols/M17/Callsign.hpp"
#include "protocols/M17/Datatypes.hpp"
using namespace std;
TEST_CASE("Encode callsign AB1CD", "[m17][callsign]")
{
const char callsign[] = "AB1CD";
M17::call_t expected = { 0x00, 0x00, 0x00, 0x9f, 0xdd, 0x51 };
M17::Callsign test = M17::Callsign(callsign);
M17::call_t actual = test;
REQUIRE(equal(begin(actual), end(actual), begin(expected), end(expected)));
}
TEST_CASE("Encode empty callsign", "[m17][callsign]")
{
const char callsign[] = "";
M17::call_t expected = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
M17::Callsign test = M17::Callsign(callsign);
M17::call_t actual = test;
REQUIRE(equal(begin(actual), end(actual), begin(expected), end(expected)));
}
TEST_CASE("Decode callsign AB1CD", "[m17][callsign]")
{
M17::call_t callsign = { 0x00, 0x00, 0x00, 0x9f, 0xdd, 0x51 };
M17::Callsign test = M17::Callsign(callsign);
const char expected[] = "AB1CD";
const char *actual = test;
REQUIRE(strcmp(expected, actual) == 0);
}