1 #include <marnav/nmea/apa.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
8 using namespace marnav
;
10 class Test_nmea_apa
: public ::testing::Test
14 TEST_F(Test_nmea_apa
, contruction
)
16 EXPECT_NO_THROW(nmea::apa apa
);
19 TEST_F(Test_nmea_apa
, properties
)
21 nmea_sentence_traits
<nmea::apa
>();
24 TEST_F(Test_nmea_apa
, parse
)
26 auto s
= nmea::make_sentence("$GPAPA,A,A,0.10,R,N,V,V,011,M,DEST*3F");
27 ASSERT_NE(nullptr, s
);
29 auto apa
= nmea::sentence_cast
<nmea::apa
>(s
);
30 ASSERT_NE(nullptr, apa
);
33 TEST_F(Test_nmea_apa
, parse_invalid_number_of_arguments
)
36 nmea::detail::factory::sentence_parse
<nmea::apa
>(nmea::talker::none
, {9, "@"}));
38 nmea::detail::factory::sentence_parse
<nmea::apa
>(nmea::talker::none
, {11, "@"}));
41 TEST_F(Test_nmea_apa
, empty_to_string
)
45 EXPECT_STREQ("$GPAPA,,,,,,,,,,*47", nmea::to_string(apa
).c_str());
48 TEST_F(Test_nmea_apa
, set_waypoint
)
51 apa
.set_waypoint_id(nmea::waypoint
{"ABC"});
53 EXPECT_STREQ("$GPAPA,,,,,,,,,,ABC*07", nmea::to_string(apa
).c_str());
56 TEST_F(Test_nmea_apa
, set_bearing_origin_to_destination
)
59 apa
.set_bearing_origin_to_destination(11, nmea::reference::MAGNETIC
);
60 EXPECT_STREQ("$GPAPA,,,,,,,,11.0,M,*14", nmea::to_string(apa
).c_str());
63 TEST_F(Test_nmea_apa
, get_bearing_origin_to_destination
)
65 auto s
= nmea::make_sentence("$GPAPA,A,A,0.10,R,N,V,V,011,M,DEST*3F");
66 ASSERT_NE(nullptr, s
);
68 auto apa
= nmea::sentence_cast
<nmea::apa
>(s
);
69 ASSERT_NE(nullptr, apa
);
71 EXPECT_NEAR(11.0, *apa
->get_bearing_origin_to_destination(), 1.0e-4);
72 EXPECT_EQ(nmea::reference::MAGNETIC
, *apa
->get_bearing_origin_to_destination_ref());