Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_tll.cpp
blobf71d9d76c92e106a5e2c72e0cd4ba769598e9e4b
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)
16 EXPECT_NO_THROW(nmea::tll tll);
19 TEST_F(Test_nmea_tll, properties)
21 nmea_sentence_traits<nmea::tll>();
24 TEST_F(Test_nmea_tll, parse)
26 auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00");
27 ASSERT_NE(nullptr, s);
29 auto tll = nmea::sentence_cast<nmea::tll>(s);
30 ASSERT_NE(nullptr, tll);
33 TEST_F(Test_nmea_tll, parse_invalid_number_of_arguments)
35 EXPECT_ANY_THROW(
36 nmea::detail::factory::sentence_parse<nmea::tll>(nmea::talker::none, {8, "@"}));
37 EXPECT_ANY_THROW(
38 nmea::detail::factory::sentence_parse<nmea::tll>(nmea::talker::none, {10, "@"}));
41 TEST_F(Test_nmea_tll, empty_to_string)
43 nmea::tll tll;
45 EXPECT_STREQ(
46 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00", nmea::to_string(tll).c_str());
49 TEST_F(Test_nmea_tll, set_lat_north)
51 nmea::tll tll;
52 tll.set_lat(geo::latitude{12.34});
54 EXPECT_STREQ(
55 "$GPTLL,00,1220.4000,N,00000.0000,E,,000000,T,*05", nmea::to_string(tll).c_str());
58 TEST_F(Test_nmea_tll, get_lat_north)
60 const auto tll = nmea::sentence_cast<nmea::tll>(
61 nmea::make_sentence("$GPTLL,00,1220.4000,N,00000.0000,E,,000000,T,*05"));
63 EXPECT_DOUBLE_EQ(geo::latitude{12.34}, tll->get_lat());
66 TEST_F(Test_nmea_tll, set_lat_south)
68 nmea::tll tll;
69 tll.set_lat(geo::latitude{-12.34});
71 EXPECT_STREQ(
72 "$GPTLL,00,1220.4000,S,00000.0000,E,,000000,T,*18", nmea::to_string(tll).c_str());
75 TEST_F(Test_nmea_tll, get_lat_south)
77 const auto tll = nmea::sentence_cast<nmea::tll>(
78 nmea::make_sentence("$GPTLL,00,1220.4000,S,00000.0000,E,,000000,T,*18"));
80 EXPECT_DOUBLE_EQ(geo::latitude{-12.34}, tll->get_lat());
83 TEST_F(Test_nmea_tll, set_lon_west)
85 nmea::tll tll;
86 tll.set_lon(geo::longitude{-123.45});
88 EXPECT_STREQ(
89 "$GPTLL,00,0000.0000,N,12327.0000,W,,000000,T,*17", nmea::to_string(tll).c_str());
92 TEST_F(Test_nmea_tll, get_lon_west)
94 const auto tll = nmea::sentence_cast<nmea::tll>(
95 nmea::make_sentence("$GPTLL,00,0000.0000,N,12327.0000,W,,000000,T,*17"));
97 EXPECT_DOUBLE_EQ(geo::longitude{-123.45}, tll->get_lon());
100 TEST_F(Test_nmea_tll, set_lon_east)
102 nmea::tll tll;
103 tll.set_lon(geo::longitude{123.45});
105 EXPECT_STREQ(
106 "$GPTLL,00,0000.0000,N,12327.0000,E,,000000,T,*05", nmea::to_string(tll).c_str());
109 TEST_F(Test_nmea_tll, get_lon_east)
111 const auto tll = nmea::sentence_cast<nmea::tll>(
112 nmea::make_sentence("$GPTLL,00,0000.0000,N,12327.0000,E,,000000,T,*05"));
114 EXPECT_DOUBLE_EQ(geo::longitude{123.45}, tll->get_lon());
117 TEST_F(Test_nmea_tll, set_status)
120 nmea::tll tll;
121 tll.set_status(nmea::target_status::lost);
122 EXPECT_STREQ(
123 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,L,*18", nmea::to_string(tll).c_str());
126 nmea::tll tll;
127 tll.set_status(nmea::target_status::query);
128 EXPECT_STREQ(
129 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,Q,*05", nmea::to_string(tll).c_str());
132 nmea::tll tll;
133 tll.set_status(nmea::target_status::tracking);
134 EXPECT_STREQ(
135 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00", nmea::to_string(tll).c_str());
139 TEST_F(Test_nmea_tll, get_status)
142 auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,00000.0000,E,,000000,L,*18");
143 EXPECT_EQ(nmea::target_status::lost, nmea::sentence_cast<nmea::tll>(s)->get_status());
146 auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,00000.0000,E,,000000,Q,*05");
147 EXPECT_EQ(nmea::target_status::query, nmea::sentence_cast<nmea::tll>(s)->get_status());
150 auto s = nmea::make_sentence("$GPTLL,00,0000.0000,N,00000.0000,E,,000000,T,*00");
151 EXPECT_EQ(
152 nmea::target_status::tracking, nmea::sentence_cast<nmea::tll>(s)->get_status());