1 #include <gtest/gtest.h>
2 #include <marnav/nmea/hdt.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_hdt
: public ::testing::Test
15 TEST_F(Test_nmea_hdt
, contruction
)
17 EXPECT_NO_THROW(nmea::hdt hdt
);
20 TEST_F(Test_nmea_hdt
, properties
)
22 nmea_sentence_traits
<nmea::hdt
>();
25 TEST_F(Test_nmea_hdt
, parse
)
27 auto s
= nmea::make_sentence("$IIHDT,45.8,T*1B");
28 ASSERT_NE(nullptr, s
);
30 auto hdt
= nmea::sentence_cast
<nmea::hdt
>(s
);
31 ASSERT_NE(nullptr, hdt
);
33 auto heading
= hdt
->get_heading();
34 EXPECT_TRUE(heading
.available());
35 EXPECT_NEAR(45.8, heading
.value(), 1e-8);
38 TEST_F(Test_nmea_hdt
, parse_invalid_number_of_arguments
)
41 nmea::detail::factory::sentence_parse
<nmea::hdt
>(nmea::talker::none
, {1, "@"}));
43 nmea::detail::factory::sentence_parse
<nmea::hdt
>(nmea::talker::none
, {3, "@"}));
46 TEST_F(Test_nmea_hdt
, empty_to_string
)
50 EXPECT_STREQ("$IIHDT,,*58", nmea::to_string(hdt
).c_str());
53 TEST_F(Test_nmea_hdt
, set_heading
)
56 hdt
.set_heading(45.8);
58 EXPECT_STREQ("$IIHDT,45.8,T*1B", nmea::to_string(hdt
).c_str());