NMEA: serialization of sentences changed, gains performance by about 7 percent on...
[marnav.git] / test / nmea / Test_nmea_gns.cpp
blobb65b04820b476d788e903f103d62b65f63482576
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/gns.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
9 using namespace marnav;
11 class Test_nmea_gns : public ::testing::Test
15 TEST_F(Test_nmea_gns, contruction)
17 EXPECT_NO_THROW(nmea::gns gns);
20 TEST_F(Test_nmea_gns, properties)
22 nmea_sentence_traits<nmea::gns>();
25 TEST_F(Test_nmea_gns, parse)
27 auto s = nmea::make_sentence(
28 "$GNGNS,122310.0,3722.42567,N,12258.856215,W,AA,15,0.9,1005.54,6.5,,*75");
29 ASSERT_NE(nullptr, s);
31 auto gns = nmea::sentence_cast<nmea::gns>(s);
32 ASSERT_NE(nullptr, gns);
35 TEST_F(Test_nmea_gns, parse_invalid_number_of_arguments)
37 EXPECT_ANY_THROW(
38 nmea::detail::factory::sentence_parse<nmea::gns>(nmea::talker_id::none, {11, "@"}));
39 EXPECT_ANY_THROW(
40 nmea::detail::factory::sentence_parse<nmea::gns>(nmea::talker_id::none, {13, "@"}));
43 TEST_F(Test_nmea_gns, empty_to_string)
45 nmea::gns gns;
47 EXPECT_STREQ("$GPGNS,,,,,,AA,,,,,,*4D", nmea::to_string(gns).c_str());
50 TEST_F(Test_nmea_gns, set_lat)
52 nmea::gns gns;
53 gns.set_lat(geo::latitude{12.34});
55 EXPECT_STREQ("$GPGNS,,1220.4000,N,,,AA,,,,,,*28", nmea::to_string(gns).c_str());
58 TEST_F(Test_nmea_gns, set_lon_west)
60 nmea::gns gns;
61 gns.set_lon(geo::longitude{-123.45});
63 EXPECT_STREQ("$GPGNS,,,,12327.0000,W,AA,,,,,,*01", nmea::to_string(gns).c_str());
66 TEST_F(Test_nmea_gns, set_lon_east)
68 nmea::gns gns;
69 gns.set_lon(geo::longitude{123.45});
71 EXPECT_STREQ("$GPGNS,,,,12327.0000,E,AA,,,,,,*13", nmea::to_string(gns).c_str());
74 TEST_F(Test_nmea_gns, set_mode_indicator)
76 nmea::gns gns;
77 gns.set_mode_indicator("DD");
79 EXPECT_STREQ("$GPGNS,,,,,,DD,,,,,,*4D", nmea::to_string(gns).c_str());