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