Microchip® Advanced Software Framework

common/utils/membag/unit_tests/unit_tests.c File Reference

Memory bag allocator.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "conf_test.h"

Functions

int main ()
 
static void run_membag_alloc_test (const struct test_case *test)
 Unit test to check that the Membag allocates small and large chunks of memory correctly, and fails when a chunk that is too large is requested. More...
 
static void run_membag_alloc_when_full_test (const struct test_case *test)
 Unit test to check that the Membag allocations fail once all suitable bags are already allocated. More...
 
static void run_membag_free_test (const struct test_case *test)
 Unit test to check that the Membag frees previously allocated memory correctly. More...
 
static void run_membag_get_test (const struct test_case *test)
 Unit test to check that the Membag functions to determine memory status work correctly. More...
 
static void run_membag_init_test (const struct test_case *test)
 Unit test to check that the Membag is initialized and re-initialized correctly. More...
 
static void run_membag_realloc_test (const struct test_case *test)
 Unit test to check that the Membag re-allocates previously allocated and subsequently freed blocks of memory correctly. More...
 

static void run_membag_alloc_test ( const struct test_case test)
static

Unit test to check that the Membag allocates small and large chunks of memory correctly, and fails when a chunk that is too large is requested.

Parameters
testPointer to the unit test case instance

References data, membag_alloc(), membag_init(), test_assert_false, and test_assert_true.

Referenced by main().

static void run_membag_alloc_when_full_test ( const struct test_case test)
static

Unit test to check that the Membag allocations fail once all suitable bags are already allocated.

Parameters
testPointer to the unit test case instance

References data, membag_alloc(), membag_get_largest_free_block_size(), membag_init(), test_assert_false, and test_assert_true.

Referenced by main().

static void run_membag_free_test ( const struct test_case test)
static

Unit test to check that the Membag frees previously allocated memory correctly.

Parameters
testPointer to the unit test case instance

References membag_alloc(), membag_free(), membag_get_total(), membag_get_total_free(), membag_init(), test_assert_false, and test_assert_true.

Referenced by main().

static void run_membag_get_test ( const struct test_case test)
static

Unit test to check that the Membag functions to determine memory status work correctly.

Parameters
testPointer to the unit test case instance

References data, membag_alloc(), membag_get_largest_free_block_size(), membag_get_total_free(), membag_init(), test_assert_false, and test_assert_true.

Referenced by main().

static void run_membag_init_test ( const struct test_case test)
static

Unit test to check that the Membag is initialized and re-initialized correctly.

Parameters
testPointer to the unit test case instance

References membag_alloc(), membag_get_total(), membag_get_total_free(), membag_init(), test_assert_false, and test_assert_true.

Referenced by main().

static void run_membag_realloc_test ( const struct test_case test)
static

Unit test to check that the Membag re-allocates previously allocated and subsequently freed blocks of memory correctly.

Parameters
testPointer to the unit test case instance

References data, membag_alloc(), membag_free(), membag_get_largest_free_block_size(), membag_init(), and test_assert_false.

Referenced by main().