NMEA: serialization of sentences changed, gains performance by about 7 percent on...
[marnav.git] / test / nmea / Test_nmea_rpm.cpp
blobf0d77c4aa2c8c15bb6f35adadaa5bfb8ec464a23
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/rpm.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
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)
36 EXPECT_ANY_THROW(
37 nmea::detail::factory::sentence_parse<nmea::rpm>(nmea::talker_id::none, {4, "@"}));
38 EXPECT_ANY_THROW(
39 nmea::detail::factory::sentence_parse<nmea::rpm>(nmea::talker_id::none, {6, "@"}));
42 TEST_F(Test_nmea_rpm, empty_to_string)
44 nmea::rpm rpm;
46 EXPECT_STREQ("$IIRPM,,,,,*63", nmea::to_string(rpm).c_str());
49 TEST_F(Test_nmea_rpm, set_source)
51 nmea::rpm rpm;
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)
59 nmea::rpm rpm;
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)
67 nmea::rpm rpm;
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)
75 nmea::rpm rpm;
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)
83 nmea::rpm rpm;
84 rpm.set_data_valid(nmea::status::ok);
86 EXPECT_STREQ("$IIRPM,,,,,A*22", nmea::to_string(rpm).c_str());