Skip to content

Commit

Permalink
Fix ambiguous constructor (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
solidpixel authored Jan 24, 2025
1 parent 44c0fa5 commit e4cfb55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hwcpipe/include/hwcpipe/sampler.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2024 Arm Limited.
* Copyright (c) 2023-2025 Arm Limited.
*
* SPDX-License-Identifier: MIT
*/
Expand Down Expand Up @@ -75,7 +75,7 @@ struct counter_sample {

/** Default constructor */
counter_sample()
: counter_sample(hwcpipe_counter(), 0, 0UL) {}
: counter_sample(hwcpipe_counter(), 0, static_cast<uint64_t>(0UL)) {}
};

/**
Expand Down
16 changes: 13 additions & 3 deletions test/counter-sampler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2024 Arm Limited.
* Copyright (c) 2023-2025 Arm Limited.
*
* SPDX-License-Identifier: MIT
*/
Expand Down Expand Up @@ -44,12 +44,22 @@ struct hwcpipe_sampler_mock_policy {
using namespace hwcpipe::mock;
using sampler_t = hwcpipe::sampler<hwcpipe_sampler_mock_policy>;

TEST_CASE("counter_sampler__DefaultConstructor") {
SECTION("uint64") {
counter_sample sample;

REQUIRE(sample.timestamp == 0);
REQUIRE(sample.value.uint64 == static_cast<uint64_t>(0UL));
REQUIRE(sample.type == counter_sample::type::uint64);
}
}

TEST_CASE("counter_sampler__CorrectTypesAreAssigned") {
SECTION("uint64") {
counter_sample sample{hwcpipe_counter(), 0xbaadcafe, 42UL};
counter_sample sample{hwcpipe_counter(), 0xbaadcafe, static_cast<uint64_t>(42UL)};

REQUIRE(sample.timestamp == 0xbaadcafe);
REQUIRE(sample.value.uint64 == 42);
REQUIRE(sample.value.uint64 == static_cast<uint64_t>(42));
REQUIRE(sample.type == counter_sample::type::uint64);
}

Expand Down

0 comments on commit e4cfb55

Please sign in to comment.