1 #include <gtest/gtest.h>
2 #include <marnav/nmea/rpm.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_rpm
: public ::testing::Test
15 TEST_F(Test_nmea_rpm
, contruction
)
17 EXPECT_NO_THROW(nmea::rpm rpm
);
20 TEST_F(Test_nmea_rpm
, properties
)
22 nmea_sentence_traits
<nmea::rpm
>();
25 TEST_F(Test_nmea_rpm
, parse
)
27 auto s
= nmea::make_sentence("$IIRPM,S,1,1800.0,5.0,A*7C");
28 ASSERT_NE(nullptr, s
);
30 auto rpm
= nmea::sentence_cast
<nmea::rpm
>(s
);
31 ASSERT_NE(nullptr, rpm
);
34 TEST_F(Test_nmea_rpm
, parse_invalid_number_of_arguments
)
37 nmea::detail::factory::sentence_parse
<nmea::rpm
>(nmea::talker_id::none
, {4, "@"}));
39 nmea::detail::factory::sentence_parse
<nmea::rpm
>(nmea::talker_id::none
, {6, "@"}));
42 TEST_F(Test_nmea_rpm
, empty_to_string
)
46 EXPECT_STREQ("$IIRPM,,,,,*63", nmea::to_string(rpm
).c_str());
49 TEST_F(Test_nmea_rpm
, set_source
)
52 rpm
.set_source(nmea::rpm::source_id::shaft
, 1);
54 EXPECT_STREQ("$IIRPM,S,1,,,*01", nmea::to_string(rpm
).c_str());
57 TEST_F(Test_nmea_rpm
, set_revolutions
)
60 rpm
.set_revolutions(1800.0);
62 EXPECT_STREQ("$IIRPM,,,1800.0,,*74", nmea::to_string(rpm
).c_str());
65 TEST_F(Test_nmea_rpm
, set_propeller_pitch_positive
)
68 rpm
.set_propeller_pitch(10.0);
70 EXPECT_STREQ("$IIRPM,,,,10.0,*7C", nmea::to_string(rpm
).c_str());
73 TEST_F(Test_nmea_rpm
, set_propeller_pitch_negative
)
76 rpm
.set_propeller_pitch(-10.0);
78 EXPECT_STREQ("$IIRPM,,,,-10.0,*51", nmea::to_string(rpm
).c_str());
81 TEST_F(Test_nmea_rpm
, set_data_valid
)
84 rpm
.set_data_valid(nmea::status::ok
);
86 EXPECT_STREQ("$IIRPM,,,,,A*22", nmea::to_string(rpm
).c_str());