1 #include <gtest/gtest.h>
2 #include <marnav/nmea/vtg.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_vtg
: public ::testing::Test
15 TEST_F(Test_nmea_vtg
, contruction
)
17 EXPECT_NO_THROW(nmea::vtg vtg
);
20 TEST_F(Test_nmea_vtg
, properties
)
22 nmea_sentence_traits
<nmea::vtg
>();
25 TEST_F(Test_nmea_vtg
, parse
)
27 auto s
= nmea::make_sentence("$GPVTG,,T,,M,,N,,K,N*2C");
28 ASSERT_NE(nullptr, s
);
30 auto vtg
= nmea::sentence_cast
<nmea::vtg
>(s
);
31 ASSERT_NE(nullptr, vtg
);
34 TEST_F(Test_nmea_vtg
, parse_invalid_number_of_arguments
)
37 nmea::detail::factory::sentence_parse
<nmea::vtg
>(nmea::talker::none
, {7, "@"}));
39 nmea::detail::factory::sentence_parse
<nmea::vtg
>(nmea::talker::none
, {10, "@"}));
42 TEST_F(Test_nmea_vtg
, empty_to_string
)
46 EXPECT_STREQ("$GPVTG,,,,,,,,,*7E", nmea::to_string(vtg
).c_str());
49 TEST_F(Test_nmea_vtg
, set_speed_kn
)
52 vtg
.set_speed_kn(units::knots
{12.5});
54 EXPECT_STREQ("$GPVTG,,,,,12.5,N,,,*28", nmea::to_string(vtg
).c_str());
57 TEST_F(Test_nmea_vtg
, set_speed_kmh
)
60 vtg
.set_speed_kmh(units::kilometers_per_hour
{22.5});
62 EXPECT_STREQ("$GPVTG,,,,,,,22.5,K,*2E", nmea::to_string(vtg
).c_str());
65 TEST_F(Test_nmea_vtg
, set_track_magn
)
68 vtg
.set_track_magn(12.5);
70 EXPECT_STREQ("$GPVTG,,,12.5,M,,,,,*2B", nmea::to_string(vtg
).c_str());
73 TEST_F(Test_nmea_vtg
, set_track_true
)
76 vtg
.set_track_true(12.5);
78 EXPECT_STREQ("$GPVTG,12.5,T,,,,,,,*32", nmea::to_string(vtg
).c_str());