5#include "testing/testing.h"
18#define TESTFAIL(test) \
24 if (listbase->
first) {
25 const Link *prev, *link;
36 }
while ((
void)(prev = link), (link = link->
next));
43 }
while ((
void)(prev = link), (link = link->
prev));
60 while (*
string != 0) {
61 if (*
string == ch_src) {
70TEST(listbase, FindLinkOrIndex)
109TEST(listbase, FindLinkFromStringOrPointer)
112 TestLink *
next, *prev;
117 const char *
const link1_name =
"Link1";
118 const char *
const link2_name =
"Link2";
119 const void *
const link1_ptr =
nullptr;
120 const void *
const link2_ptr = link2_name;
122 const size_t name_offset =
offsetof(TestLink, name);
126 TestLink *link1 = (TestLink *)
MEM_callocN(
sizeof(TestLink),
"link1");
127 STRNCPY(link1->name, link1_name);
128 link1->ptr = link1_ptr;
129 TestLink *link2 = (TestLink *)
MEM_callocN(
sizeof(TestLink),
"link2");
130 STRNCPY(link2->name, link2_name);
131 link2->ptr = link2_ptr;
267 int i = strcmp(*(
const char **)a, *(
const char **)
b);
268 return (i > 0) ? 1 : (i < 0) ? -1 : 0;
275 int i = strcmp((
const char *)link_a->
data, (
const char *)link_b->
data);
276 return (i > 0) ? 1 : (i < 0) ? -1 : 0;
296 for (i = 0; i < arr_num; i++) {
297 if (!
STREQ(arr[i], (
char *)link_step->
data)) {
300 link_step = link_step->
next;
315 while (link_step && link_step->
next) {
317 if ((link_step < link_step->
next) != forward) {
321 link_step = link_step->
next;
328 const int words_len =
sizeof(
words10k) - 1;
340 words_arr = (
char **)
MEM_mallocN(
sizeof(*words_arr) * words_num, __func__);
342 words_linkdata_arr = (
LinkData *)
MEM_mallocN(
sizeof(*words_linkdata_arr) * words_num, __func__);
346 for (i = 0; i < words_num; i++) {
347 words_arr[i] = w_step;
348 w_step += strlen(w_step) + 1;
371 for (i = 0; i < words_num; i++) {
372 LinkData *link = &words_linkdata_arr[i];
375 w_step += strlen(w_step) + 1;
Generic array manipulation API.
#define BLI_array_reverse(arr, arr_len)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void * BLI_rfindlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void * BLI_findlinkfrom(struct Link *start, int step) ATTR_WARN_UNUSED_RESULT
void void void void void BLI_listbase_split_after(struct ListBase *original_listbase, struct ListBase *split_listbase, void *vlink) ATTR_NONNULL(1
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void void BLI_listbase_sort(struct ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_rfindptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_rfindstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void void void void void BLI_listbase_reverse(struct ListBase *lb) ATTR_NONNULL(1)
ListBase BLI_listbase_from_link(struct Link *some_link)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void * BLI_listbase_string_or_index_find(const struct ListBase *listbase, const char *string, size_t string_offset, int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static int testsort_listbase_str_cmp(const void *a, const void *b)
static int testsort_array_str_cmp(const void *a, const void *b)
static bool listbase_is_valid(const ListBase *listbase)
static bool testsort_listbase_array_str_cmp(ListBase *lb, char **arr, int arr_num)
static int testsort_array_str_cmp_reverse(const void *a, const void *b)
TEST(listbase, FindLinkOrIndex)
static int char_switch(char *string, char ch_src, char ch_dst)
static int testsort_listbase_str_cmp_reverse(const void *a, const void *b)
static bool testsort_listbase_sort_is_stable(ListBase *lb, bool forward)
#define STRNCPY(dst, src)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Read Guarded memory(de)allocation.
local_group_size(16, 16) .push_constant(Type b
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)