1 #include <marnav/nmea/vwe.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
8 using namespace marnav
;
10 class Test_nmea_vwe
: public ::testing::Test
14 TEST_F(Test_nmea_vwe
, contruction
)
16 EXPECT_NO_THROW(nmea::vwe vwe
);
19 TEST_F(Test_nmea_vwe
, properties
)
21 nmea_sentence_traits
<nmea::vwe
>();
24 TEST_F(Test_nmea_vwe
, parse
)
26 auto s
= nmea::make_sentence("$IIVWE,50.0*73");
27 ASSERT_NE(nullptr, s
);
29 auto vwe
= nmea::sentence_cast
<nmea::vwe
>(s
);
30 ASSERT_NE(nullptr, vwe
);
32 EXPECT_NEAR(50.0, vwe
->get_efficiency(), 1e-8);
35 TEST_F(Test_nmea_vwe
, parse_invalid_number_of_arguments
)
38 nmea::detail::factory::sentence_parse
<nmea::vwe
>(nmea::talker::none
, {2, "@"}));
41 TEST_F(Test_nmea_vwe
, empty_to_string
)
45 EXPECT_STREQ("$IIVWE,0.0*46", nmea::to_string(vwe
).c_str());
48 TEST_F(Test_nmea_vwe
, set_efficiency
)
52 vwe
.set_efficiency(10.0);
53 EXPECT_STREQ("$IIVWE,10.0*77", nmea::to_string(vwe
).c_str());
57 vwe
.set_efficiency(25.1);
58 EXPECT_STREQ("$IIVWE,25.1*70", nmea::to_string(vwe
).c_str());
62 vwe
.set_efficiency(100.0);
63 EXPECT_STREQ("$IIVWE,100.0*47", nmea::to_string(vwe
).c_str());
67 TEST_F(Test_nmea_vwe
, set_efficiency_invalid
)
70 EXPECT_ANY_THROW(vwe
.set_efficiency(-1.0));
71 EXPECT_ANY_THROW(vwe
.set_efficiency(100.1));
74 TEST_F(Test_nmea_vwe
, get_efficiency
)
77 const auto vwe
= nmea::create_sentence
<nmea::vwe
>("$IIVWE,12.7*72");
78 EXPECT_NEAR(12.7, vwe
.get_efficiency(), 1e-8);
81 const auto vwe
= nmea::create_sentence
<nmea::vwe
>("$IIVWE,0.0*46");
82 EXPECT_NEAR(0.0, vwe
.get_efficiency(), 1e-8);
85 const auto vwe
= nmea::create_sentence
<nmea::vwe
>("$IIVWE,100.0*47");
86 EXPECT_NEAR(100.0, vwe
.get_efficiency(), 1e-8);