MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_allocator_injection

Function test_allocator_injection

app/redis-6.2.6/deps/hiredis/test.c:632–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632static void test_allocator_injection(void) {
633 hiredisAllocFuncs ha = {
634 .mallocFn = hi_malloc_fail,
635 .callocFn = hi_calloc_fail,
636 .reallocFn = hi_realloc_fail,
637 .strdupFn = strdup,
638 .freeFn = free,
639 };
640
641 // Override hiredis allocators
642 hiredisSetAllocators(&ha);
643
644 test("redisContext uses injected allocators: ");
645 redisContext *c = redisConnect("localhost", 6379);
646 test_cond(c == NULL);
647
648 test("redisReader uses injected allocators: ");
649 redisReader *reader = redisReaderCreate();
650 test_cond(reader == NULL);
651
652 // Return allocators to default
653 hiredisResetAllocators();
654}
655
656#define HIREDIS_BAD_DOMAIN "idontexist-noreally.com"
657static void test_blocking_connection_errors(void) {

Callers 1

mainFunction · 0.85

Calls 5

hiredisSetAllocatorsFunction · 0.85
redisConnectFunction · 0.85
redisReaderCreateFunction · 0.85
hiredisResetAllocatorsFunction · 0.85
testClass · 0.50

Tested by

no test coverage detected