1 #include <gtest/gtest.h>
2 #include <marnav/nmea/time.hpp>
7 using namespace marnav
;
9 class Test_nmea_time
: public ::testing::Test
13 TEST_F(Test_nmea_time
, explicit_construction
)
15 EXPECT_ANY_THROW((nmea::time
{24, 0, 0, 0}));
16 EXPECT_ANY_THROW((nmea::time
{0, 60, 0, 0}));
17 EXPECT_ANY_THROW((nmea::time
{0, 0, 60, 0}));
18 EXPECT_ANY_THROW((nmea::time
{0, 0, 0, 1000}));
21 TEST_F(Test_nmea_time
, hour
)
23 nmea::time t
{1, 2, 3, 4};
25 EXPECT_EQ(1u, t
.hour());
28 TEST_F(Test_nmea_time
, minutes
)
30 nmea::time t
{1, 2, 3, 4};
32 EXPECT_EQ(2u, t
.minutes());
35 TEST_F(Test_nmea_time
, seconds
)
37 nmea::time t
{1, 2, 3, 4};
39 EXPECT_EQ(3u, t
.seconds());
42 TEST_F(Test_nmea_time
, milliseconds
)
44 nmea::time t
{1, 2, 3, 4};
46 EXPECT_EQ(4u, t
.milliseconds());
49 TEST_F(Test_nmea_time
, comparison_equal
)
51 nmea::time t0
{1, 2, 3, 4};
52 nmea::time t1
{1, 2, 3, 4};
54 EXPECT_TRUE(t0
== t1
);
57 TEST_F(Test_nmea_time
, invalid_format_for_double
)
59 EXPECT_ANY_THROW(nmea::time::parse("123.455.6"));
62 TEST_F(Test_nmea_time
, to_string
)
64 nmea::time t
{1, 2, 3, 4};
66 using namespace marnav::nmea
;
67 const std::string s
= to_string(t
);
69 EXPECT_STREQ("010203", s
.c_str());