NMEA: make nmeatool available with/without ENABLE_IO
[marnav.git] / test / nmea / Test_nmea_zte.cpp
blob1614d6791c2ff98c08c6486e7aaa2e014f8d6862
1 #include <marnav/nmea/zte.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
6 namespace
8 using namespace marnav;
10 class Test_nmea_zte : public ::testing::Test
14 TEST_F(Test_nmea_zte, contruction)
16 EXPECT_NO_THROW(nmea::zte zte);
19 TEST_F(Test_nmea_zte, properties)
21 nmea_sentence_traits<nmea::zte>();
24 TEST_F(Test_nmea_zte, parse)
26 auto s = nmea::make_sentence("$GPZTE,123456.1,000010,POINT1*14");
27 ASSERT_NE(nullptr, s);
29 auto zte = nmea::sentence_cast<nmea::zte>(s);
30 ASSERT_NE(nullptr, zte);
32 EXPECT_EQ(nmea::time(12, 34, 56, 100), zte->get_time_utc());
33 EXPECT_EQ(nmea::duration(0, 0, 10), zte->get_time_remaining());
34 EXPECT_STREQ("POINT1", zte->get_waypoint_id().c_str());
37 TEST_F(Test_nmea_zte, parse_invalid_number_of_arguments)
39 EXPECT_ANY_THROW(
40 nmea::detail::factory::sentence_parse<nmea::zte>(nmea::talker::none, {2, "@"}));
41 EXPECT_ANY_THROW(
42 nmea::detail::factory::sentence_parse<nmea::zte>(nmea::talker::none, {4, "@"}));
45 TEST_F(Test_nmea_zte, empty_to_string)
47 nmea::zte zte;
49 EXPECT_STREQ("$GPZTE,000000,000000,*70", nmea::to_string(zte).c_str());
52 TEST_F(Test_nmea_zte, set_time_utc)
54 nmea::zte zte;
55 zte.set_time_utc(nmea::time{12, 34, 56});
57 EXPECT_STREQ("$GPZTE,123456,000000,*77", nmea::to_string(zte).c_str());
60 TEST_F(Test_nmea_zte, set_time_remaining)
62 nmea::zte zte;
63 zte.set_time_remaining(nmea::duration{12, 34, 56});
65 EXPECT_STREQ("$GPZTE,000000,123456,*77", nmea::to_string(zte).c_str());
68 TEST_F(Test_nmea_zte, set_waypoint_id)
70 nmea::zte zte;
71 zte.set_waypoint_id(nmea::waypoint{"POINT1"});
73 EXPECT_STREQ("$GPZTE,000000,000000,POINT1*0D", nmea::to_string(zte).c_str());