Build: update docker build scripts
[marnav.git] / test / nmea / Test_nmea_alm.cpp
blob1836ea4a63eb9371f64065e195643aeeb8fe09f0
1 #include <gtest/gtest.h>
2 #include <marnav/nmea/alm.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
6 namespace
9 using namespace marnav;
11 class Test_nmea_alm : public ::testing::Test
15 TEST_F(Test_nmea_alm, contruction)
17 EXPECT_NO_THROW(nmea::alm alm);
20 TEST_F(Test_nmea_alm, properties)
22 nmea_sentence_traits<nmea::alm>();
25 TEST_F(Test_nmea_alm, parse)
27 auto s = nmea::make_sentence(
28 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
29 ASSERT_NE(nullptr, s);
31 auto alm = nmea::sentence_cast<nmea::alm>(s);
32 ASSERT_NE(nullptr, alm);
35 TEST_F(Test_nmea_alm, parse_invalid_satellite_prn)
37 EXPECT_ANY_THROW(nmea::make_sentence(
38 "$GPALM,1,1,33,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*73"));
41 TEST_F(Test_nmea_alm, parse_invalid_number_of_arguments)
43 EXPECT_ANY_THROW(
44 nmea::detail::factory::sentence_parse<nmea::alm>(nmea::talker::none, {14, "@"}));
45 EXPECT_ANY_THROW(
46 nmea::detail::factory::sentence_parse<nmea::alm>(nmea::talker::none, {16, "@"}));
49 TEST_F(Test_nmea_alm, empty_to_string)
51 nmea::alm alm;
53 EXPECT_STREQ("$GPALM,0,0,00,0,00,0,0,0,0,0,0,0,0,0,0*4B", nmea::to_string(alm).c_str());
56 TEST_F(Test_nmea_alm, get_number_of_messages)
58 auto s = nmea::make_sentence(
59 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
60 ASSERT_NE(nullptr, s);
61 auto alm = nmea::sentence_cast<nmea::alm>(s);
62 ASSERT_NE(nullptr, alm);
64 EXPECT_EQ(1u, alm->get_number_of_messages());
67 TEST_F(Test_nmea_alm, get_message_number)
69 auto s = nmea::make_sentence(
70 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
71 ASSERT_NE(nullptr, s);
72 auto alm = nmea::sentence_cast<nmea::alm>(s);
73 ASSERT_NE(nullptr, alm);
75 EXPECT_EQ(1u, alm->get_message_number());
78 TEST_F(Test_nmea_alm, get_satellite_prn)
80 auto s = nmea::make_sentence(
81 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
82 ASSERT_NE(nullptr, s);
83 auto alm = nmea::sentence_cast<nmea::alm>(s);
84 ASSERT_NE(nullptr, alm);
86 EXPECT_EQ(15u, alm->get_satellite_prn());
89 TEST_F(Test_nmea_alm, get_gps_week_number)
91 auto s = nmea::make_sentence(
92 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
93 ASSERT_NE(nullptr, s);
94 auto alm = nmea::sentence_cast<nmea::alm>(s);
95 ASSERT_NE(nullptr, alm);
97 EXPECT_EQ(1159u, alm->get_gps_week_number());
100 TEST_F(Test_nmea_alm, get_sv_health)
102 auto s = nmea::make_sentence(
103 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
104 ASSERT_NE(nullptr, s);
105 auto alm = nmea::sentence_cast<nmea::alm>(s);
106 ASSERT_NE(nullptr, alm);
108 EXPECT_EQ(0u, alm->get_sv_health());
111 TEST_F(Test_nmea_alm, get_eccentricity)
113 auto s = nmea::make_sentence(
114 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
115 ASSERT_NE(nullptr, s);
116 auto alm = nmea::sentence_cast<nmea::alm>(s);
117 ASSERT_NE(nullptr, alm);
119 EXPECT_EQ(0x441du, alm->get_eccentricity());
122 TEST_F(Test_nmea_alm, get_almanac_reference_time)
124 auto s = nmea::make_sentence(
125 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
126 ASSERT_NE(nullptr, s);
127 auto alm = nmea::sentence_cast<nmea::alm>(s);
128 ASSERT_NE(nullptr, alm);
130 EXPECT_EQ(0x4eu, alm->get_almanac_reference_time());
133 TEST_F(Test_nmea_alm, get_inclination_angle)
135 auto s = nmea::make_sentence(
136 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
137 ASSERT_NE(nullptr, s);
138 auto alm = nmea::sentence_cast<nmea::alm>(s);
139 ASSERT_NE(nullptr, alm);
141 EXPECT_EQ(0x16beu, alm->get_inclination_angle());
144 TEST_F(Test_nmea_alm, get_rate_of_right_ascension)
146 auto s = nmea::make_sentence(
147 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
148 ASSERT_NE(nullptr, s);
149 auto alm = nmea::sentence_cast<nmea::alm>(s);
150 ASSERT_NE(nullptr, alm);
152 EXPECT_EQ(0xfd5eu, alm->get_rate_of_right_ascension());
155 TEST_F(Test_nmea_alm, get_root_of_semimajor_axis)
157 auto s = nmea::make_sentence(
158 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
159 ASSERT_NE(nullptr, s);
160 auto alm = nmea::sentence_cast<nmea::alm>(s);
161 ASSERT_NE(nullptr, alm);
163 EXPECT_EQ(0xa10c9fu, alm->get_root_of_semimajor_axis());
166 TEST_F(Test_nmea_alm, get_argument_of_perigee)
168 auto s = nmea::make_sentence(
169 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
170 ASSERT_NE(nullptr, s);
171 auto alm = nmea::sentence_cast<nmea::alm>(s);
172 ASSERT_NE(nullptr, alm);
174 EXPECT_EQ(0x4a2da4u, alm->get_argument_of_perigee());
177 TEST_F(Test_nmea_alm, get_longitude_of_ascension_node)
179 auto s = nmea::make_sentence(
180 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
181 ASSERT_NE(nullptr, s);
182 auto alm = nmea::sentence_cast<nmea::alm>(s);
183 ASSERT_NE(nullptr, alm);
185 EXPECT_EQ(0x686e81u, alm->get_longitude_of_ascension_node());
188 TEST_F(Test_nmea_alm, get_mean_anomaly)
190 auto s = nmea::make_sentence(
191 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
192 ASSERT_NE(nullptr, s);
193 auto alm = nmea::sentence_cast<nmea::alm>(s);
194 ASSERT_NE(nullptr, alm);
196 EXPECT_EQ(0x58cbe1u, alm->get_mean_anomaly());
199 TEST_F(Test_nmea_alm, get_f0_clock_parameter)
201 auto s = nmea::make_sentence(
202 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
203 ASSERT_NE(nullptr, s);
204 auto alm = nmea::sentence_cast<nmea::alm>(s);
205 ASSERT_NE(nullptr, alm);
207 EXPECT_EQ(0xa4u, alm->get_f0_clock_parameter());
210 TEST_F(Test_nmea_alm, get_f1_clock_parameter)
212 auto s = nmea::make_sentence(
213 "$GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*77");
214 ASSERT_NE(nullptr, s);
215 auto alm = nmea::sentence_cast<nmea::alm>(s);
216 ASSERT_NE(nullptr, alm);
218 EXPECT_EQ(0x001u, alm->get_f1_clock_parameter());