8#include "testing/testing.h"
14TEST(vector_set, DefaultConstructor)
21TEST(vector_set, InitializerListConstructor_WithoutDuplicates)
28 VectorSet<int> set_bigger_than_inline = {1, 4, 5, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19};
36TEST(vector_set, InitializerListConstructor_WithDuplicates)
56TEST(vector_set, CopyAssignment)
83TEST(vector_set, MoveNonInline)
85 VectorSet<int> set1 = {1, 2, 3, 5, 1, 6, 7, 8, 1, 4, 57, 8, 7, 34, 57, 8, 1231};
91TEST(vector_set, MoveAssignment)
95 set2 = std::move(set1);
100TEST(vector_set, AddNewIncreasesSize)
110TEST(vector_set, AddExistingDoesNotIncreaseSize)
114 EXPECT_TRUE(set.
add(5));
116 EXPECT_FALSE(set.
add(5));
137TEST(vector_set, RemoveContained)
170TEST(vector_set, AddMultipleTimes)
173 for (
int i = 0;
i < 100;
i++) {
181TEST(vector_set, UniquePtrValue)
184 set.
add_new(std::make_unique<int>());
185 set.
add(std::make_unique<int>());
187 std::unique_ptr<int> value = set.
pop();
194 EXPECT_TRUE(set.
add(5));
196 EXPECT_FALSE(set.
remove(6));
198 EXPECT_TRUE(set.
remove(5));
200 EXPECT_FALSE(set.
remove(5));
204TEST(vector_set, SpanConstructorExceptions)
206 std::array<ExceptionThrower, 5>
array = {1, 2, 3, 4, 5};
207 array[3].throw_during_copy =
true;
213TEST(vector_set, CopyConstructorExceptions)
216 set[3].throw_during_copy =
true;
221TEST(vector_set, MoveConstructorExceptions)
224 set[3].throw_during_copy =
true;
225 set[3].throw_during_move =
true;
233TEST(vector_set, AddNewExceptions)
238 EXPECT_ANY_THROW({ set.
add_new(value); });
240 EXPECT_ANY_THROW({ set.
add_new(value); });
249 EXPECT_ANY_THROW({ set.
add(value); });
251 EXPECT_ANY_THROW({ set.
add(value); });
255TEST(vector_set, ReserveExceptions)
259 set[2].throw_during_move =
true;
260 EXPECT_ANY_THROW({ set.
reserve(100); });
266 set.
as_span().last().throw_during_move =
true;
268 EXPECT_ANY_THROW({ set.
pop(); });
330 const int *data_ptr = set.
data();
338TEST(vector_set, ExtractVectorInline)
350TEST(vector_set, ExtractVectorInlineExceptions)
354 set[3].throw_during_copy =
true;
355 set[3].throw_during_move =
true;
362TEST(vector_set, ExtractVectorEmpty)
383 set.
add_new(ThingWithID{0,
"test", 54});
385 set.
add_new(ThingWithID{4333,
"other", 2});
387 set.
add(ThingWithID{3333,
"test", 27});
392 larger_set.
add_new(ThingWithID{12,
"test", 9});
394 larger_set.
add_new(ThingWithID{123,
"other", 8});
395 larger_set.
add(ThingWithID{1234,
"test", 7});
396 larger_set.
add_new(ThingWithID{12345,
"test_2", 6});
397 larger_set.
add_new(ThingWithID{123456,
"test_4", 5});
398 larger_set.
add_new(ThingWithID{1234567,
"test_5", 4});
400 larger_set.
add_new(ThingWithID{12345678,
"test_6", 3});
401 EXPECT_TRUE(larger_set.
size() == 6);
404TEST(vector_set, CustomIDVectorSetMove)
419 set.
add(std::make_unique<ThingWithID>(ThingWithID{1,
"hug", 2}));
420 set.
add(std::make_unique<ThingWithID>(ThingWithID{2,
"a", 2}));
421 set.
add(std::make_unique<ThingWithID>(ThingWithID{3,
"bug", 4}));
422 auto set_new = std::move(set);
432 KeyWithData(
int key, std::string
data) : key(key),
data(
data) {}
440 friend bool operator==(
const KeyWithData &a,
const KeyWithData &
b)
442 return a.key ==
b.key;
453 EXPECT_FALSE(set.
add(KeyWithData{1,
"b"}));
462 const KeyWithData key{2,
"d"};
473 EXPECT_TRUE(set.
add(KeyWithData{1,
"b"}));
474 EXPECT_TRUE(set.
add(KeyWithData{423,
"s"}));
475 EXPECT_TRUE(set.
add(KeyWithData{2,
"t"}));
476 KeyWithData default_key{1,
"default"};
478 KeyWithData other_s{0,
"testing"};
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
BMesh const char void * data
unsigned long long int uint64_t
int64_t index_of_try(const Key &key) const
const Key & lookup_key_as(const ForwardKey &key) const
bool contains_as(const ForwardKey &key) const
bool remove(const Key &key)
int64_t index_of_as(const ForwardKey &key) const
const Key * lookup_key_ptr(const Key &key) const
int64_t index_of_or_add(const Key &key)
const Key & lookup_key(const Key &key) const
const Key * lookup_key_ptr_as(const ForwardKey &key) const
Key lookup_key_default(const Key &key, const Key &default_value) const
void reserve(const int64_t n)
void add_multiple(Span< Key > keys)
bool add_overwrite(const Key &key)
int64_t index_of(const Key &key) const
bool contains(const Key &key) const
int64_t remove_if(Predicate &&predicate)
Span< Key > as_span() const
void add_new(const Key &key)
void remove_contained(const Key &key)
static bool operator==(const Type1 &a, const Type1 &b)
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet