Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_vhw.cpp
blobbb260b1729fcfefe962bd8ceb026fa6f7213e33c
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/vhw.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
8 using namespace marnav;
10 class Test_nmea_vhw : public ::testing::Test
14 TEST_F(Test_nmea_vhw, contruction)
16 EXPECT_NO_THROW(nmea::vhw vhw);
19 TEST_F(Test_nmea_vhw, properties)
21 nmea_sentence_traits<nmea::vhw>();
24 TEST_F(Test_nmea_vhw, parse)
26 auto s = nmea::make_sentence("$IIVHW,,,211.0,M,0.00,N,0.00,K*2D");
27 ASSERT_NE(nullptr, s);
29 auto vhw = nmea::sentence_cast<nmea::vhw>(s);
30 ASSERT_NE(nullptr, vhw);
32 auto heading = vhw->get_heading_magn();
33 EXPECT_TRUE(heading.available());
34 EXPECT_NEAR(211.0, heading.value(), 1e-8);
37 TEST_F(Test_nmea_vhw, parse_invalid_number_of_arguments)
39 EXPECT_ANY_THROW(
40 nmea::detail::factory::sentence_parse<nmea::vhw>(nmea::talker::none, {7, "@"}));
41 EXPECT_ANY_THROW(
42 nmea::detail::factory::sentence_parse<nmea::vhw>(nmea::talker::none, {9, "@"}));
45 TEST_F(Test_nmea_vhw, empty_to_string)
47 nmea::vhw vhw;
49 EXPECT_STREQ("$IIVHW,,,,,,,,*49", nmea::to_string(vhw).c_str());
52 TEST_F(Test_nmea_vhw, set_heading)
54 nmea::vhw vhw;
55 vhw.set_heading_magn(45.8);
57 EXPECT_STREQ("$IIVHW,,,45.8,M,,,,*13", nmea::to_string(vhw).c_str());
60 TEST_F(Test_nmea_vhw, set_speed_knots)
62 nmea::vhw vhw;
63 vhw.set_speed_knots(units::knots{12.5});
65 EXPECT_STREQ("$IIVHW,,,,,12.5,N,,*1F", nmea::to_string(vhw).c_str());
68 TEST_F(Test_nmea_vhw, set_speed_kmh)
70 nmea::vhw vhw;
71 vhw.set_speed_kmh(units::kilometers_per_hour{13.5});
73 EXPECT_STREQ("$IIVHW,,,,,,,13.5,K*1B", nmea::to_string(vhw).c_str());