Files
SSR/test/test_allcall.h
T
2026-06-16 11:04:03 +08:00

59 lines
1.8 KiB
C++

#ifdef _USE_GTEST
#ifndef TEST_ALLCALL_H
#define TEST_ALLCALL_H
#include "global.h"
using namespace All_Call_Reply;
TEST(AllCallTest, Icao) {
// 测试 allcall::icao 函数
EXPECT_EQ(decode_icao(hex2bin("5D484FDEA248F5")), "484FDE");
}
TEST(AllCallTest, Interrogator) {
// 测试 allcall::interrogator 函数
EXPECT_EQ(interrogator_allCall(hex2bin("5D484FDEA248F5")), "SI6");
}
TEST(AllCallTest, create) {
// 测试 allcall::capability 函数,检查第一个值是否为 5
// int ca = std::get<0>(*capability_allCall(hex2bin("5D484FDEA248F5")));
// EXPECT_EQ(ca, 5);
// auto r = All_Call_Reply::All_Call_Reply_BDS::Builder("484FDE")
// .set_interrogator_identifier(22)
// .build();
//
// std::cout << r.interrogator_identifier() << std::endl;
// //std::cout << tell(r.msg) << std::endl;
// std::cout << "crc msg == " << crc(r.msg) << std::endl;
//std::cout << icao(r.msg) << std::endl;
std::string msg = hex2bin("5D484FDEA248F5");
//std::cout << crc(msg) << std::endl;
auto last_24 = msg.substr(56-24);
auto crc_24 = std::bitset<24>(crc(msg, true)).to_string();
auto icao = ::decode_icao(msg);
icao.resize(6, '0');
auto icao_24 = hex2bin(icao);
// 22 = 16 + 4 + 2
std::string id = "000000000000000000010110";
// 101000100100100011110101
// 101000100100100011110101
// std::cout << "icao === " << bin2hex(xorBin(crc_24, id)) << std::endl;
// std::cout << "icao === " << xorBin(crc_24, id) << std::endl;
//std::cout << "icao == " << icao;
// std::cout << "interrogator == " << interrogator_allCall(r.msg).value();
//std::cout << interrogator_allCall(r.msg).value() << std::endl;
// auto t = Comm_B::ELS::Altitude_Data_Link_Capability_Report_BDS_1_0::Builder("ASD").build();
// std::cout << t.msg;
}
#endif
#endif