1 #include <gtest/gtest.h>
2 #include <marnav/nmea/bwc.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
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
)
48 nmea::detail::factory::sentence_parse
<nmea::bwc
>(nmea::talker::none
, {11, "@"}));
50 nmea::detail::factory::sentence_parse
<nmea::bwc
>(nmea::talker::none
, {14, "@"}));
53 TEST_F(Test_nmea_bwc
, empty_to_string
)
57 EXPECT_STREQ("$GPBWC,,,,,,,,,,,,,*6D", nmea::to_string(bwc
).c_str());
60 TEST_F(Test_nmea_bwc
, set_time_utc
)
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
)
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
)
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
)
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
)
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
)
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
)
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
)
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
)
127 bwc
.set_mode_indicator(nmea::mode_indicator::differential
);
129 EXPECT_STREQ("$GPBWC,,,,,,,,,,,,,D*29", nmea::to_string(bwc
).c_str());