Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_bwc.cpp
blob78d8a6c61e66d6b62a3462119cc67561fa6ea6fa
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/bwc.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
9 using namespace marnav;
11 class Test_nmea_bwc : public ::testing::Test
15 TEST_F(Test_nmea_bwc, contruction)
17 EXPECT_NO_THROW(nmea::bwc bwc);
20 TEST_F(Test_nmea_bwc, properties)
22 nmea_sentence_traits<nmea::bwc>();
25 TEST_F(Test_nmea_bwc, parse_before_v23)
27 auto s = nmea::make_sentence(
28 "$GPBWC,220516,5130.02,N,00046.34,W,213.8,T,218.0,M,0004.6,N,EGLM*21");
29 ASSERT_NE(nullptr, s);
31 auto bwc = nmea::sentence_cast<nmea::bwc>(s);
32 ASSERT_NE(nullptr, bwc);
35 TEST_F(Test_nmea_bwc, parse)
37 auto s = nmea::make_sentence(
38 "$GPBWC,220516,5130.02,N,00046.34,W,213.8,T,218.0,M,0004.6,N,EGLM,A*4C");
39 ASSERT_NE(nullptr, s);
41 auto bwc = nmea::sentence_cast<nmea::bwc>(s);
42 ASSERT_NE(nullptr, bwc);
45 TEST_F(Test_nmea_bwc, parse_invalid_number_of_arguments)
47 EXPECT_ANY_THROW(
48 nmea::detail::factory::sentence_parse<nmea::bwc>(nmea::talker::none, {11, "@"}));
49 EXPECT_ANY_THROW(
50 nmea::detail::factory::sentence_parse<nmea::bwc>(nmea::talker::none, {14, "@"}));
53 TEST_F(Test_nmea_bwc, empty_to_string)
55 nmea::bwc bwc;
57 EXPECT_STREQ("$GPBWC,,,,,,,,,,,,,*6D", nmea::to_string(bwc).c_str());
60 TEST_F(Test_nmea_bwc, set_time_utc)
62 nmea::bwc bwc;
63 bwc.set_time_utc(nmea::time{12, 34, 56});
65 EXPECT_STREQ("$GPBWC,123456,,,,,,,,,,,,*6A", nmea::to_string(bwc).c_str());
68 TEST_F(Test_nmea_bwc, set_lat)
70 nmea::bwc bwc;
71 bwc.set_lat(geo::latitude{12.34});
73 EXPECT_STREQ("$GPBWC,,1220.4000,N,,,,,,,,,,*08", nmea::to_string(bwc).c_str());
76 TEST_F(Test_nmea_bwc, set_lon)
78 nmea::bwc bwc;
79 bwc.set_lon(geo::longitude{123.45});
81 EXPECT_STREQ("$GPBWC,,,,12327.0000,E,,,,,,,,*33", nmea::to_string(bwc).c_str());
84 TEST_F(Test_nmea_bwc, set_bearing_true)
86 nmea::bwc bwc;
87 bwc.set_bearing_true(12.3);
89 EXPECT_STREQ("$GPBWC,,,,,,12.3,T,,,,,,*27", nmea::to_string(bwc).c_str());
92 TEST_F(Test_nmea_bwc, set_bearing_mag)
94 nmea::bwc bwc;
95 bwc.set_bearing_mag(12.3);
97 EXPECT_STREQ("$GPBWC,,,,,,,,12.3,M,,,,*3E", nmea::to_string(bwc).c_str());
100 TEST_F(Test_nmea_bwc, set_distance)
102 nmea::bwc bwc;
103 bwc.set_distance(units::nautical_miles{100});
105 EXPECT_STREQ("$GPBWC,,,,,,,,,,100,N,,*12", nmea::to_string(bwc).c_str());
108 TEST_F(Test_nmea_bwc, set_distance_different_unit)
110 nmea::bwc bwc;
111 bwc.set_distance(units::meters{100 * 1852.0});
113 EXPECT_STREQ("$GPBWC,,,,,,,,,,100,N,,*12", nmea::to_string(bwc).c_str());
116 TEST_F(Test_nmea_bwc, set_waypoint)
118 nmea::bwc bwc;
119 bwc.set_waypoint(nmea::waypoint{"POINT1"});
121 EXPECT_STREQ("$GPBWC,,,,,,,,,,,,POINT1,*10", nmea::to_string(bwc).c_str());
124 TEST_F(Test_nmea_bwc, set_mode_indicator)
126 nmea::bwc bwc;
127 bwc.set_mode_indicator(nmea::mode_indicator::differential);
129 EXPECT_STREQ("$GPBWC,,,,,,,,,,,,,D*29", nmea::to_string(bwc).c_str());