Blender V5.0
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, uint 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 uint rand_range_i (RNG *rng, uint min_i, uint max_i, uint 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 uint 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)
RLE Encode/Decode Utilities
static bool rle_encode_decode_test (const uint8_t *data_dec, size_t data_dec_len, size_t *r_data_enc_len)
static void array_store_test_random_span_rle_encode (const size_t data_size, const size_t span_size, const int permitations)
static void array_store_test_random_data_rle_encode (const size_t data_size, const size_t data_ratio_size, const int permitations)
RLE Encode/Decode Tests
 TEST (array_store, RLE_Simple)
 TEST (array_store, RLE_Uniform)
 TEST (array_store, RLE_Alignment)
 TEST (array_store, RLE_RandomSpan)
 TEST (array_store, RLE_RandomBytes)

Macro Definition Documentation

◆ D

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

Referenced by area_light_spread_attenuation(), area_light_valid_ray_segment(), assign_final_coords_from_mdisps(), assign_final_elements_from_orig_mdisps(), background_light_sample(), background_portal_pdf(), background_portal_sample(), background_sun_pdf(), bsdf_ashikhmin_velvet_eval(), bsdf_ashikhmin_velvet_sample(), bsdf_microfacet_eval(), bsdf_microfacet_sample(), btDoSimplex4(), camera_sample_custom(), camera_sample_orthographic(), camera_sample_panorama(), camera_sample_perspective(), camera_sample_to_ray(), compute_v(), computeAccelerationsArticulatedBodyAlgorithmMultiDof(), libmv::ComputeTrackingEquation(), libmv::ArrayND< T, 3 >::CopyFrom(), differential_from_compact(), differential_make_compact(), distant_light_uv(), blender::bke::subdiv::eval_final_point(), blender::bke::subdiv::evaluate_vertex_and_apply_displacement_copy(), blender::bke::subdiv::evaluate_vertex_and_apply_displacement_interpolate(), guiding_phase_init(), guiding_record_background(), guiding_record_light_surface_segment(), integrate_distant_lights(), integrate_light(), integrate_surface_bsdf_bssrdf_bounce(), integrate_surface_ray_portal(), integrator_eval_background_shader(), integrator_init_from_bake(), integrator_state_read_ray(), integrator_state_read_shadow_ray(), integrator_state_write_ray(), integrator_state_write_shadow_ray(), Freestyle::GeomUtils::intersect2dSegPoly(), kernel_displace_evaluate(), KERNEL_STRUCT_MEMBER(), light_sample(), light_sample_from_volume_segment(), light_sample_mis_weight_forward_background(), light_tree_emitter_importance(), light_tree_node_importance(), light_tree_pdf(), md5_process_block(), multires_reshape_apply_base_update_mesh_coords(), object_dir_transform(), object_grid_element_to_tangent_displacement(), object_inverse_dir_transform(), blender::robust_pred::orient2dadapt(), osl_eval_camera(), osl_eval_camera(), pdf_cos_hemisphere(), pdf_uniform_cone(), phase_draine_sample(), phase_fournier_forand_sample(), phase_henyey_greenstein_sample(), phase_rayleigh_sample(), phase_sample_direction(), Freestyle::ImagePyramid::pixel(), blender::ed::greasepencil::primitive_calulate_curve_positions(), ray_cone_intersect(), ray_infinite_cylinder_intersect(), libmv::Tuple< int, N >::Reset(), EdgeDice::scale_factor(), SolveP2(), SolveP4Bi(), sphere_light_pdf(), spherical_stereo_transform(), spot_light_pdf(), spot_light_valid_ray_segment(), blender::bke::subdiv::subdiv_accumulate_vertex_displacement(), blender::bke::subdiv::subdiv_accumulate_vertex_displacement(), blender::bke::subdiv::subdiv_mesh_vertex_corner(), TEST(), triangle_light_valid_ray_segment(), libmv::Tuple< int, N >::Tuple(), and Camera::world_to_raster_size().

◆ testbuffer_list_state_from_string_array

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

Definition at line 178 of file BLI_array_store_test.cc.

◆ TESTBUFFER_STRINGS

#define TESTBUFFER_STRINGS ( stride,
chunk_count,
... )
Value:
{ \
ListBase lb; \
TESTBUFFER_STRINGS_CREATE(&lb, __VA_ARGS__); \
\
testbuffer_run_tests_simple(&lb, stride, chunk_count); \
\
testbuffer_list_free(&lb); \
} \
((void)0)

Definition at line 199 of file BLI_array_store_test.cc.

