Skip to content

Commit

Permalink
Fix float16
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-PLACET committed Apr 15, 2024
1 parent 029814e commit dc18441
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions test/test_typed_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <algorithm>
#include <compare>
#include <cstdint>
#include <iostream> // For Doctest
#include <numeric>
#include <string>
Expand All @@ -36,21 +37,12 @@ namespace
{
ad.bitmap.set(9, false);
}
size_t buffer_size = (n * sizeof(T)) / sizeof(uint8_t);
const size_t buffer_size = (n * sizeof(T)) / sizeof(uint8_t);
buffer<uint8_t> b(buffer_size);
if constexpr (std::is_same_v<T, bool>)
for (uint8_t i = 0; i < n; ++i)
{
std::fill(b.data<T>(), b.data<T>() + n, 0x01);
if (n > 0)
{
b.data<T>()[0] = 0x00;
}
}
else
{
std::iota(b.data<T>(), b.data<T>() + n, static_cast<T>(0));
b.data<T>()[i] = static_cast<T>(i);
}

ad.buffers.push_back(b);
ad.length = n;
ad.offset = offset;
Expand Down Expand Up @@ -139,6 +131,8 @@ TEST_SUITE("typed_array")
const auto array_data = make_test_array_data<T>(10, 1);
typed_array<T> typed_array(array_data);
CHECK_EQ(typed_array.size(), 9);
// CHECK_EQ(typed_array.at(0), 1);

}

SUBCASE("at")
Expand All @@ -147,7 +141,8 @@ TEST_SUITE("typed_array")
typed_array<T> typed_array(array_data);
for (typename ::typed_array<T>::size_type i = 0; i < typed_array.size() - 1; ++i)
{
CHECK_EQ(typed_array.at(i).value(), to_value_type<T>(i + 1));
const T value = to_value_type<T>(i + 1);
CHECK_EQ(typed_array.at(i).value(), value);
}
CHECK_FALSE(typed_array.at(typed_array.size() - 1).has_value());

Expand Down

0 comments on commit dc18441

Please sign in to comment.