Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_wpl.cpp
blob552ad053f08e1bdb430bf8b34bf865a6df11297c
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/wpl.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
9 using namespace marnav;
11 class Test_nmea_wpl : public ::testing::Test
15 TEST_F(Test_nmea_wpl, contruction)
17 EXPECT_NO_THROW(nmea::wpl wpl);
20 TEST_F(Test_nmea_wpl, properties)
22 nmea_sentence_traits<nmea::wpl>();
25 TEST_F(Test_nmea_wpl, parse)
27 auto s = nmea::make_sentence("$GPWPL,12.3,N,123.4,E,POINT1*32");
28 ASSERT_NE(nullptr, s);
30 auto wpl = nmea::sentence_cast<nmea::wpl>(s);
31 ASSERT_NE(nullptr, wpl);
34 TEST_F(Test_nmea_wpl, parse_invalid_number_of_arguments)
36 EXPECT_ANY_THROW(
37 nmea::detail::factory::sentence_parse<nmea::wpl>(nmea::talker::none, {4, "@"}));
38 EXPECT_ANY_THROW(
39 nmea::detail::factory::sentence_parse<nmea::wpl>(nmea::talker::none, {6, "@"}));
42 TEST_F(Test_nmea_wpl, empty_to_string)
44 nmea::wpl wpl;
46 EXPECT_STREQ("$GPWPL,,,,,*70", nmea::to_string(wpl).c_str());
49 TEST_F(Test_nmea_wpl, set_lat)
51 nmea::wpl wpl;
52 wpl.set_lat(geo::latitude{12.3});
54 EXPECT_STREQ("$GPWPL,1218.0000,N,,,*1A", nmea::to_string(wpl).c_str());
57 TEST_F(Test_nmea_wpl, set_lon_west)
59 nmea::wpl wpl;
60 wpl.set_lon(geo::longitude{-123.4});
62 EXPECT_STREQ("$GPWPL,,,12324.0000,W,*3F", nmea::to_string(wpl).c_str());
65 TEST_F(Test_nmea_wpl, set_lon_east)
67 nmea::wpl wpl;
68 wpl.set_lon(geo::longitude{123.4});
70 EXPECT_STREQ("$GPWPL,,,12324.0000,E,*2D", nmea::to_string(wpl).c_str());
73 TEST_F(Test_nmea_wpl, set_waypoint)
75 nmea::wpl wpl;
76 wpl.set_waypoint(nmea::waypoint{"POINT1"});
78 EXPECT_STREQ("$GPWPL,,,,,POINT1*0D", nmea::to_string(wpl).c_str());