Blender  V3.3
Classes | Macros | Functions
BLI_array_store_test.cc File Reference
#include "testing/testing.h"
#include "MEM_guardedalloc.h"
#include "BLI_array_store.h"
#include "BLI_array_utils.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
#include "BLI_ressource_strings.h"
#include "BLI_string.h"
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Classes

struct  TestChunk
 
struct  TestBuffer
 

Macros

#define testbuffer_list_state_from_string_array(lb, data_array)
 
#define TESTBUFFER_STRINGS_CREATE(lb, ...)
 
#define TESTBUFFER_STRINGS(stride, chunk_count, ...)
 
#define D   "#1#2#3#4"
 
#define WORDS   words10k, sizeof(words10k)
 

Functions

static TestChunktestchunk_list_add (ListBase *lb, const void *data, size_t data_len)
 
static void testchunk_list_free (ListBase *lb)
 
static char * testchunk_as_data_array (TestChunk **tc_array, int tc_array_len, size_t *r_data_len)
 
static TestBuffertestbuffer_list_add (ListBase *lb, const void *data, size_t data_len)
 
static TestBuffertestbuffer_list_add_copydata (ListBase *lb, const void *data, size_t data_len)
 
static void testbuffer_list_state_from_data (ListBase *lb, const char *data, const size_t data_len)
 
static void testbuffer_list_state_from_data__stride_expand (ListBase *lb, const char *data, const size_t data_len, const size_t stride)
 
static bool testbuffer_item_validate (TestBuffer *tb)
 
static bool testbuffer_list_validate (const ListBase *lb)
 
static void testbuffer_list_data_randomize (ListBase *lb, unsigned int random_seed)
 
static void testbuffer_list_store_populate (BArrayStore *bs, ListBase *lb)
 
static void testbuffer_list_store_clear (BArrayStore *bs, ListBase *lb)
 
static void testbuffer_list_free (ListBase *lb)
 
static void testbuffer_run_tests_single (BArrayStore *bs, ListBase *lb)
 
static void testbuffer_run_tests (BArrayStore *bs, ListBase *lb)
 
static void testbuffer_run_tests_simple (ListBase *lb, const int stride, const int chunk_count)
 
 TEST (array_store, Nop)
 
 TEST (array_store, NopState)
 
 TEST (array_store, Single)
 
 TEST (array_store, DoubleNop)
 
 TEST (array_store, DoubleDiff)
 
 TEST (array_store, TextMixed)
 
 TEST (array_store, TextDupeIncreaseDecrease)
 
static void plain_text_helper (const char *words, int words_len, const char word_delim, const int stride, const int chunk_count, const int random_seed)
 
 TEST (array_store, TextSentences_Chunk1)
 
 TEST (array_store, TextSentences_Chunk2)
 
 TEST (array_store, TextSentences_Chunk8)
 
 TEST (array_store, TextSentences_Chunk32)
 
 TEST (array_store, TextSentences_Chunk128)
 
 TEST (array_store, TextSentences_Chunk1024)
 
 TEST (array_store, TextSentences_Chunk3)
 
 TEST (array_store, TextSentences_Chunk13)
 
 TEST (array_store, TextSentences_Chunk131)
 
 TEST (array_store, TextWords_Chunk1)
 
 TEST (array_store, TextWords_Chunk2)
 
 TEST (array_store, TextWords_Chunk8)
 
 TEST (array_store, TextWords_Chunk32)
 
 TEST (array_store, TextWords_Chunk128)
 
 TEST (array_store, TextWords_Chunk1024)
 
 TEST (array_store, TextWords_Chunk3)
 
 TEST (array_store, TextWords_Chunk13)
 
 TEST (array_store, TextWords_Chunk131)
 
 TEST (array_store, TextSentencesRandom_Stride3_Chunk3)
 
 TEST (array_store, TextSentencesRandom_Stride8_Chunk8)
 
 TEST (array_store, TextSentencesRandom_Stride32_Chunk1)
 
 TEST (array_store, TextSentencesRandom_Stride12_Chunk512)
 
 TEST (array_store, TextSentencesRandom_Stride128_Chunk6)
 
static unsigned int rand_range_i (RNG *rng, unsigned int min_i, unsigned int max_i, unsigned int step)
 