Referenced by TEST().

◆ TESTBUFFER_STRINGS_CREATE

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

Definition at line 190 of file BLI_array_store_test.cc.

Referenced by TEST().

◆ WORDS

Function Documentation

◆ array_store_test_random_data_rle_encode()

void array_store_test_random_data_rle_encode ( const size_t data_size,
const size_t data_ratio_size,
const int permitations )
static

◆ array_store_test_random_span_rle_encode()

void array_store_test_random_span_rle_encode ( const size_t data_size,
const size_t span_size,
const int permitations )
static

Test that a span of empty data gets RLE encoded.

Definition at line 840 of file BLI_array_store_test.cc.

References BLI_assert, BLI_rng_free(), BLI_rng_get_int(), BLI_rng_new(), data, i, MEM_freeN(), MEM_malloc_arrayN(), and rle_encode_decode_test().

Referenced by TEST(), and TEST().

◆ plain_text_helper()

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 parameters for the array-store to ensure no corner cases fail.

Definition at line 434 of file BLI_array_store_test.cc.

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

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ rand_range_i()

uint rand_range_i ( RNG * rng,
uint min_i,
uint max_i,
uint step )
static

Definition at line 569 of file BLI_array_store_test.cc.

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

Referenced by testbuffer_list_state_random_data().

◆ random_chunk_generate()

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()

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()

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

◆ rle_encode_decode_test()

bool rle_encode_decode_test ( const uint8_t * data_dec,
size_t data_dec_len,
size_t * r_data_enc_len )
static

◆ TEST() [1/44]

◆ TEST() [2/44]

◆ TEST() [3/44]

TEST ( array_store ,
Nop  )

Definition at line 305 of file BLI_array_store_test.cc.

References BLI_array_store_create(), and BLI_array_store_destroy().

Referenced by TEST(), and TEST().

◆ TEST() [4/44]

◆ TEST() [5/44]

TEST ( array_store ,
RLE_Alignment  )

◆ TEST() [6/44]

TEST ( array_store ,
RLE_RandomBytes  )

◆ TEST() [7/44]

TEST ( array_store ,
RLE_RandomSpan  )

◆ TEST() [8/44]

TEST ( array_store ,
RLE_Simple  )

Definition at line 920 of file BLI_array_store_test.cc.

References data, and rle_encode_decode_test().

◆ TEST() [9/44]

TEST ( array_store ,
RLE_Uniform  )

Definition at line 936 of file BLI_array_store_test.cc.

References EXPECT_EQ(), i, and rle_encode_decode_test().

◆ TEST() [10/44]

◆ TEST() [11/44]

TEST ( array_store ,
TestChunk_Rand31_Stride11_Chunk21  )

Definition at line 794 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [12/44]

TEST ( array_store ,
TestChunk_Rand32_Stride1_Chunk64  )

Definition at line 786 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [13/44]

TEST ( array_store ,
TestChunk_Rand64_Stride8_Chunk32  )

Definition at line 790 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [14/44]

TEST ( array_store ,
TestChunk_Rand8_Stride1_Chunk64  )

Definition at line 782 of file BLI_array_store_test.cc.

References random_chunk_mutate_helper().

◆ TEST() [15/44]

TEST ( array_store ,
TestData_Stride12_Chunk48_Mutate2  )

Definition at line 698 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [16/44]

TEST ( array_store ,
TestData_Stride1_Chunk32_Mutate2  )

Definition at line 690 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [17/44]

TEST ( array_store ,
TestData_Stride32_Chunk64_Mutate1  )

Definition at line 702 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [18/44]

TEST ( array_store ,
TestData_Stride32_Chunk64_Mutate8  )

Definition at line 706 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [19/44]

TEST ( array_store ,
TestData_Stride8_Chunk512_Mutate2  )

Definition at line 694 of file BLI_array_store_test.cc.

References random_data_mutate_helper().

◆ TEST() [20/44]

◆ TEST() [21/44]

TEST ( array_store ,
TextMixed  )

Definition at line 386 of file BLI_array_store_test.cc.

References TESTBUFFER_STRINGS.

◆ TEST() [22/44]

TEST ( array_store ,
TextSentences_Chunk1  )

Definition at line 465 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [23/44]

TEST ( array_store ,
TextSentences_Chunk1024  )

Definition at line 485 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [24/44]

TEST ( array_store ,
TextSentences_Chunk128  )

Definition at line 481 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [25/44]

TEST ( array_store ,
TextSentences_Chunk13  )

Definition at line 494 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [26/44]

TEST ( array_store ,
TextSentences_Chunk131  )

