Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_hdt.cpp
blob6e91008daf272b1c0ff57a28e6a26320000e07b1
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/hdt.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
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)
40 EXPECT_ANY_THROW(
41 nmea::detail::factory::sentence_parse<nmea::hdt>(nmea::talker::none, {1, "@"}));
42 EXPECT_ANY_THROW(
43 nmea::detail::factory::sentence_parse<nmea::hdt>(nmea::talker::none, {3, "@"}));
46 TEST_F(Test_nmea_hdt, empty_to_string)
48 nmea::hdt hdt;
50 EXPECT_STREQ("$IIHDT,,*58", nmea::to_string(hdt).c_str());
53 TEST_F(Test_nmea_hdt, set_heading)
55 nmea::hdt hdt;
56 hdt.set_heading(45.8);
58 EXPECT_STREQ("$IIHDT,45.8,T*1B", nmea::to_string(hdt).c_str());