static void testbuffer_list_state_random_data (ListBase *lb, const size_t stride, const size_t data_min_len, const size_t data_max_len, const unsigned int mutate, RNG *rng)
 
static void random_data_mutate_helper (const int items_size_min, const int items_size_max, const int items_total, const int stride, const int chunk_count, const int random_seed, const int mutate)
 
 TEST (array_store, TestData_Stride1_Chunk32_Mutate2)
 
 TEST (array_store, TestData_Stride8_Chunk512_Mutate2)
 
 TEST (array_store, TestData_Stride12_Chunk48_Mutate2)
 
 TEST (array_store, TestData_Stride32_Chunk64_Mutate1)
 
 TEST (array_store, TestData_Stride32_Chunk64_Mutate8)
 
static void random_chunk_generate (ListBase *lb, const int chunks_per_buffer, const int stride, const int chunk_count, const int random_seed)
 
static void random_chunk_mutate_helper (const int chunks_per_buffer, const int items_total, const int stride, const int chunk_count, const int random_seed)
 
 TEST (array_store, TestChunk_Rand8_Stride1_Chunk64)
 
 TEST (array_store, TestChunk_Rand32_Stride1_Chunk64)
 
 TEST (array_store, TestChunk_Rand64_Stride8_Chunk32)
 
 TEST (array_store, TestChunk_Rand31_Stride11_Chunk21)
 

Macro Definition Documentation

◆ D

#define D   "#1#2#3#4"

◆ testbuffer_list_state_from_string_array

#define testbuffer_list_state_from_string_array (   lb,
  data_array 
)
Value:
{ \
unsigned int i_ = 0; \
const char *data; \
while ((data = data_array[i_++])) { \
testbuffer_list_state_from_data(lb, data, strlen(data)); \
} \
} \
((void)0)
SyclQueue void void size_t num_bytes void

Definition at line 169 of file BLI_array_store_test.cc.

◆ TESTBUFFER_STRINGS

#define TESTBUFFER_STRINGS (   stride,
  chunk_count,
  ... 
)
Value:
{ \
ListBase lb; \
TESTBUFFER_STRINGS_CREATE(&lb, __VA_ARGS__); \
} \
((void)0)
static void testbuffer_run_tests_simple(ListBase *lb, const int stride, const int chunk_count)
static void testbuffer_list_free(ListBase *lb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride

Definition at line 190 of file BLI_array_store_test.cc.

◆ TESTBUFFER_STRINGS_CREATE

#define TESTBUFFER_STRINGS_CREATE (   lb,
  ... 
)
Value:
{ \
BLI_listbase_clear(lb); \
const char *data_array[] = {__VA_ARGS__ NULL}; \
testbuffer_list_state_from_string_array((lb), data_array); \
} \
((void)0)

Definition at line 181 of file BLI_array_store_test.cc.

◆ WORDS

#define WORDS   words10k, sizeof(words10k)

Definition at line 454 of file BLI_array_store_test.cc.

Function Documentation

◆ plain_text_helper()

static void plain_text_helper ( const char *  words,
int  words_len,
const char  word_delim,
const int  stride,
const int  chunk_count,
const int  random_seed 
)
static

Test that uses text input with different params for the array-store to ensure no corner cases fail.

Definition at line 424 of file BLI_array_store_test.cc.

References BLI_listbase_clear(), ELEM, stride, testbuffer_list_data_randomize(), testbuffer_list_free(), testbuffer_list_state_from_data__stride_expand(), and testbuffer_run_tests_simple().

Referenced by TEST().

◆ rand_range_i()

static unsigned int rand_range_i ( RNG rng,
unsigned int  min_i,
unsigned int  max_i,
unsigned int  step 
)
static

Definition at line 559 of file BLI_array_store_test.cc.

References BLI_assert, BLI_rng_get_uint(), max_i(), and min_i().

Referenced by testbuffer_list_state_random_data().

◆ random_chunk_generate()

static void random_chunk_generate ( ListBase lb,
const int  chunks_per_buffer,
const int  stride,
const int  chunk_count,
const int  random_seed 
)
static

◆ random_chunk_mutate_helper()

static void random_chunk_mutate_helper ( const int  chunks_per_buffer,
const int  items_total,
const int  stride,
const int  chunk_count,
const int  random_seed 
)
static

◆ random_data_mutate_helper()

