libft Unit tests

⚠️ Important note: this version targets the new 42 subject of libft, if you want to use the old one you can access it on the old branch.

libft-unit-test is a complete testing suite for 42's libft project, allowing you to test your lib, track your progress and benchmarking your lib (with system's libc or with another lib)

🤖 Important information 🤖

This repository this not maintained by the owner anymore, an automated merge bot is setup to merge all the pull requests that are reviewed by at least one contributor of this project.

In other words if something is broken and you want to fix it, the only thing you have to do is create a pull request and find someone that has already pushed code to this repository to review your work. You can see the list of people that can review your work here: libft-uni-test contributors.

Installation

You must have the following file structure:

.
|- libft/
|- libft-unit-tests/

Whereas: libft is your project folder. libft-unit-tests is the folder containing this repository.

Afterwards, you can just make.

(NOTE: Before running make, you can edit the LIBFTDIR variable containing the path to your libft folder.)

Usage

Run make f or ./run_test when inside the repo's directory. ./run_test -b to use the Benchmark mode. (-b option to compare with system's libc and -v <libft file> option to compare with another libft file (should be libft.so).

the -nospeed option is available if you're mad enough at your optimization. :)

Results

The test result will be displayed directly in the console with a simple color code.

Color Meaning
Red The function did not behaved correctly or crashed during the test.
Orange The function exceeded the maximal execution time, Probably due to an infinite loop.
Yellow The function failed to handle an extreme case, Most of the time, it's okay to consider the function as correct.
Green The function is correct.

More information about the test context and code is available in the result.log written at the root of the test repository.

Note that in the results, there is a big difference between [CRASH] or [FAIL] and [KO]. While both crash and fail means that the function does not work and should be graded as invalid it's not the case for KO, KO means that the functions fails to handle a case not intended to be tested by 42's grading system and that in some case may exceed the scope of the function.

Linux

To get it work on linux:

  • Install this two packages libbsd-dev and libncurses-dev
  • Add a rule called 'so' in your Makefile to compile your libft in dynamic library instead of static (must be called "libft.so").
  • To make it work in ubuntu you might need to add the flag -nostartfiles

Example:

so:
	$(CC) -fPIC $(CFLAGS) $(SRC)
	gcc -shared -o libft.so $(OBJ)

Example (ubuntu):

so:
	$(CC) -nostartfiles -fPIC $(CFLAGS) $(SRC)
	gcc -nostartfiles -shared -o libft.so $(OBJ)

Screenshots

Default mode

Unit_Testing

Benchmark mode

Benchmarking