1 #include <gtest/gtest.h>
2 #include <marnav/nmea/tll.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
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
)
36 nmea::detail::factory::sentence_parse
<nmea::tll
>(nmea::talker::none
, {8, "@"}));
38 nmea::detail::factory::sentence_parse
<nmea::tll
>(nmea::talker::none
, {10, "@"}));
41 TEST_F(Test_nmea_tll
, empty_to_string
)
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
)
52 tll
.set_lat(geo::latitude
{12.34});
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
)
69 tll
.set_lat(geo::latitude
{-12.34});
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
)
86 tll
.set_lon(geo::longitude
{-123.45});
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
)
103 tll
.set_lon(geo::longitude
{123.45});
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
)
121 tll
.set_status(nmea::target_status::lost
);
123 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,L,*18", nmea::to_string(tll
).c_str());
127 tll
.set_status(nmea::target_status::query
);
129 "$GPTLL,00,0000.0000,N,00000.0000,E,,000000,Q,*05", nmea::to_string(tll
).c_str());
133 tll
.set_status(nmea::target_status::tracking
);
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");
152 nmea::target_status::tracking
, nmea::sentence_cast
<nmea::tll
>(s
)->get_status());