1 #include <marnav/nmea/r00.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
9 using namespace marnav
;
11 class Test_nmea_r00
: public ::testing::Test
15 TEST_F(Test_nmea_r00
, contruction
)
17 EXPECT_NO_THROW(nmea::r00 r00
);
20 TEST_F(Test_nmea_r00
, properties
)
22 nmea_sentence_traits
<nmea::r00
>();
25 TEST_F(Test_nmea_r00
, parse
)
27 auto s
= nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
28 ASSERT_NE(nullptr, s
);
30 auto r00
= nmea::sentence_cast
<nmea::r00
>(s
);
31 ASSERT_NE(nullptr, r00
);
34 TEST_F(Test_nmea_r00
, parse_invalid_number_of_arguments
)
37 nmea::detail::factory::sentence_parse
<nmea::r00
>(nmea::talker::none
, {13, "@"}));
39 nmea::detail::factory::sentence_parse
<nmea::r00
>(nmea::talker::none
, {15, "@"}));
42 TEST_F(Test_nmea_r00
, empty_to_string
)
46 EXPECT_STREQ("$GPR00,,,,,,,,,,,,,,*45", nmea::to_string(r00
).c_str());
49 TEST_F(Test_nmea_r00
, set_id_invalid_index
)
53 EXPECT_ANY_THROW(r00
.set_waypoint_id(-1, nmea::waypoint
{"ABC"}));
54 EXPECT_ANY_THROW(r00
.set_waypoint_id(15, nmea::waypoint
{"ABC"}));
57 TEST_F(Test_nmea_r00
, set_id
)
61 r00
.set_waypoint_id(0, nmea::waypoint
{"ABC"});
62 EXPECT_STREQ("$GPR00,ABC,,,,,,,,,,,,,*05", nmea::to_string(r00
).c_str());
65 TEST_F(Test_nmea_r00
, get_id
)
67 auto s
= nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
68 ASSERT_NE(nullptr, s
);
70 auto r00
= nmea::sentence_cast
<nmea::r00
>(s
);
71 ASSERT_NE(nullptr, r00
);
74 auto wp
= *r00
->get_waypoint_id(0);
75 EXPECT_STREQ("EGLL", wp
.c_str());
78 auto wp
= *r00
->get_waypoint_id(1);
79 EXPECT_STREQ("EGLM", wp
.c_str());
82 auto wp
= *r00
->get_waypoint_id(2);
83 EXPECT_STREQ("EGTB", wp
.c_str());
87 TEST_F(Test_nmea_r00
, found_on_internet
)
90 auto s
= nmea::make_sentence("$GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58");
91 EXPECT_NE(nullptr, s
);
94 auto s
= nmea::make_sentence(
95 "$GPR00,MINST,CHATN,CHAT1,CHATW,CHATM,CHATE,003,004,005,006,007,,,*05");
96 EXPECT_NE(nullptr, s
);