Skip to content

Commit d06b5a9

Browse files
committed
iox-#1295 Fix Windows build
1 parent 0b6c557 commit d06b5a9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "iox/duration.hpp"
2121
#include "iox/posix_call.hpp"
2222
#include "test.hpp"
23+
#include <chrono>
2324
#include <ctime>
2425
#include <iostream>
2526
#include <limits>
@@ -102,7 +103,7 @@ TEST(Duration_test, ConstructDurationWithNanosecondsLessThanOneSecond)
102103
::testing::Test::RecordProperty("TEST_ID", "7de47e88-c4b3-4655-bdeb-3c51f3b34d3e");
103104
constexpr uint64_t SECONDS{37U};
104105
constexpr uint64_t NANOSECONDS{73U};
105-
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{SECONDS * NANOSECS_PER_SECOND + NANOSECONDS};
106+
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{(SECONDS * NANOSECS_PER_SECOND) + NANOSECONDS};
106107

107108
auto sut = createDuration(SECONDS, NANOSECONDS);
108109

@@ -127,7 +128,7 @@ TEST(Duration_test, ConstructDurationWithNanosecondsMoreThanOneSecond)
127128
constexpr uint64_t SECONDS{37U};
128129
constexpr uint64_t NANOSECONDS{42U};
129130
constexpr uint64_t MORE_THAN_ONE_SECOND_NANOSECONDS{NANOSECS_PER_SECOND + NANOSECONDS};
130-
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{(SECONDS + 1U) * NANOSECS_PER_SECOND + NANOSECONDS};
131+
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{((SECONDS + 1U) * NANOSECS_PER_SECOND) + NANOSECONDS};
131132

132133
auto sut = createDuration(SECONDS, MORE_THAN_ONE_SECOND_NANOSECONDS);
133134

@@ -139,9 +140,10 @@ TEST(Duration_test, ConstructDurationWithNanosecondsMaxValue)
139140
::testing::Test::RecordProperty("TEST_ID", "fe8152ca-cd14-4d99-aa68-0f56ab3007de");
140141
constexpr uint64_t SECONDS{37U};
141142
constexpr uint64_t MAX_NANOSECONDS_FOR_CTOR{std::numeric_limits<DurationAccessor::Nanoseconds_t>::max()};
142-
constexpr uint64_t EXPECTED_SECONDS = SECONDS + MAX_NANOSECONDS_FOR_CTOR / NANOSECS_PER_SECOND;
143+
constexpr uint64_t EXPECTED_SECONDS = SECONDS + (MAX_NANOSECONDS_FOR_CTOR / NANOSECS_PER_SECOND);
143144
constexpr uint64_t REMAINING_NANOSECONDS = MAX_NANOSECONDS_FOR_CTOR % NANOSECS_PER_SECOND;
144-
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{(EXPECTED_SECONDS)*NANOSECS_PER_SECOND + REMAINING_NANOSECONDS};
145+
constexpr uint64_t EXPECTED_DURATION_IN_NANOSECONDS{((EXPECTED_SECONDS)*NANOSECS_PER_SECOND)
146+
+ REMAINING_NANOSECONDS};
145147

146148
auto sut = createDuration(SECONDS, MAX_NANOSECONDS_FOR_CTOR);
147149

@@ -1156,7 +1158,7 @@ TEST(Duration_test, ConvertTimevalFromDurationWithLessThanOneSecond)
11561158
constexpr int64_t MICROSECONDS{222};
11571159
constexpr int64_t ROUND_OFF_NANOSECONDS{666};
11581160

1159-
auto duration = createDuration(SECONDS, MICROSECONDS * NANOSECS_PER_MICROSECOND + ROUND_OFF_NANOSECONDS);
1161+
auto duration = createDuration(SECONDS, (MICROSECONDS * NANOSECS_PER_MICROSECOND) + ROUND_OFF_NANOSECONDS);
11601162

11611163
const timeval sut = duration.timeval();
11621164

@@ -1171,7 +1173,7 @@ TEST(Duration_test, ConvertTimevalFromDurationWithMoreThanOneSecond)
11711173
constexpr int64_t MICROSECONDS{222};
11721174
constexpr int64_t ROUND_OFF_NANOSECONDS{666};
11731175

1174-
auto duration = createDuration(SECONDS, MICROSECONDS * NANOSECS_PER_MICROSECOND + ROUND_OFF_NANOSECONDS);
1176+
auto duration = createDuration(SECONDS, (MICROSECONDS * NANOSECS_PER_MICROSECOND) + ROUND_OFF_NANOSECONDS);
11751177

11761178
const timeval sut = duration.timeval();
11771179

@@ -1428,7 +1430,7 @@ TEST(Duration_test, AddDurationWithOneZeroDurationsResultsInNoneZeroDuration)
14281430
TEST(Duration_test, AddDurationWithSumOfDurationsLessThanOneSecondsResultsInLessThanOneSecond)
14291431
{
14301432
::testing::Test::RecordProperty("TEST_ID", "b3704e3c-588a-4c1f-a09b-9244c210d853");
1431-
constexpr Duration EXPECTED_DURATION = createDuration(0U, 100 * NANOSECS_PER_MICROSECOND + 10U);
1433+
constexpr Duration EXPECTED_DURATION = createDuration(0U, (100 * NANOSECS_PER_MICROSECOND) + 10U);
14321434
const auto duration1 = 100_us;
14331435
const auto duration2 = 10_ns;
14341436

@@ -1981,7 +1983,7 @@ TEST(Duration_test, MultiplyDurationWithNegativMultiplicatorResultsInZero)
19811983
TEST(Duration_test, MultiplyDurationLessThanOneSecondResultsInMoreNanosecondsThan64BitCanRepresent)
19821984
{
19831985
::testing::Test::RecordProperty("TEST_ID", "2f1bbcb3-3692-4895-a36f-38eed7775b6f");
1984-
constexpr uint64_t MULTIPLICATOR{(1ULL << 32U) * 42U + 73U};
1986+
constexpr uint64_t MULTIPLICATOR{((1ULL << 32U) * 42U) + 73U};
19851987
constexpr Duration DURATION = 473_ms + 578_us + 511_ns;
19861988
const auto EXPECTED_RESULT = createDuration(85428177141U, 573034055U);
19871989

0 commit comments

Comments
 (0)