1 #include <gtest/gtest.h>
2 #include <marnav/nmea/mwv.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_mwv
: public ::testing::Test
15 TEST_F(Test_nmea_mwv
, contruction
)
17 EXPECT_NO_THROW(nmea::mwv mwv
);
20 TEST_F(Test_nmea_mwv
, properties
)
22 nmea_sentence_traits
<nmea::mwv
>();
25 TEST_F(Test_nmea_mwv
, parse
)
27 auto s
= nmea::make_sentence("$IIMWV,084.0,R,10.4,N,A*04");
28 ASSERT_NE(nullptr, s
);
30 auto mwv
= nmea::sentence_cast
<nmea::mwv
>(s
);
31 ASSERT_NE(nullptr, mwv
);
33 auto angle
= mwv
->get_angle();
34 ASSERT_TRUE(angle
.available());
35 EXPECT_NEAR(84.0, angle
.value(), 1e-8);
37 auto speed
= mwv
->get_speed();
38 ASSERT_TRUE(speed
.available());
39 EXPECT_NEAR(10.4, speed
.value(), 1e-8);
42 TEST_F(Test_nmea_mwv
, parse_invalid_number_of_arguments
)
45 nmea::detail::factory::sentence_parse
<nmea::mwv
>(nmea::talker_id::none
, {4, "@"}));
47 nmea::detail::factory::sentence_parse
<nmea::mwv
>(nmea::talker_id::none
, {6, "@"}));
50 TEST_F(Test_nmea_mwv
, empty_to_string
)
54 EXPECT_STREQ("$IIMWV,,,,,*60", nmea::to_string(mwv
).c_str());
57 TEST_F(Test_nmea_mwv
, set_angle
)
60 mwv
.set_angle(12.5, nmea::reference::RELATIVE
);
62 EXPECT_STREQ("$IIMWV,12.5,R,,,*2A", nmea::to_string(mwv
).c_str());
65 TEST_F(Test_nmea_mwv
, set_speed
)
68 mwv
.set_speed(22.5, nmea::unit::velocity::knot
);
70 EXPECT_STREQ("$IIMWV,,,22.5,N,*35", nmea::to_string(mwv
).c_str());