CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADSB/tests/test_adsb_callsign.cpp
Views: 1799
1
#include <AP_gtest.h>
2
3
#include <AP_ADSB/AP_ADSB.h>
4
5
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
6
7
TEST(IsValidCallsign, Valid)
8
{
9
EXPECT_TRUE(AP_ADSB::is_valid_callsign(7777));
10
EXPECT_TRUE(AP_ADSB::is_valid_callsign(777));
11
EXPECT_TRUE(AP_ADSB::is_valid_callsign(77));
12
EXPECT_TRUE(AP_ADSB::is_valid_callsign(7));
13
EXPECT_TRUE(AP_ADSB::is_valid_callsign(0));
14
EXPECT_TRUE(AP_ADSB::is_valid_callsign(1111));
15
EXPECT_TRUE(AP_ADSB::is_valid_callsign(111));
16
EXPECT_TRUE(AP_ADSB::is_valid_callsign(11));
17
EXPECT_TRUE(AP_ADSB::is_valid_callsign(1));
18
EXPECT_TRUE(AP_ADSB::is_valid_callsign(0));
19
EXPECT_TRUE(AP_ADSB::is_valid_callsign(7654));
20
EXPECT_TRUE(AP_ADSB::is_valid_callsign(321));
21
EXPECT_TRUE(AP_ADSB::is_valid_callsign(23));
22
EXPECT_TRUE(AP_ADSB::is_valid_callsign(5));
23
EXPECT_TRUE(AP_ADSB::is_valid_callsign(5));
24
}
25
26
TEST(IsValidCallsign, Invalid)
27
{
28
EXPECT_FALSE(AP_ADSB::is_valid_callsign(17777));
29
EXPECT_FALSE(AP_ADSB::is_valid_callsign(8888));
30
EXPECT_FALSE(AP_ADSB::is_valid_callsign(888));
31
EXPECT_FALSE(AP_ADSB::is_valid_callsign(88));
32
EXPECT_FALSE(AP_ADSB::is_valid_callsign(8));
33
EXPECT_FALSE(AP_ADSB::is_valid_callsign(9));
34
35
EXPECT_FALSE(AP_ADSB::is_valid_callsign(7778));
36
EXPECT_FALSE(AP_ADSB::is_valid_callsign(7788));
37
EXPECT_FALSE(AP_ADSB::is_valid_callsign(7888));
38
EXPECT_FALSE(AP_ADSB::is_valid_callsign(8888));
39
}
40
41
AP_GTEST_MAIN()
42
43
#pragma GCC diagnostic pop
44
45