Definition at line 498 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [27/44]

TEST ( array_store ,
TextSentences_Chunk2  )

Definition at line 469 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [28/44]

TEST ( array_store ,
TextSentences_Chunk3  )

Definition at line 490 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [29/44]

TEST ( array_store ,
TextSentences_Chunk32  )

Definition at line 477 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [30/44]

TEST ( array_store ,
TextSentences_Chunk8  )

Definition at line 473 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [31/44]

TEST ( array_store ,
TextSentencesRandom_Stride128_Chunk6  )

Definition at line 559 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [32/44]

TEST ( array_store ,
TextSentencesRandom_Stride12_Chunk512  )

Definition at line 555 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [33/44]

TEST ( array_store ,
TextSentencesRandom_Stride32_Chunk1  )

Definition at line 551 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [34/44]

TEST ( array_store ,
TextSentencesRandom_Stride3_Chunk3  )

Definition at line 543 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [35/44]

TEST ( array_store ,
TextSentencesRandom_Stride8_Chunk8  )

Definition at line 547 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [36/44]

TEST ( array_store ,
TextWords_Chunk1  )

Definition at line 504 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [37/44]

TEST ( array_store ,
TextWords_Chunk1024  )

Definition at line 524 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [38/44]

TEST ( array_store ,
TextWords_Chunk128  )

Definition at line 520 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [39/44]

TEST ( array_store ,
TextWords_Chunk13  )

Definition at line 533 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [40/44]

TEST ( array_store ,
TextWords_Chunk131  )

Definition at line 537 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [41/44]

TEST ( array_store ,
TextWords_Chunk2  )

Definition at line 508 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [42/44]

TEST ( array_store ,
TextWords_Chunk3  )

Definition at line 529 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [43/44]

TEST ( array_store ,
TextWords_Chunk32  )

Definition at line 516 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ TEST() [44/44]

TEST ( array_store ,
TextWords_Chunk8  )

Definition at line 512 of file BLI_array_store_test.cc.

References plain_text_helper(), and WORDS.

◆ testbuffer_item_validate()

bool testbuffer_item_validate ( TestBuffer * tb)
static

◆ testbuffer_list_add()

◆ testbuffer_list_add_copydata()

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

Definition at line 142 of file BLI_array_store_test.cc.

References data, MEM_mallocN(), and testbuffer_list_add().

Referenced by testbuffer_list_state_from_data().

◆ testbuffer_list_data_randomize()

void testbuffer_list_data_randomize ( ListBase * lb,
uint random_seed )
static

Definition at line 236 of file BLI_array_store_test.cc.

References BLI_array_randomize(), and LISTBASE_FOREACH.

Referenced by plain_text_helper().

◆ testbuffer_list_free()

void testbuffer_list_free ( ListBase * lb)
static

◆ testbuffer_list_state_from_data()

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

◆ testbuffer_list_state_from_data__stride_expand()

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 158 of file BLI_array_store_test.cc.

References data, i, MEM_malloc_arrayN(), testbuffer_list_add(), and testbuffer_list_state_from_data().

Referenced by plain_text_helper().

◆ testbuffer_list_state_random_data()

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 uint mutate,
RNG * rng )
static

◆ testbuffer_list_store_clear()

void testbuffer_list_store_clear ( BArrayStore * bs,
ListBase * lb )
static

Definition at line 253 of file BLI_array_store_test.cc.

References BLI_array_store_state_remove(), and LISTBASE_FOREACH.

Referenced by TEST(), and testbuffer_run_tests().

◆ testbuffer_list_store_populate()

void testbuffer_list_store_populate ( BArrayStore * bs,
ListBase * lb )
static

Definition at line 243 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()

bool testbuffer_list_validate ( const ListBase * lb)
static

Definition at line 225 of file BLI_array_store_test.cc.

References LISTBASE_FOREACH, and testbuffer_item_validate().

Referenced by TEST(), and testbuffer_run_tests_single().

◆ testbuffer_run_tests()

void testbuffer_run_tests ( BArrayStore * bs,
ListBase * lb )
static

◆ testbuffer_run_tests_simple()

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

◆ testbuffer_run_tests_single()

void testbuffer_run_tests_single ( BArrayStore * bs,
ListBase * lb )
static

◆ testchunk_as_data_array()

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

◆ testchunk_list_add()

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

◆ testchunk_list_free()

void testchunk_list_free ( ListBase * lb)
static

Definition at line 69 of file BLI_array_store_test.cc.

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

Referenced by random_chunk_mutate_helper().