NMEA: make nmeatool available with/without ENABLE_IO
[marnav.git] / test / nmea / Test_nmea_pgrmz.cpp
blob2059da8f7b491377774da8fbb1957365e884b1c3
1 #include "type_traits_helper.hpp"
2 #include <marnav/nmea/nmea.hpp>
3 #include <gtest/gtest.h>
4 #include <marnav/nmea/pgrmz.hpp>
6 namespace
9 using namespace marnav;
11 class Test_nmea_pgrmz : public ::testing::Test
15 TEST_F(Test_nmea_pgrmz, contruction)
17 nmea::pgrmz pgrmz;
20 TEST_F(Test_nmea_pgrmz, properties)
22 nmea_sentence_traits<nmea::pgrmz>();
25 TEST_F(Test_nmea_pgrmz, parse)
27 auto s = nmea::make_sentence("$PGRMZ,1494,f,*10");
28 ASSERT_NE(nullptr, s);
30 auto pgrmz = nmea::sentence_cast<nmea::pgrmz>(s);
31 ASSERT_NE(nullptr, pgrmz);
34 TEST_F(Test_nmea_pgrmz, parse_invalid_number_of_arguments)
36 EXPECT_ANY_THROW(
37 nmea::detail::factory::sentence_parse<nmea::pgrmz>(nmea::talker::none, {2, "@"}));
38 EXPECT_ANY_THROW(
39 nmea::detail::factory::sentence_parse<nmea::pgrmz>(nmea::talker::none, {4, "@"}));
42 TEST_F(Test_nmea_pgrmz, empty_to_string)
44 nmea::pgrmz pgrmz;
46 EXPECT_STREQ("$PGRMZ,0,f,*28", nmea::to_string(pgrmz).c_str());
49 TEST_F(Test_nmea_pgrmz, set_altitude)
51 nmea::pgrmz pgrmz;
52 pgrmz.set_altitude(units::feet{100});
54 EXPECT_STREQ("$PGRMZ,100,f,*29", nmea::to_string(pgrmz).c_str());
57 TEST_F(Test_nmea_pgrmz, set_fix_nofix)
59 nmea::pgrmz pgrmz;
60 pgrmz.set_fix(nmea::pgrmz::fix_type::no_fix);
62 EXPECT_STREQ("$PGRMZ,0,f,1*19", nmea::to_string(pgrmz).c_str());
65 TEST_F(Test_nmea_pgrmz, set_fix_2d)
67 nmea::pgrmz pgrmz;
68 pgrmz.set_fix(nmea::pgrmz::fix_type::d2fix);
70 EXPECT_STREQ("$PGRMZ,0,f,2*1A", nmea::to_string(pgrmz).c_str());
73 TEST_F(Test_nmea_pgrmz, set_fix_3d)
75 nmea::pgrmz pgrmz;
76 pgrmz.set_fix(nmea::pgrmz::fix_type::d3fix);
78 EXPECT_STREQ("$PGRMZ,0,f,3*1B", nmea::to_string(pgrmz).c_str());