2024-05-12 00:45:11 -03:00
|
|
|
// Tests for the GSOF parser.
|
|
|
|
// * ./waf tests
|
|
|
|
// * ./build/sitl/tests/test_gsof
|
|
|
|
|
|
|
|
|
|
|
|
#include <AP_gtest.h>
|
|
|
|
|
|
|
|
#include <AP_GSOF/AP_GSOF.h>
|
|
|
|
|
2024-05-12 00:45:11 -03:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2024-05-12 00:45:11 -03:00
|
|
|
const AP_HAL::HAL &hal = AP_HAL::get_HAL();
|
|
|
|
|
|
|
|
|
|
|
|
TEST(AP_GSOF, incomplete_packet)
|
|
|
|
{
|
|
|
|
AP_GSOF gsof;
|
2024-05-12 00:45:11 -03:00
|
|
|
EXPECT_FALSE(gsof.parse(0, 5));
|
2024-05-12 00:45:11 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AP_GSOF, packet1)
|
|
|
|
{
|
2024-07-30 23:42:26 -03:00
|
|
|
GTEST_SKIP() << "There is not yet a convention for loading in a data file in a cross-platform way in AP for unit tests";
|
2024-05-12 00:45:11 -03:00
|
|
|
FILE* fp = std::fopen("libraries/AP_GSOF/tests/gsof_gps.dat", "rb");
|
|
|
|
EXPECT_NE(fp, nullptr);
|
2024-05-12 00:45:11 -03:00
|
|
|
AP_GSOF gsof;
|
2024-05-12 00:45:11 -03:00
|
|
|
char c = 0;
|
|
|
|
bool parsed = false;
|
|
|
|
while (c != EOF) {
|
|
|
|
c = fgetc (fp);
|
|
|
|
parsed |= gsof.parse((uint8_t)c, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_TRUE(parsed);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
2024-05-12 00:45:11 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
AP_GTEST_MAIN()
|