Skip to content

Test suite for the ft_containers project at 42 - Makefile based

Notifications You must be signed in to change notification settings

5atchm1n/ft_containers-tester-42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

42 FT_CONTAINERS TESTER

Inspired by monkey_tester by @jgiron42

A basic unit test for the 42 containers project

STEP - 1

Read the README !
Compiles using clang++ !!
Modify the $INC variable in Makefile to point to your containers.

NOTE - Modify the #include "pair.hpp" in the srcs/_test_header.hpp to point to your ft::pair file if you wish to test map.

BASIC

Just to get you started ! Read the INDIVIDUAL TESTS and MODIFYING TESTS for details on how to debug errors or run individual tests.

make test_[container] to test against std ( ex: make test_vector )

make test_all to run all tests at once.

NOTE - A full list of the commands is provided below
NOTE - All test variables can be changed in the srcs/_test_header.hpp file
NOTE - Tests can be run with or without certain options. ex: -fsanitize=address can be removed. Please check makefile variables for the details.

Intro

Each container can be tested seperately. Tests are split into their respective directories :

  • vector_test
  • map_test
  • stack_test
  • set_test

Each test runs NTEST times and attempts to modify the container at most MAX_TEST_SIZE. The tests are run randomly using a unique SEED and this MAX_SEED_SIZE times to ensure multiple random test that can be run identicaly with the std library.
NOTE - All test variables can be changed in the srcs/_test_header.hpp file

Test all containers together
Test all containers seperately

COMPILING INDIVIDUAL TESTS FOR DEBUGGING

NOTICE - as of now you must run make clean between commands
A full list of the rules is provided below
Please check makefile variables

each container can be compiled and tested using the following syntax :

make [name]_[container]

so to test ft vector you would excute :

make ft_vector and this would generate the ft_vector binary.

make std_vector would then generate the std_vector binary.

each containers output can be tested against the std library using the folowing syntax :

make test_[container]

to test vector : make test_vector

MODIFYING THE TESTS

Tests can be run with or without certain compile flags. The const test can also be removed. Please check makefile variables for the details.
Each test is run MAX_SEED different times - the base SEED is 42. Each test is stored in a array of functions pointers - and randomly called. The tests are wrapped in a switch case - the header file in each test folder contains the necessary variables to modify the test. To remove a test for the unit comment out the case in the given file and make the wanted binary again.

example for vector :

scrnsht2
Feel free to add tests and remove tests to suit your build needs

FULL TESTS - SINGLE BINARY

The basic make commands all and bonus will compile the mandatory and bonus tests respectively.
To run diff tests (std vs ft) run make test and suprise suprise to test the bonuses output run make test_bonus. These will run tests on all the containers simultaneously. Please read the sections below to compile individual tests.

FULL TESTS - SEPERATE BINARIES

To run diff tests on all the binaries seperately run make test_all and make test_all_bonus this will run all the tests seperately and allow you to run the time commands to check the execution time.
If any of the tests fail Make will throw an error and stop.
Logs are output to the log directory and all tests are run with -fsanitize=address and -fstandalone-debug
this can be changed please read NOTES section

COMMANDS

FULL PROJECT TESTING

make generate ft and std binaries (mandatory)
make bonus generate ft and std binaries (mandatory + bonus)
make test run test std vs ft
make test_bonus run test std vs ft (mandatory + bonus)
make test_all run each container tests individually
make test_all_bonus run each container tests individually

containers_tester

TIME

make time after make test_all
make time_bonus after make test_all_bonus

INDIVIDUAL CONTAINERS TESTS

VECTOR

make ft_vector to create ft::vector executable
make std_vector to create std::vector executable
make test_vector run vector test and output to /log

MAP

make ft_map create ft::map executable
make std_map create std::map executable
make test_map run map test and output to /log

STACK

make ft_stack create ft::stack executable
make std_stack create std::stack executable
make test_stack run stack test and output to /log

SET

make ft_set create ft::set executable
make std_set create std::set executable
make test_set run set test and output to /log

Clean

make clean clean objs
make tclean clean test files
make lclean clean log files
make fclean clean all

VARIABLES

you can enable and disable certain tests at compile time by running the make command using certain variables.

  • TMEM - removes -fsanitize=address
  • TDEBUG - removes -fstandalone-debug
  • TCONST - removes const only tests
  • TALLOC - set to 1 to add allocator tests
  • LOG - output diff to stdout and file (no seperate logs)
these variables can be used together ex:

make <rule_name> TMEM=0 TCONST=0 TALLOC=1

NOTE - to editors

create a branch and pull request to merge into master !

About

Test suite for the ft_containers project at 42 - Makefile based

Topics

Resources

Stars

Watchers

Forks