1 #include <gtest/gtest.h>
2 #include <marnav/nmea/glc.hpp>
3 #include <marnav/nmea/nmea.hpp>
4 #include "type_traits_helper.hpp"
9 using namespace marnav
;
11 class Test_nmea_glc
: public ::testing::Test
15 TEST_F(Test_nmea_glc
, contruction
)
17 EXPECT_NO_THROW(nmea::glc glc
);
20 TEST_F(Test_nmea_glc
, properties
)
22 nmea_sentence_traits
<nmea::glc
>();
25 TEST_F(Test_nmea_glc
, parse
)
27 auto s
= nmea::make_sentence("$GPGLC,1,1,A,1,A,2,A,3,A,4,V,,*21");
28 ASSERT_NE(nullptr, s
);
30 auto glc
= nmea::sentence_cast
<nmea::glc
>(s
);
31 ASSERT_NE(nullptr, glc
);
34 TEST_F(Test_nmea_glc
, parse_invalid_number_of_arguments
)
37 nmea::detail::factory::sentence_parse
<nmea::glc
>(nmea::talker::none
, {12, "@"}));
39 nmea::detail::factory::sentence_parse
<nmea::glc
>(nmea::talker::none
, {14, "@"}));
42 TEST_F(Test_nmea_glc
, empty_to_string
)
46 EXPECT_STREQ("$GPGLC,0,0,V,,,,,,,,,,*25", nmea::to_string(glc
).c_str());
49 TEST_F(Test_nmea_glc
, set_time_diff_invalid_index
)
53 EXPECT_ANY_THROW(glc
.set_time_diff(-1, {0.0, nmea::status::ok
}));
54 EXPECT_ANY_THROW(glc
.set_time_diff(5, {0.0, nmea::status::ok
}));
57 TEST_F(Test_nmea_glc
, get_time_diff_invalid_index
)
61 EXPECT_ANY_THROW(glc
.get_time_diff(-1));
62 EXPECT_ANY_THROW(glc
.get_time_diff(5));
63 EXPECT_ANY_THROW(glc
.get_time_diff(nmea::glc::max_differences
));
66 TEST_F(Test_nmea_glc
, set_time_diff
)
70 glc
.set_time_diff(0, {1.0, nmea::status::ok
});
71 EXPECT_STREQ("$GPGLC,0,0,V,1,A,,,,,,,,*55", nmea::to_string(glc
).c_str());
75 glc
.set_time_diff(1, {1.0, nmea::status::ok
});
76 EXPECT_STREQ("$GPGLC,0,0,V,,,1,A,,,,,,*55", nmea::to_string(glc
).c_str());
80 glc
.set_time_diff(2, {1.0, nmea::status::ok
});
81 EXPECT_STREQ("$GPGLC,0,0,V,,,,,1,A,,,,*55", nmea::to_string(glc
).c_str());
85 glc
.set_time_diff(3, {1.0, nmea::status::ok
});
86 EXPECT_STREQ("$GPGLC,0,0,V,,,,,,,1,A,,*55", nmea::to_string(glc
).c_str());
90 glc
.set_time_diff(4, {1.0, nmea::status::ok
});
91 EXPECT_STREQ("$GPGLC,0,0,V,,,,,,,,,1,A*55", nmea::to_string(glc
).c_str());
95 TEST_F(Test_nmea_glc
, get_time_diff
)
97 auto s
= nmea::make_sentence("$GPGLC,1,1,A,1,A,2,A,3,A,4,V,,*21");
98 ASSERT_NE(nullptr, s
);
100 auto glc
= nmea::sentence_cast
<nmea::glc
>(s
);
101 ASSERT_NE(nullptr, glc
);
103 auto const t
= glc
->get_time_diff(0);
104 EXPECT_TRUE(static_cast<bool>(t
));
105 EXPECT_NEAR(1.0, t
->diff
, 1e-8);
106 EXPECT_EQ(nmea::status::ok
, t
->status
);