14#include "testing/testing.h"
18TEST(bit_span, DefaultConstructor)
22 memset(buffer, 0xff,
sizeof(
BitSpan));
42 for (
const BitRef bit : span) {
76 for ([[maybe_unused]]
const int bit_index :
iter_1_indices(data2)) {
83TEST(bit_span, MutableIteration)
90 bit.set(
index % 4 == 0);
94 0b0000'0000'0000'0000'0000'0000'0001'0001'0001'0001'0001'0001'0001'0001'0001'0001);
97TEST(bit_span, SubscriptOperator)
110 mutable_span[5].set(
true);
116 mutable_span[120].set(
true);
121 0b0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0010'0000);
123 0b0000'0001'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000);
126TEST(bit_span, RangeConstructor)
134 mutable_span[0].set(
true);
135 mutable_span[1].set(
true);
136 mutable_span[2].set(
true);
137 mutable_span[0].set(
false);
138 mutable_span[2].set(
false);
143 0b0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0010'0000);
156 0b0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'1111'1111'0000);
160 0b0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'0000'1111'0000);
171 std::array<uint64_t, 10>
data;
172 memset(
data.data(), 0,
sizeof(
data));
183 EXPECT_EQ(span[i], (i >= 5 && i < 10) || (i >= 200 && i < 505));
189 std::array<uint64_t, 10>
data;
216 std::array<uint64_t, 30> src_data;
222 const BitSpan src(src_data.data(), src_data.size() * BitsPerInt);
224 std::array<uint64_t, 4> dst_data;
236 std::array<uint64_t, 100> data_1;
239 span_1[i].set(i % 2 == 0);
242 std::array<uint64_t, 100> data_2;
245 span_2[i].set(i % 2 != 0);
256 std::array<uint64_t, 100> data_1{};
259 span_1[i].set(i % 2 == 0);
262 std::array<uint64_t, 100> data_2{};
265 span_2[i].set(i % 2 != 0);
276 std::array<uint64_t, 2>
data{};
278 for (
const int i : {1, 28, 37, 86}) {
283 foreach_1_index(span.
slice({4, span.size() - 4}), [&](
const int i) { indices_test.append(i); });
364 [](
const BitInt a,
const BitInt b) {
return a ^
b; }, vec_a, vec_b),
418TEST(bit_span, to_index_ranges_small)
436TEST(bit_span, to_index_ranges_all_ones)
constexpr IndexRange()=default
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
static constexpr IndexRange from_begin_end_inclusive(const int64_t begin, const int64_t last)
void append(const T &value)
Span< T > as_span() const
const BitInt * data() const
BitSpan slice(const IndexRange range) const
const IndexRange & bit_range() const
MutableBitSpan slice(const IndexRange range) const
const IndexRange & bit_range() const
IndexRange index_range() const
void copy_from(const BitSpan other)
#define EXPECT_FALSE(result)
#define EXPECT_TRUE(result)
TEST(bit_group_vector, DefaultConstruct)
bool or_bools_into_bits(Span< bool > bools, MutableBitSpan r_bits, int64_t allowed_overshoot=0)
std::optional< int64_t > find_first_1_index_expr(ExprFn &&Expr, const FirstBitSpanT &first_arg, const BitSpanT &...args)
OneBitIteratorRange iter_1_indices(BitInt value)
void bits_to_index_ranges(const BitSpan bits, IndexRangesBuilder< IntT > &builder)
bool is_bounded_span(const BitSpan span)
std::optional< int64_t > find_first_0_index(const BitSpanT &data)
void foreach_1_index(const BitSpanT &data, Fn &&fn)
std::optional< int64_t > find_first_1_index(const BitSpanT &data)
unsigned __int64 uint64_t
BMesh const char void * data
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)