Skip to content

Commit e4cfb55

Browse files
authored
Fix ambiguous constructor (#85)
1 parent 44c0fa5 commit e4cfb55

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

hwcpipe/include/hwcpipe/sampler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024 Arm Limited.
2+
* Copyright (c) 2023-2025 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*/
@@ -75,7 +75,7 @@ struct counter_sample {
7575

7676
/** Default constructor */
7777
counter_sample()
78-
: counter_sample(hwcpipe_counter(), 0, 0UL) {}
78+
: counter_sample(hwcpipe_counter(), 0, static_cast<uint64_t>(0UL)) {}
7979
};
8080

8181
/**

test/counter-sampler.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024 Arm Limited.
2+
* Copyright (c) 2023-2025 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*/
@@ -44,12 +44,22 @@ struct hwcpipe_sampler_mock_policy {
4444
using namespace hwcpipe::mock;
4545
using sampler_t = hwcpipe::sampler<hwcpipe_sampler_mock_policy>;
4646

47+
TEST_CASE("counter_sampler__DefaultConstructor") {
48+
SECTION("uint64") {
49+
counter_sample sample;
50+
51+
REQUIRE(sample.timestamp == 0);
52+
REQUIRE(sample.value.uint64 == static_cast<uint64_t>(0UL));
53+
REQUIRE(sample.type == counter_sample::type::uint64);
54+
}
55+
}
56+
4757
TEST_CASE("counter_sampler__CorrectTypesAreAssigned") {
4858
SECTION("uint64") {
49-
counter_sample sample{hwcpipe_counter(), 0xbaadcafe, 42UL};
59+
counter_sample sample{hwcpipe_counter(), 0xbaadcafe, static_cast<uint64_t>(42UL)};
5060

5161
REQUIRE(sample.timestamp == 0xbaadcafe);
52-
REQUIRE(sample.value.uint64 == 42);
62+
REQUIRE(sample.value.uint64 == static_cast<uint64_t>(42));
5363
REQUIRE(sample.type == counter_sample::type::uint64);
5464
}
5565

0 commit comments

Comments
 (0)