NMEA: changed type of talker id from 'std::string' to its own type.
[marnav.git] / test / nmea / Test_nmea_gll.cpp
blobf9178ef6ba5040a7a94af16f52eeec735a954589
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/gll.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
9 using namespace marnav;
11 class Test_nmea_gll : public ::testing::Test
15 TEST_F(Test_nmea_gll, contruction) { EXPECT_NO_THROW(nmea::gll gll); }
17 TEST_F(Test_nmea_gll, properties) { nmea_sentence_traits<nmea::gll>(); }
19 TEST_F(Test_nmea_gll, parse)
21 auto s = nmea::make_sentence("$GPGLL,,,,,,*50");
22 ASSERT_NE(nullptr, s);
24 auto gll = nmea::sentence_cast<nmea::gll>(s);
25 ASSERT_NE(nullptr, gll);
28 TEST_F(Test_nmea_gll, parse_invalid_number_of_arguments)
30 EXPECT_ANY_THROW(nmea::sentence_parse<nmea::gll>(nmea::talker_id::none, {5, "@"}));
31 EXPECT_ANY_THROW(nmea::sentence_parse<nmea::gll>(nmea::talker_id::none, {8, "@"}));
34 TEST_F(Test_nmea_gll, empty_to_string)
36 nmea::gll gll;
38 EXPECT_STREQ("$GPGLL,,,,,,,V*2A", nmea::to_string(gll).c_str());
41 TEST_F(Test_nmea_gll, set_lat_north)
43 nmea::gll gll;
44 gll.set_lat(geo::latitude{12.345});
46 EXPECT_STREQ("$GPGLL,1220.7000,N,,,,,V*4C", nmea::to_string(gll).c_str());
49 TEST_F(Test_nmea_gll, set_lat_south)
51 nmea::gll gll;
52 gll.set_lat(geo::latitude{-12.345});
54 EXPECT_STREQ("$GPGLL,1220.7000,S,,,,,V*51", nmea::to_string(gll).c_str());
57 TEST_F(Test_nmea_gll, set_lon_west)
59 nmea::gll gll;
60 gll.set_lon(geo::longitude{-123.45});
62 EXPECT_STREQ("$GPGLL,,,12327.0000,W,,,V*66", nmea::to_string(gll).c_str());
65 TEST_F(Test_nmea_gll, set_lon_east)
67 nmea::gll gll;
68 gll.set_lon(geo::longitude{123.45});
70 EXPECT_STREQ("$GPGLL,,,12327.0000,E,,,V*74", nmea::to_string(gll).c_str());