1 #include <gtest/gtest.h>
2 #include <marnav/nmea/vwr.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_vwr
: public ::testing::Test
15 TEST_F(Test_nmea_vwr
, contruction
)
17 EXPECT_NO_THROW(nmea::vwr vwr
);
20 TEST_F(Test_nmea_vwr
, properties
)
22 nmea_sentence_traits
<nmea::vwr
>();
25 TEST_F(Test_nmea_vwr
, parse
)
27 auto s
= nmea::make_sentence("$IIVWR,084.0,R,10.4,N,5.4,M,19.3,K*4A");
28 ASSERT_NE(nullptr, s
);
30 auto vwr
= nmea::sentence_cast
<nmea::vwr
>(s
);
31 ASSERT_NE(nullptr, vwr
);
33 auto angle
= vwr
->get_angle();
34 EXPECT_TRUE(angle
.available());
35 EXPECT_NEAR(84.0, angle
.value(), 1e-8);
37 auto side
= vwr
->get_angle_side();
38 EXPECT_TRUE(side
.available());
39 EXPECT_EQ(nmea::side::right
, side
.value());
42 TEST_F(Test_nmea_vwr
, parse_invalid_number_of_arguments
)
45 nmea::detail::factory::sentence_parse
<nmea::vwr
>(nmea::talker_id::none
, {7, "@"}));
47 nmea::detail::factory::sentence_parse
<nmea::vwr
>(nmea::talker_id::none
, {9, "@"}));
50 TEST_F(Test_nmea_vwr
, empty_to_string
)
54 EXPECT_STREQ("$IIVWR,,,,,,,,*53", nmea::to_string(vwr
).c_str());
57 TEST_F(Test_nmea_vwr
, set_angle_left
)
60 vwr
.set_angle(22.5, nmea::side::left
);
62 EXPECT_STREQ("$IIVWR,22.5,L,,,,,,*04", nmea::to_string(vwr
).c_str());
65 TEST_F(Test_nmea_vwr
, set_angle_right
)
68 vwr
.set_angle(22.5, nmea::side::right
);
70 EXPECT_STREQ("$IIVWR,22.5,R,,,,,,*1A", nmea::to_string(vwr
).c_str());
73 TEST_F(Test_nmea_vwr
, set_speed_knots
)
76 vwr
.set_speed_knots(12.5);
78 EXPECT_STREQ("$IIVWR,,,12.5,N,,,,*05", nmea::to_string(vwr
).c_str());
81 TEST_F(Test_nmea_vwr
, set_speed_mps
)
84 vwr
.set_speed_mps(2.5);
86 EXPECT_STREQ("$IIVWR,,,,,2.5,M,,*37", nmea::to_string(vwr
).c_str());
89 TEST_F(Test_nmea_vwr
, set_speed_kmh
)
92 vwr
.set_speed_kmh(13.5);
94 EXPECT_STREQ("$IIVWR,,,,,,,13.5,K*01", nmea::to_string(vwr
).c_str());