General: separation of marav-io as a library
[marnav.git] / test / marnav / nmea / Test_nmea_zda.cpp
blob9097e6164f4cf32ab7deb146aef0d2a61c504595
1 #include <marnav/nmea/zda.hpp>
2 #include "type_traits_helper.hpp"
3 #include <marnav/nmea/nmea.hpp>
4 #include <gtest/gtest.h>
6 namespace
9 using namespace marnav;
11 class Test_nmea_zda : public ::testing::Test
15 TEST_F(Test_nmea_zda, contruction)
17 EXPECT_NO_THROW(nmea::zda zda);
20 TEST_F(Test_nmea_zda, properties)
22 nmea_sentence_traits<nmea::zda>();
25 TEST_F(Test_nmea_zda, parse)
27 auto s = nmea::make_sentence("$GPZDA,160012.71,11,03,2004,-1,00*7D");
28 ASSERT_NE(nullptr, s);
30 auto zda = nmea::sentence_cast<nmea::zda>(s);
31 ASSERT_NE(nullptr, zda);
34 TEST_F(Test_nmea_zda, parse_invalid_number_of_arguments)
36 EXPECT_ANY_THROW(
37 nmea::detail::factory::sentence_parse<nmea::zda>(nmea::talker::none, {5, "@"}));
38 EXPECT_ANY_THROW(
39 nmea::detail::factory::sentence_parse<nmea::zda>(nmea::talker::none, {7, "@"}));
42 TEST_F(Test_nmea_zda, empty_to_string)
44 nmea::zda zda;
46 EXPECT_STREQ("$GPZDA,,,,,,*48", nmea::to_string(zda).c_str());
49 TEST_F(Test_nmea_zda, set_time_utc)
51 nmea::zda zda;
52 zda.set_time_utc(nmea::time{1, 2, 3});
54 EXPECT_STREQ("$GPZDA,010203,,,,,*48", nmea::to_string(zda).c_str());
57 TEST_F(Test_nmea_zda, set_date)
59 nmea::zda zda;
60 zda.set_date(nmea::date{2015, nmea::month::june, 28});
62 EXPECT_STREQ("$GPZDA,,28,06,2015,,*42", nmea::to_string(zda).c_str());
65 TEST_F(Test_nmea_zda, set_local_zone)
67 nmea::zda zda;
68 zda.set_local_zone(10, 0);
70 EXPECT_STREQ("$GPZDA,,,,,10,00*49", nmea::to_string(zda).c_str());