static void random_data_mutate_helper ( const int  items_size_min,
const int  items_size_max,
const int  items_total,
const int  stride,
const int  chunk_count,
const int  random_seed,
const int  mutate 
)
static

◆ TEST() [1/39]

TEST ( array_store  ,
DoubleDiff   
)

◆ TEST() [2/39]

TEST ( array_store  ,
DoubleNop   
)

◆ TEST() [3/39]

TEST ( array_store  ,
Nop   
)

Definition at line 295 of file BLI_array_store_test.cc.

References BLI_array_store_create(), and BLI_array_store_destroy().

◆ TEST() [4/39]

TEST ( array_store  ,
NopState   
)

◆ TEST() [5/39]

TEST ( array_store  ,
Single   
)

◆ TEST() [6/39]

TEST ( array_store  ,
TestChunk_Rand31_Stride11_Chunk21   
)

Definition at line 788 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [7/39]

TEST ( array_store  ,
TestChunk_Rand32_Stride1_Chunk64   
)

Definition at line 780 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [8/39]

TEST ( array_store  ,
TestChunk_Rand64_Stride8_Chunk32   
)

Definition at line 784 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [9/39]

TEST ( array_store  ,
TestChunk_Rand8_Stride1_Chunk64   
)

Definition at line 776 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [10/39]

TEST ( array_store  ,
TestData_Stride12_Chunk48_Mutate2   
)

Definition at line 691 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [11/39]

TEST ( array_store  ,
TestData_Stride1_Chunk32_Mutate2   
)

Definition at line 683 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [12/39]

TEST ( array_store  ,
TestData_Stride32_Chunk64_Mutate1   
)

Definition at line 695 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [13/39]

TEST ( array_store  ,
TestData_Stride32_Chunk64_Mutate8   
)

Definition at line 699 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [14/39]

TEST ( array_store  ,
TestData_Stride8_Chunk512_Mutate2   
)

Definition at line 687 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [15/39]

TEST ( array_store  ,
TextDupeIncreaseDecrease   
)

◆ TEST() [16/39]

TEST ( array_store  ,
TextMixed   
)

Definition at line 376 of file BLI_array_store_test.cc.

References TESTBUFFER_STRINGS.

◆ TEST() [17/39]

TEST ( array_store  ,
TextSentences_Chunk1   
)

Definition at line 455 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [18/39]

TEST ( array_store  ,
TextSentences_Chunk1024   
)

Definition at line 475 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [19/39]

TEST ( array_store  ,
TextSentences_Chunk128   
)

Definition at line 471 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [20/39]

TEST ( array_store  ,
TextSentences_Chunk13   
)

Definition at line 484 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [21/39]

TEST ( array_store  ,
TextSentences_Chunk131   
)

Definition at line 488 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [22/39]

TEST ( array_store  ,
TextSentences_Chunk2   
)

Definition at line 459 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [23/39]

TEST ( array_store  ,
TextSentences_Chunk3   
)

Definition at line 480 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [24/39]

TEST ( array_store  ,
TextSentences_Chunk32   
)

Definition at line 467 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [25/39]

TEST ( array_store  ,
TextSentences_Chunk8   
)

Definition at line 463 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [26/39]

TEST ( array_store  ,
TextSentencesRandom_Stride128_Chunk6   
)

Definition at line 549 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [27/39]

TEST ( array_store  ,
TextSentencesRandom_Stride12_Chunk512   
)

Definition at line 545 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [28/39]

TEST ( array_store  ,
TextSentencesRandom_Stride32_Chunk1   
)

Definition at line 541 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [29/39]

TEST ( array_store  ,
TextSentencesRandom_Stride3_Chunk3   
)

Definition at line 533 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [30/39]

TEST ( array_store  ,
TextSentencesRandom_Stride8_Chunk8   
)

Definition at line 537 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [31/39]

TEST ( array_store  ,
TextWords_Chunk1   
)

Definition at line 494 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [32/39]

TEST ( array_store  ,
TextWords_Chunk1024   
)

Definition at line 514 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [33/39]

TEST ( array_store  ,
TextWords_Chunk128   
)

Definition at line 510 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [34/39]

TEST ( array_store  ,
TextWords_Chunk13   
)

Definition at line 523 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [35/39]

TEST ( array_store  ,
TextWords_Chunk131   
)

