Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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