Skip to content

Commit

Permalink
Use SparrowAssert instead of cassert
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-PLACET committed Apr 19, 2024
1 parent 624d6d2 commit 3f8794b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions include/sparrow/typed_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@

#include "sparrow/algorithm.hpp"
#include "sparrow/array_data.hpp"
#include "sparrow/contracts.hpp"
#include "sparrow/data_traits.hpp"
#include "sparrow/data_type.hpp"

#if !defined(COMPILING_WITH_APPLE_CLANG)
#include <format>
#endif

namespace sparrow
{
template <class T, class L>
Expand Down Expand Up @@ -232,47 +228,47 @@ namespace sparrow
requires is_arrow_base_type<T>
auto typed_array<T, L>::operator[](size_type i) -> reference
{
assert(i < size());
SPARROW_ASSERT_TRUE(i < size());
return m_layout[i];
}

template <class T, class L>
requires is_arrow_base_type<T>
auto typed_array<T, L>::operator[](size_type i) const -> const_reference
{
assert(i < size());
SPARROW_ASSERT_TRUE(i < size());
return m_layout[i];
}

template <class T, class L>
requires is_arrow_base_type<T>
auto typed_array<T, L>::front() -> reference
{
assert(!empty());
SPARROW_ASSERT_FALSE(empty());
return m_layout[0];
}

template <class T, class L>
requires is_arrow_base_type<T>
auto typed_array<T, L>::front() const -> const_reference
{
assert(!empty());
SPARROW_ASSERT_FALSE(empty());
return m_layout[0];
}

template <class T, class L>
requires is_arrow_base_type<T>
auto typed_array<T, L>::back() -> reference
{
assert(!empty());
SPARROW_ASSERT_FALSE(empty());
return m_layout[size() - 1];
}

template <class T, class L>
requires is_arrow_base_type<T>
auto typed_array<T, L>::back() const -> const_reference
{
assert(!empty());
SPARROW_ASSERT_FALSE(empty());
return m_layout[size() - 1];
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_typed_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ TEST_SUITE("typed_array")
const typed_array<T> ta{array_data};

auto iter = ta.cbegin();
assert(std::is_const_v<typename std::remove_reference_t<decltype(iter->value())>>);
CHECK(std::is_const_v<typename std::remove_reference_t<decltype(iter->value())>>);
auto iter_bis = ta.begin();
CHECK(std::is_const_v<typename std::remove_reference_t<decltype(iter_bis->value())>>);
CHECK_EQ(iter, iter_bis);
Expand Down

0 comments on commit 3f8794b

Please sign in to comment.