Definition at line 527 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [36/39]

TEST ( array_store  ,
TextWords_Chunk2   
)

Definition at line 498 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [37/39]

TEST ( array_store  ,
TextWords_Chunk3   
)

Definition at line 519 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [38/39]

TEST ( array_store  ,
TextWords_Chunk32   
)

Definition at line 506 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [39/39]

TEST ( array_store  ,
TextWords_Chunk8   
)

Definition at line 502 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ testbuffer_item_validate()

static bool testbuffer_item_validate ( TestBuffer tb)
static

◆ testbuffer_list_add()

static TestBuffer* testbuffer_list_add ( ListBase lb,
const void data,
size_t  data_len 
)
static

◆ testbuffer_list_add_copydata()

static TestBuffer* testbuffer_list_add_copydata ( ListBase lb,
const void data,
size_t  data_len 
)
static

◆ testbuffer_list_data_randomize()

static void testbuffer_list_data_randomize ( ListBase lb,
unsigned int  random_seed 
)
static

Definition at line 227 of file BLI_array_store_test.cc.

References BLI_array_randomize(), and ListBase::first.

Referenced by plain_text_helper().

◆ testbuffer_list_free()

static void testbuffer_list_free ( ListBase lb)
static

◆ testbuffer_list_state_from_data()

static void testbuffer_list_state_from_data ( ListBase lb,
const char *  data,
const size_t  data_len 
)
static

◆ testbuffer_list_state_from_data__stride_expand()

static void testbuffer_list_state_from_data__stride_expand ( ListBase lb,
const char *  data,
const size_t  data_len,
const size_t  stride 
)
static

A version of testbuffer_list_state_from_data that expand data by stride, handy so we can test data at different strides.

Definition at line 149 of file BLI_array_store_test.cc.

References data, TestBuffer::data_len, MEM_mallocN, stride, testbuffer_list_add(), and testbuffer_list_state_from_data().

Referenced by plain_text_helper().

◆ testbuffer_list_state_random_data()

static void testbuffer_list_state_random_data ( ListBase lb,
const size_t  stride,
const size_t  data_min_len,
const size_t  data_max_len,
const unsigned int  mutate,
RNG rng 
)
static

◆ testbuffer_list_store_clear()

static void testbuffer_list_store_clear ( BArrayStore bs,
ListBase lb 
)
static

Definition at line 243 of file BLI_array_store_test.cc.

References BLI_array_store_state_remove(), and ListBase::first.

Referenced by TEST(), and testbuffer_run_tests().

◆ testbuffer_list_store_populate()

static void testbuffer_list_store_populate ( BArrayStore bs,
ListBase lb 
)
static

Definition at line 234 of file BLI_array_store_test.cc.

References BLI_array_store_state_add(), and ListBase::first.

Referenced by TEST(), and testbuffer_run_tests_single().

◆ testbuffer_list_validate()

static bool testbuffer_list_validate ( const ListBase lb)
static

Definition at line 216 of file BLI_array_store_test.cc.

References ListBase::first, and testbuffer_item_validate().

Referenced by TEST(), and testbuffer_run_tests_single().

◆ testbuffer_run_tests()

static void testbuffer_run_tests ( BArrayStore bs,
ListBase lb 
)
static

◆ testbuffer_run_tests_simple()

static void testbuffer_run_tests_simple ( ListBase lb,
const int  stride,
const int  chunk_count 
)
static

◆ testbuffer_run_tests_single()

static void testbuffer_run_tests_single ( BArrayStore bs,
ListBase lb 
)
static

◆ testchunk_as_data_array()

static char* testchunk_as_data_array ( TestChunk **  tc_array,
int  tc_array_len,
size_t *  r_data_len 
)
static

Definition at line 91 of file BLI_array_store_test.cc.

References TestChunk::data, data, TestChunk::data_len, and MEM_mallocN.

Referenced by random_chunk_mutate_helper().

◆ testchunk_list_add()

static TestChunk* testchunk_list_add ( ListBase lb,
const void data,
size_t  data_len 
)
static

◆ testchunk_list_free()

static void testchunk_list_free ( ListBase lb)
static

Definition at line 60 of file BLI_array_store_test.cc.

References BLI_listbase_clear(), ListBase::first, and MEM_freeN.

Referenced by random_chunk_mutate_helper().