Files
SSR/test/test_bds_inference.h
T
2026-06-26 17:56:28 +08:00

69 lines
2.5 KiB
C++

#ifdef _USE_GTEST
#ifndef TEST_BDS_INFERENCE_H
#define TEST_BDS_INFERENCE_H
#include "global.h"
class BdsTest : public ::testing::Test {
protected:
void SetUp() override {
// Any necessary setup can go here
}
};
TEST_F(BdsTest, TestBdsInfer) {
EXPECT_EQ(infer(hex2bin("8D406B902015A678D4D220AA4BDA")), "BDS08");
EXPECT_EQ(infer(hex2bin("8FC8200A3AB8F5F893096B000000")), "BDS06");
EXPECT_EQ(infer(hex2bin("8D40058B58C901375147EFD09357")), "BDS05");
EXPECT_EQ(infer(hex2bin("8D485020994409940838175B284F")), "BDS09");
EXPECT_EQ(infer(hex2bin("A800178D10010080F50000D5893C")), "BDS10");
EXPECT_EQ(infer(hex2bin("A0000638FA81C10000000081A92F")), "BDS17");
EXPECT_EQ(infer(hex2bin("A0001838201584F23468207CDFA5")), "BDS20");
EXPECT_EQ(infer(hex2bin("A0001839CA3800315800007448D9")), "BDS40");
EXPECT_EQ(infer(hex2bin("A000139381951536E024D4CCF6B5")), "BDS50");
EXPECT_EQ(infer(hex2bin("A00004128F39F91A7E27C46ADC21")), "BDS60");
// std::cout << infer("A0001838201584F23468207CDFA5").value();
}
TEST_F(BdsTest, Infer2LargeBds17ReservedBitsDoesNotThrow) {
std::string msg = "10100000000000000000000000000000";
msg += "00010000000000110000101010000000111101010000000000000000";
msg += "000000000000000000000000";
EXPECT_NO_THROW(infer2(msg, true));
EXPECT_NO_THROW(infer2("1010000000000000000011110011100100010000000000110000101010000000111101010000000000000000001110000101001101010111", true));
}
TEST_F(BdsTest, TestBdsIs50Or60) {
auto result = is50or60(hex2bin("A0001838201584F23468207CDFA5"), 0, 0, 0);
EXPECT_EQ(result, ""); // Check if the optional is empty
EXPECT_EQ(is50or60(hex2bin("A8001EBCFFFB23286004A73F6A5B"), 320, 250, 14000), "BDS50");
EXPECT_EQ(is50or60(hex2bin("A8001EBCFE1B29287FDCA807BCFC"), 320, 250, 14000), "BDS50");
}
TEST_F(BdsTest, TestSurfacePosition) {
std::string msg0 = hex2bin("8FE48C033A9FA184B934E744C6FD");
std::string msg1 = hex2bin("8FE48C033A9FA68F7C3D39B1C2F0");
unsigned long long t0 = 1565608663102;
unsigned long long t1 = 1565608666214;
float lat_ref = -23.4265448;
float lon_ref = -46.4816258;
CPR::Position pos_ref(lat_ref, lon_ref);
// auto pos2 = CPR::surface_position(msg0, msg1, t0, t0, pos_ref).value();
auto pos = CPR::surface_position_with_ref(msg0, lat_ref, lon_ref, t0, t0).value();
// 为什么差那么 多
//std::cout << lat << " " << lon << std::endl;
EXPECT_LT(std::abs(lon_ref - pos.lon), 0.05);
}
#endif
#endif