1 #include <gtest/gtest.h>
2 #include <marnav/nmea/dpt.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_dpt
: public ::testing::Test
15 TEST_F(Test_nmea_dpt
, contruction
)
17 EXPECT_NO_THROW(nmea::dpt dpt
);
20 TEST_F(Test_nmea_dpt
, properties
)
22 nmea_sentence_traits
<nmea::dpt
>();
25 TEST_F(Test_nmea_dpt
, parse_two_fields
)
27 auto s
= nmea::make_sentence("$IIDPT,9.3,1.0*4B");
28 ASSERT_NE(nullptr, s
);
30 auto dpt
= nmea::sentence_cast
<nmea::dpt
>(s
);
31 ASSERT_NE(nullptr, dpt
);
34 TEST_F(Test_nmea_dpt
, parse_three_fields
)
36 auto s
= nmea::make_sentence("$IIDPT,9.3,1.0,1.0*48");
37 ASSERT_NE(nullptr, s
);
39 auto dpt
= nmea::sentence_cast
<nmea::dpt
>(s
);
40 ASSERT_NE(nullptr, dpt
);
43 TEST_F(Test_nmea_dpt
, parse_invalid_number_of_arguments
)
46 nmea::detail::factory::sentence_parse
<nmea::dpt
>(nmea::talker_id::none
, {1, "@"}));
48 nmea::detail::factory::sentence_parse
<nmea::dpt
>(nmea::talker_id::none
, {4, "@"}));
51 TEST_F(Test_nmea_dpt
, empty_to_string
)
55 EXPECT_STREQ("$IIDPT,0,0,*6C", nmea::to_string(dpt
).c_str());
58 TEST_F(Test_nmea_dpt
, set_depth_feet
)
61 dpt
.set_depth_meter(12.5);
63 EXPECT_STREQ("$IIDPT,12.5,0,*44", nmea::to_string(dpt
).c_str());
66 TEST_F(Test_nmea_dpt
, set_transducer_offset
)
69 dpt
.set_transducer_offset(12.5);
71 EXPECT_STREQ("$IIDPT,0,12.5,*44", nmea::to_string(dpt
).c_str());
74 TEST_F(Test_nmea_dpt
, set_max_depth
)
77 dpt
.set_max_depth(2.5);
79 EXPECT_STREQ("$IIDPT,0,0,2.5*45", nmea::to_string(dpt
).c_str());