/printf_tester

This is a unit-tester for 42's ft_printf project.

Primary LanguageCMIT LicenseMIT

Printf_tester

GitHub release (latest by date) GitHub last commit GitHub issues License: MIT

Tester output gif

⚠️Don't use this tester while writing your code. To be a good programmer, you should write your own tests. This tester is intended as a last check for your project, to see whether you missed some testcases.

🚀 Description

This is a tester for the ft_printf project in 42's curriculum. It contains 800+ tests and is made with the user in mind. It is very easy to use after a small setup. It is also very easy to see which test cases you failed (see figure above).

It only tests for:

  1. "cspdiuxX%" conversions.
  2. "0-" flags.
  3. Width and precision (also with the '*' option).

The output of printf on Linux and MacOS is different. Be aware of this. Make sure you test it on the iMacs! Below you can find some cases (not all) in which Linux and MacOS differ:

Precision used with s-conversion with NULL as input: printf("%.2s", NULL);
Width used with %-conversion: printf("%3%");
NULL as input with p-conversion: printf("%p", NULL);

⚙️ Installation and Setup

Clone this repository and go inside the project folder. Now we are going to create a symbolic to your ft_printf project. This makes it easy to debug. You can just work on your original project and these symbolic links will follow the changes you make to your original code. To create a symbolic link, run the following command from inside the printf_tester directory:

ln -s path/to/your/ft_printf src

⚠️ Make sure you call the directory src.

Your directory should look like this now:

After linking

🕹️ Usage

To run the tester on all testcases, simply run:

./printf_tester.sh

You can also choose a specific conversion test to run. In this case, it tests for the s-conversion:

./printf_tester.sh s

In the logs/wrong_test_cases file you can find all the testcases for which your project has failed.

🧭 Roadmap

  • Add more testcases.
  • Improve error messages.

📫 Contribute

Found a bug? Ran into a specific problem? Missing a feature? Or you have some more testcases? Feel free to file a new issue with a respective title and description on the issue page. You can also ask questions in GitHub Discussion.

📘 License

MIT