1 #include <gtest/gtest.h>
2 #include <marnav/nmea/wnc.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_wnc
: public ::testing::Test
15 TEST_F(Test_nmea_wnc
, contruction
)
17 EXPECT_NO_THROW(nmea::wnc wnc
);
20 TEST_F(Test_nmea_wnc
, properties
)
22 nmea_sentence_traits
<nmea::wnc
>();
25 TEST_F(Test_nmea_wnc
, parse
)
27 auto s
= nmea::make_sentence("$GPWNC,12.3,N,5.6,K,POINT1,POINT2*78");
28 ASSERT_NE(nullptr, s
);
30 auto wnc
= nmea::sentence_cast
<nmea::wnc
>(s
);
31 ASSERT_NE(nullptr, wnc
);
34 TEST_F(Test_nmea_wnc
, parse_invalid_number_of_arguments
)
37 nmea::detail::factory::sentence_parse
<nmea::wnc
>(nmea::talker_id::none
, {5, "@"}));
39 nmea::detail::factory::sentence_parse
<nmea::wnc
>(nmea::talker_id::none
, {7, "@"}));
42 TEST_F(Test_nmea_wnc
, empty_to_string
)
46 EXPECT_STREQ("$GPWNC,,,,,,*4D", nmea::to_string(wnc
).c_str());
49 TEST_F(Test_nmea_wnc
, set_distance_nm
)
52 wnc
.set_distance_nm(12.5);
54 EXPECT_STREQ("$GPWNC,12.5,N,,,,*1B", nmea::to_string(wnc
).c_str());
57 TEST_F(Test_nmea_wnc
, set_distance_km
)
60 wnc
.set_distance_km(12.5);
62 EXPECT_STREQ("$GPWNC,,,12.5,K,,*1E", nmea::to_string(wnc
).c_str());
65 TEST_F(Test_nmea_wnc
, set_waypoint_to
)
68 wnc
.set_waypoint_to(nmea::waypoint
{"wpt1"});
70 EXPECT_STREQ("$GPWNC,,,,,wpt1,*0F", nmea::to_string(wnc
).c_str());
73 TEST_F(Test_nmea_wnc
, set_waypoint_from
)
76 wnc
.set_waypoint_from(nmea::waypoint
{"wpt1"});
78 EXPECT_STREQ("$GPWNC,,,,,,wpt1*0F", nmea::to_string(wnc
).c_str());