Skip to content

Commit

Permalink
[#490] Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
orecham committed Nov 7, 2024
1 parent 9a25cbc commit b353e0a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions iceoryx2-ffi/cxx/tests/src/slice_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "iox/slice.hpp"
#include "test.hpp"

#include <array>

namespace {

struct DummyData {
Expand All @@ -27,25 +29,25 @@ TEST(SliceTest, const_correctness_is_maintained) {

auto elements = std::array<DummyData, SLICE_MAX_LENGTH> {};

auto mutable_slice = iox::MutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
auto mutable_slice = iox::MutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(mutable_slice.begin())>>);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(mutable_slice.end())>>);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(mutable_slice.data())>>);
ASSERT_FALSE(std::is_const_v<std::remove_reference_t<decltype(mutable_slice[0])>>);

const auto const_mutable_slice = iox::MutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
const auto const_mutable_slice = iox::MutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(const_mutable_slice.begin())>>);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(const_mutable_slice.end())>>);
ASSERT_FALSE(std::is_const_v<std::remove_pointer_t<decltype(const_mutable_slice.data())>>);
ASSERT_FALSE(std::is_const_v<std::remove_reference_t<decltype(const_mutable_slice[0])>>);

auto immutable_slice = iox::ImmutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
auto immutable_slice = iox::ImmutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(immutable_slice.begin())>>);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(immutable_slice.end())>>);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(immutable_slice.data())>>);
ASSERT_TRUE(std::is_const_v<std::remove_reference_t<decltype(immutable_slice[0])>>);

const auto const_immutable_slice = iox::ImmutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
const auto const_immutable_slice = iox::ImmutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(const_immutable_slice.begin())>>);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(const_immutable_slice.end())>>);
ASSERT_TRUE(std::is_const_v<std::remove_pointer_t<decltype(const_immutable_slice.data())>>);
Expand All @@ -57,7 +59,7 @@ TEST(SliceTest, can_iterate_mutable_slice) {

auto elements = std::array<DummyData, SLICE_MAX_LENGTH> {};

auto mutable_slice = iox::MutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
auto mutable_slice = iox::MutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
auto iterations = 0;
for (auto element : mutable_slice) {
ASSERT_THAT(element.a, Eq(DummyData::DEFAULT_VALUE_A));
Expand All @@ -72,7 +74,7 @@ TEST(SliceTest, can_iterate_const_mutable_slice) {

auto elements = std::array<DummyData, SLICE_MAX_LENGTH> {};

const auto slice = iox::MutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
const auto slice = iox::MutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
auto iterations = 0;
for (auto element : slice) {
ASSERT_THAT(element.a, Eq(DummyData::DEFAULT_VALUE_A));
Expand All @@ -87,7 +89,7 @@ TEST(SliceTest, can_iterate_immutable_slice) {

auto elements = std::array<DummyData, SLICE_MAX_LENGTH> {};

auto slice = iox::ImmutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
auto slice = iox::ImmutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
auto iterations = 0;
for (auto element : slice) {
ASSERT_THAT(element.a, Eq(DummyData::DEFAULT_VALUE_A));
Expand All @@ -102,7 +104,7 @@ TEST(SliceTest, can_iterate_const_immutable_slice) {

auto elements = std::array<DummyData, SLICE_MAX_LENGTH> {};

const auto slice = iox::ImmutableSlice<DummyData>(elements.begin(), SLICE_MAX_LENGTH);
const auto slice = iox::ImmutableSlice<DummyData>(elements.data(), SLICE_MAX_LENGTH);
auto iterations = 0;
for (auto element : slice) {
ASSERT_THAT(element.a, Eq(DummyData::DEFAULT_VALUE_A));
Expand Down

0 comments on commit b353e0a

Please sign in to comment.