NMEA: serialization of sentences changed, gains performance by about 7 percent on...
[marnav.git] / test / nmea / Test_nmea_wnc.cpp
blobb5e16f55047619ec6b7ab72bb020ddcd999e2d83
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/wnc.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
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)
36 EXPECT_ANY_THROW(
37 nmea::detail::factory::sentence_parse<nmea::wnc>(nmea::talker_id::none, {5, "@"}));
38 EXPECT_ANY_THROW(
39 nmea::detail::factory::sentence_parse<nmea::wnc>(nmea::talker_id::none, {7, "@"}));
42 TEST_F(Test_nmea_wnc, empty_to_string)
44 nmea::wnc wnc;
46 EXPECT_STREQ("$GPWNC,,,,,,*4D", nmea::to_string(wnc).c_str());
49 TEST_F(Test_nmea_wnc, set_distance_nm)
51 nmea::wnc wnc;
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)
59 nmea::wnc wnc;
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)
67 nmea::wnc wnc;
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)
75 nmea::wnc wnc;
76 wnc.set_waypoint_from(nmea::waypoint{"wpt1"});
78 EXPECT_STREQ("$GPWNC,,,,,,wpt1*0F", nmea::to_string(wnc).c_str());