1 #include <gtest/gtest.h>
2 #include <marnav/nmea/mtw.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_mtw
: public ::testing::Test
15 TEST_F(Test_nmea_mtw
, contruction
)
17 EXPECT_NO_THROW(nmea::mtw mtw
);
20 TEST_F(Test_nmea_mtw
, properties
)
22 nmea_sentence_traits
<nmea::mtw
>();
25 TEST_F(Test_nmea_mtw
, parse
)
27 auto s
= nmea::make_sentence("$IIMTW,9.5,C*2F");
28 ASSERT_NE(nullptr, s
);
30 auto mtw
= nmea::sentence_cast
<nmea::mtw
>(s
);
31 ASSERT_NE(nullptr, mtw
);
33 auto temperature
= mtw
->get_temperature();
34 ASSERT_TRUE(temperature
.available());
35 EXPECT_NEAR(9.5, temperature
.value(), 1e-8);
37 auto unit
= mtw
->get_temperature_unit();
38 ASSERT_TRUE(unit
.available());
39 EXPECT_EQ(nmea::unit::temperature::celsius
, unit
.value());
42 TEST_F(Test_nmea_mtw
, parse_invalid_number_of_arguments
)
45 nmea::detail::factory::sentence_parse
<nmea::mtw
>(nmea::talker_id::none
, {1, "@"}));
47 nmea::detail::factory::sentence_parse
<nmea::mtw
>(nmea::talker_id::none
, {3, "@"}));
50 TEST_F(Test_nmea_mtw
, empty_to_string
)
54 EXPECT_STREQ("$IIMTW,,*4E", nmea::to_string(mtw
).c_str());
57 TEST_F(Test_nmea_mtw
, set_temperature_to_string
)
60 mtw
.set_temperature(22.5);
62 EXPECT_STREQ("$IIMTW,22.5,C*16", nmea::to_string(mtw
).c_str());