Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / test / marnav / nmea / Test_nmea_r00.cpp
blob9ce6420fb7e8a8481448d2fa72d687bea98b293c
1 #include <marnav/nmea/r00.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
6 namespace
8 using namespace marnav;
10 class test_nmea_r00 : public ::testing::Test
14 TEST_F(test_nmea_r00, contruction)
16 EXPECT_NO_THROW(nmea::r00 r00);
19 TEST_F(test_nmea_r00, properties)
21 nmea_sentence_traits<nmea::r00>();
24 TEST_F(test_nmea_r00, parse)
26 auto s = nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
27 ASSERT_NE(nullptr, s);
29 auto r00 = nmea::sentence_cast<nmea::r00>(s);
30 ASSERT_NE(nullptr, r00);
33 TEST_F(test_nmea_r00, parse_invalid_number_of_arguments)
35 EXPECT_ANY_THROW(
36 nmea::detail::factory::sentence_parse<nmea::r00>(nmea::talker::none, {13, "@"}));
37 EXPECT_ANY_THROW(
38 nmea::detail::factory::sentence_parse<nmea::r00>(nmea::talker::none, {15, "@"}));
41 TEST_F(test_nmea_r00, empty_to_string)
43 nmea::r00 r00;
45 EXPECT_STREQ("$GPR00,,,,,,,,,,,,,,*45", nmea::to_string(r00).c_str());
48 TEST_F(test_nmea_r00, set_id_invalid_index)
50 nmea::r00 r00;
52 EXPECT_ANY_THROW(r00.set_waypoint_id(-1, nmea::waypoint{"ABC"}));
53 EXPECT_ANY_THROW(r00.set_waypoint_id(15, nmea::waypoint{"ABC"}));
56 TEST_F(test_nmea_r00, set_id)
58 nmea::r00 r00;
60 r00.set_waypoint_id(0, nmea::waypoint{"ABC"});
61 EXPECT_STREQ("$GPR00,ABC,,,,,,,,,,,,,*05", nmea::to_string(r00).c_str());
64 TEST_F(test_nmea_r00, get_id)
66 auto s = nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
67 ASSERT_NE(nullptr, s);
69 auto r00 = nmea::sentence_cast<nmea::r00>(s);
70 ASSERT_NE(nullptr, r00);
73 auto wp = *r00->get_waypoint_id(0);
74 EXPECT_STREQ("EGLL", wp.c_str());
77 auto wp = *r00->get_waypoint_id(1);
78 EXPECT_STREQ("EGLM", wp.c_str());
81 auto wp = *r00->get_waypoint_id(2);
82 EXPECT_STREQ("EGTB", wp.c_str());
86 TEST_F(test_nmea_r00, found_on_internet)
89 auto s = nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
90 EXPECT_NE(nullptr, s);
93 auto s = nmea::make_sentence(
94 "$GPR00,MINST,CHATN,CHAT1,CHATW,CHATM,CHATE,003,004,005,006,007,,,*05");
95 EXPECT_NE(nullptr, s);