ft_containers terminator

A tester for the project ft_containers at 42

Usage

Set the location of your containers folder in tests/run_tests.sh (variable FT_CONTAINERS) The tester expects every header files at the root of the folder assigned to FT_CONTAINERS

Run every tests: sh run_tests.sh

Run one or more container tests: sh run_files.sh <CONTAINER_1> ... <CONTAINER_N> Example: sh run_tests.sh vector stack ...

Run individual tests: sh run_files.sh <CONTAINER> <TEST_1> ... <TEST_N> Example: sh run_files.sh vector erase clear ...

Summary

This tester tracks allocations/dealloctions as well as construction/destruction calls.

Leaks are tracked and bad use of Allocator::construct/Allocator::destroy (Allocator is the template parameter for the container’s allocator). Construct calls on initialized memory is a bug because the destructor of T will NOT be called. Also, destroy calls on uninitialized memory is also a bug because its calling a destructor on garbage values.

For example, consider this struct:

struct object
{
    int* ptr;

    object()
    {
        ptr = new int[10]();
    }

    object(const object&)
    {
        ptr = new int[10]();
    }

    ~object()
    {
        delete[] ptr;
    }
};

A vector of the struct object (ft::vector<object>) would leak memory everytime the destructor isn’t called. Thus when the tester reports N number of alive objects, consider it to be a bug. This also happens when Allocator::construct is called on already initialized memory.

GitHub

View Github