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)
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();
204TEST(vector_set, OrderPreservation)
206 Vector<int> ref_vec = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
230 for (
int i = 10; i < 1000; i++) {
236TEST(vector_set, SpanConstructorExceptions)
238 std::array<ExceptionThrower, 5>
array = {1, 2, 3, 4, 5};
239 array[3].throw_during_copy =
true;
245TEST(vector_set, CopyConstructorExceptions)
248 set[3].throw_during_copy =
true;
253TEST(vector_set, MoveConstructorExceptions)
256 set[3].throw_during_copy =
true;
257 set[3].throw_during_move =
true;
265TEST(vector_set, AddNewExceptions)
270 EXPECT_ANY_THROW({ set.
add_new(value); });
272 EXPECT_ANY_THROW({ set.
add_new(value); });
281 EXPECT_ANY_THROW({ set.
add(value); });
283 EXPECT_ANY_THROW({ set.
add(value); });
287TEST(vector_set, ReserveExceptions)
291 set[2].throw_during_move =
true;
292 EXPECT_ANY_THROW({ set.
reserve(100); });
298 set.
as_span().last().throw_during_move =
true;
300 EXPECT_ANY_THROW({ set.
pop(); });
362 const int *data_ptr = set.
data();
370TEST(vector_set, ExtractVectorInline)
382TEST(vector_set, ExtractVectorInlineExceptions)
386 set[3].throw_during_copy =
true;
387 set[3].throw_during_move =
true;
394TEST(vector_set, ExtractVectorEmpty)
415 set.
add_new(ThingWithID{0,
"test", 54});
417 set.
add_new(ThingWithID{4333,
"other", 2});
419 set.
add(ThingWithID{3333,
"test", 27});
424 larger_set.
add_new(ThingWithID{12,
"test", 9});
426 larger_set.
add_new(ThingWithID{123,
"other", 8});
427 larger_set.
add(ThingWithID{1234,
"test", 7});
428 larger_set.
add_new(ThingWithID{12345,
"test_2", 6});
429 larger_set.
add_new(ThingWithID{123456,
"test_4", 5});
430 larger_set.
add_new(ThingWithID{1234567,
"test_5", 4});
432 larger_set.
add_new(ThingWithID{12345678,
"test_6", 3});
436TEST(vector_set, CustomIDVectorSetMove)
451 set.
add(std::make_unique<ThingWithID>(ThingWithID{1,
"hug", 2}));
452 set.
add(std::make_unique<ThingWithID>(ThingWithID{2,
"a", 2}));
453 set.
add(std::make_unique<ThingWithID>(ThingWithID{3,
"bug", 4}));
454 auto set_new = std::move(set);
464 KeyWithData(
int key, std::string
data) : key(key),
data(
data) {}
465 KeyWithData(
const StringRef
data) : key(0),
data(
data) {}
472 friend bool operator==(
const KeyWithData &a,
const KeyWithData &
b)
474 return a.key ==
b.key;
494 const KeyWithData key{2,
"d"};
508 KeyWithData default_key{1,
"default"};
510 KeyWithData other_s{0,
"testing"};
constexpr IndexRange()=default
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)
Span< T > as_span() const
#define EXPECT_FALSE(result)
#define EXPECT_NE(result, expect)
#define EXPECT_TRUE(result)
bool operator==(const Error &left, const Error &right)
TEST(any_virtual, DefaultConstructor)
unsigned __int64 uint64_t
BMesh const char void * data
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)