NMEA: changed interface of sentences containing position information.
[marnav.git] / test / nmea / Test_nmea_tll.cpp
blob50aa1e434d973ba2cf826f4249aa1c7c1c889e7d
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/tll.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
8 using namespace marnav;
10 class Test_nmea_tll : public ::testing::Test
14 TEST_F(Test_nmea_tll, contruction) { EXPECT_NO_THROW(nmea::tll tll); }
16 TEST_F(Test_nmea_tll, properties) { nmea_sentence_traits<nmea::tll>(); }
18 TEST_F(Test_nmea_tll, parse)
20 auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00");
21 ASSERT_NE(nullptr, s);
23 auto tll = nmea::sentence_cast<nmea::tll>(s);
24 ASSERT_NE(nullptr, tll);
27 TEST_F(Test_nmea_tll, parse_invalid_number_of_arguments)
29 EXPECT_ANY_THROW(nmea::sentence_parse<nmea::tll>("@@", {8, "@"}));
30 EXPECT_ANY_THROW(nmea::sentence_parse<nmea::tll>("@@", {10, "@"}));
33 TEST_F(Test_nmea_tll, empty_to_string)
35 nmea::tll tll;
37 EXPECT_STREQ(
38 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00", nmea::to_string(tll).c_str());
41 TEST_F(Test_nmea_tll, set_lat_north)
43 nmea::tll tll;
44 tll.set_lat(geo::latitude{12.34});
46 EXPECT_STREQ(
47 "$GPTLL,00,1220.4000,N,00000.0000,E,,000000,T,*05", nmea::to_string(tll).c_str());
50 TEST_F(Test_nmea_tll, get_latitude_north)
52 const auto s = nmea::make_sentence("$GPTLL,00,1220.4000,N,00000.0000,E,,000000,T,*05");
53 const auto tll = nmea::sentence_cast<nmea::tll>(s);
55 EXPECT_EQ(geo::latitude{12.34}, tll->get_latitude());
58 TEST_F(Test_nmea_tll, set_lat_south)
60 nmea::tll tll;
61 tll.set_lat(geo::latitude{-12.34});
63 EXPECT_STREQ(
64 "$GPTLL,00,1220.4000,S,00000.0000,E,,000000,T,*18", nmea::to_string(tll).c_str());
67 TEST_F(Test_nmea_tll, get_latitude_south)
69 const auto s = nmea::make_sentence("$GPTLL,00,1220.4000,S,00000.0000,E,,000000,T,*18");
70 const auto tll = nmea::sentence_cast<nmea::tll>(s);
72 EXPECT_EQ(geo::latitude{-12.34}, tll->get_latitude());
75 TEST_F(Test_nmea_tll, set_lon_west)
77 nmea::tll tll;
78 tll.set_lon(geo::longitude{-123.45});
80 EXPECT_STREQ(
81 "$GPTLL,00,0000.0000,N,12327.0000,W,,000000,T,*17", nmea::to_string(tll).c_str());
84 TEST_F(Test_nmea_tll, get_longitude_west)
86 const auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,12327.0000,W,,000000,T,*17");
87 const auto tll = nmea::sentence_cast<nmea::tll>(s);
89 EXPECT_EQ(geo::longitude{-123.45}, tll->get_longitude());
92 TEST_F(Test_nmea_tll, set_lon_east)
94 nmea::tll tll;
95 tll.set_lon(geo::longitude{123.45});
97 EXPECT_STREQ(
98 "$GPTLL,00,0000.0000,N,12327.0000,E,,000000,T,*05", nmea::to_string(tll).c_str());
101 TEST_F(Test_nmea_tll, get_longitude_east)
103 const auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,12327.0000,E,,000000,T,*05");
104 const auto tll = nmea::sentence_cast<nmea::tll>(s);
106 EXPECT_EQ(geo::longitude{123.45}, tll->get_longitude());