1 #include <marnav/nmea/aam.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
9 using namespace marnav
;
11 class Test_nmea_aam
: public ::testing::Test
15 TEST_F(Test_nmea_aam
, contruction
)
17 EXPECT_NO_THROW(nmea::aam aam
);
20 TEST_F(Test_nmea_aam
, properties
)
22 nmea_sentence_traits
<nmea::aam
>();
25 TEST_F(Test_nmea_aam
, parse
)
27 auto s
= nmea::make_sentence("$GPAAM,A,A,0.5,N,POINT1*6E");
28 ASSERT_NE(nullptr, s
);
30 auto aam
= nmea::sentence_cast
<nmea::aam
>(s
);
31 ASSERT_NE(nullptr, aam
);
33 auto radius
= aam
->get_arrival_circle_radius();
34 EXPECT_NEAR(0.5, radius
.get
<marnav::units::nautical_miles
>().value(), 1e-8);
37 TEST_F(Test_nmea_aam
, parse_wrong_distance_unit
)
39 EXPECT_ANY_THROW(nmea::make_sentence("$GPAAM,,,0.5,M,POINT1*6D"));
42 TEST_F(Test_nmea_aam
, parse_missing_distance_unit
)
44 EXPECT_ANY_THROW(nmea::make_sentence("$GPAAM,,,0.5,,POINT1*20"));
47 TEST_F(Test_nmea_aam
, parse_invalid_number_of_arguments
)
50 nmea::detail::factory::sentence_parse
<nmea::aam
>(nmea::talker::none
, {4, "@"}));
52 nmea::detail::factory::sentence_parse
<nmea::aam
>(nmea::talker::none
, {6, "@"}));
55 TEST_F(Test_nmea_aam
, empty_to_string
)
59 EXPECT_STREQ("$GPAAM,V,V,0,N,*08", nmea::to_string(aam
).c_str());
62 TEST_F(Test_nmea_aam
, set_arrival_circle_entered_ok
)
65 aam
.set_arrival_circle_entered(nmea::status::ok
);
67 EXPECT_STREQ("$GPAAM,A,V,0,N,*1F", nmea::to_string(aam
).c_str());
70 TEST_F(Test_nmea_aam
, set_arrival_circle_entered_warning
)
73 aam
.set_arrival_circle_entered(nmea::status::warning
);
75 EXPECT_STREQ("$GPAAM,V,V,0,N,*08", nmea::to_string(aam
).c_str());
78 TEST_F(Test_nmea_aam
, set_arrival_circle_entered_invalid_status
)
82 aam
.set_arrival_circle_entered(static_cast<nmea::status
>('?')), std::invalid_argument
);
85 TEST_F(Test_nmea_aam
, set_perpendicular_passed_ok
)
88 aam
.set_perpendicular_passed(nmea::status::ok
);
90 EXPECT_STREQ("$GPAAM,V,A,0,N,*1F", nmea::to_string(aam
).c_str());
93 TEST_F(Test_nmea_aam
, set_perpendicular_passed_warning
)
96 aam
.set_perpendicular_passed(nmea::status::warning
);
98 EXPECT_STREQ("$GPAAM,V,V,0,N,*08", nmea::to_string(aam
).c_str());
101 TEST_F(Test_nmea_aam
, set_perpendicular_passed_invalid_status
)
105 aam
.set_perpendicular_passed(static_cast<nmea::status
>('?')), std::invalid_argument
);
108 TEST_F(Test_nmea_aam
, set_arrival_circle_radius
)
111 aam
.set_arrival_circle_radius(marnav::units::nautical_miles
{1.2});
113 EXPECT_STREQ("$GPAAM,V,V,1.2,N,*15", nmea::to_string(aam
).c_str());
116 TEST_F(Test_nmea_aam
, set_arrival_circle_radius_negative
)
120 EXPECT_THROW(aam
.set_arrival_circle_radius(marnav::units::nautical_miles
{-1.2}),
121 std::invalid_argument
);
124 TEST_F(Test_nmea_aam
, set_waypoint_id
)
127 aam
.set_waypoint_id(nmea::waypoint
{"wpt1"});
129 EXPECT_STREQ("$GPAAM,V,V,0,N,wpt1*4A", nmea::to_string(aam
).c_str());