diff --git a/framework/libunit.c b/framework/libunit.c index d38c83d..f98e249 100644 --- a/framework/libunit.c +++ b/framework/libunit.c @@ -10,16 +10,16 @@ /* */ /* ************************************************************************** */ -#include "libunit.h" #include "libft/libft.h" +#include "libunit.h" +#include #include #include -#include -static size_t interpret_status(int status, const char *fn_name - , char *test_name) +static size_t interpret_status(int status, const char *fn_name, + char *test_name) { - ft_putstr_fd((char *) fn_name, 1); + ft_putstr_fd((char *)fn_name, 1); ft_putstr_fd(" : ", 1); ft_putstr_fd(test_name, 1); ft_putstr_fd(" : ", 1); @@ -45,13 +45,13 @@ static size_t interpret_status(int status, const char *fn_name static void print_passed_test(size_t ok_tests, t_unit_test *test_list) { - size_t total; + size_t total; - total = count_tests(test_list); - if (ok_tests == total) - ft_putstr_fd("\x1B[32m", 1); - else - ft_putstr_fd("\x1B[31m", 1); + total = count_tests(test_list); + if (ok_tests == total) + ft_putstr_fd("\x1B[32m", 1); + else + ft_putstr_fd("\x1B[31m", 1); ft_putnbr_fd(ok_tests, 1); ft_putchar_fd('/', 1); ft_putnbr_fd((int)total, 1); @@ -60,10 +60,10 @@ static void print_passed_test(size_t ok_tests, t_unit_test *test_list) int launch_tests(t_unit_test *test_list, const char *fn_name) { - size_t ok_tests; - pid_t wpid; - int status; - int i; + size_t ok_tests; + pid_t wpid; + int status; + int i; ok_tests = 0; i = -1; @@ -79,8 +79,8 @@ int launch_tests(t_unit_test *test_list, const char *fn_name) wpid = wait(&status); if (wpid < 0) return (1); - ok_tests += interpret_status(status, fn_name, - get_test_at(test_list, i)->title); + ok_tests += interpret_status(status, fn_name, get_test_at(test_list, + i)->title); } } print_passed_test(ok_tests, test_list); diff --git a/framework/libunit.h b/framework/libunit.h index 5e859c6..f68a14c 100644 --- a/framework/libunit.h +++ b/framework/libunit.h @@ -6,12 +6,12 @@ /* By: elagouch +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/24 14:38:40 by elagouch #+# #+# */ -/* Updated: 2026/01/24 18:40:36 by elagouch ### ########.fr */ +/* Updated: 2026/01/24 18:56:03 by elagouch ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef UTIL_UNIT_H -# define UTIL_UNIT_H +#ifndef LIBUNIT_H +# define LIBUNIT_H # include "libft.h" # include @@ -66,4 +66,4 @@ void clear_tests(t_unit_test **head_ptr); int launch_tests(t_unit_test *test_list, const char *fn_name); -#endif // !UTIL_UNIT_H +#endif // !LIBUNIT_H diff --git a/libft/ft_strlen/00_launcher.c b/libft/ft_strlen/00_launcher.c deleted file mode 100644 index e1ff4fa..0000000 --- a/libft/ft_strlen/00_launcher.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 00_launcher.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: elagouch +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2026/01/24 15:32:32 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:01:11 by elagouch ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "../../util_unit.h" -#include "../tests.h" - -int strlen_launcher(void) { - t_unit_test *testlist; - size_t res; - - testlist = NULL; - load_test(&testlist, "null test", &test_null); - load_test(&testlist, "basic test", &test_basic); - - res = launch_tests(testlist, "strlen"); - clear_tests(&testlist); - - return (res); -} diff --git a/libft/ft_strlen/01_basic_test.c b/libft/ft_strlen/01_basic_test.c deleted file mode 100644 index 9ffa4c5..0000000 --- a/libft/ft_strlen/01_basic_test.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 01_basic_test.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: elagouch +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */ -/* Updated: 2026/01/24 15:39:06 by elagouch ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int test_basic(void) -{ - return (ft_strlen("hello, world") == 12); -} diff --git a/libft/ft_strlen/02_null_test.c b/libft/ft_strlen/02_null_test.c deleted file mode 100644 index 565d235..0000000 --- a/libft/ft_strlen/02_null_test.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 02_null_test.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: elagouch +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:01:12 by elagouch ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int test_null(void) { - return (ft_strlen(NULL) == 0); -} diff --git a/main.c b/main.c deleted file mode 100644 index 21ca363..0000000 --- a/main.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* main.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: elagouch +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2026/01/24 15:40:58 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:15:52 by elagouch ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libunit.h" - -int main(void) -{ - libunit_launcher(); - strlen_launcher(); -} diff --git a/real_tests/ft_strlen/00_launcher.c b/real_tests/ft_strlen/00_launcher.c index b2f93a7..10d6ad5 100644 --- a/real_tests/ft_strlen/00_launcher.c +++ b/real_tests/ft_strlen/00_launcher.c @@ -12,17 +12,16 @@ #include "../tests.h" -int strlen_launcher(void) { - t_unit_test *testlist; - size_t res; +int strlen_launcher(void) +{ + t_unit_test *testlist; + size_t res; - testlist = NULL; - load_test(&testlist, "null", &test_null); - load_test(&testlist, "basic", &test_basic); - load_test(&testlist, "large", &test_large); - - res = launch_tests(testlist, "strlen"); - clear_tests(&testlist); - - return (res); + testlist = NULL; + load_test(&testlist, "null", &test_null); + load_test(&testlist, "basic", &test_basic); + load_test(&testlist, "large", &test_large); + res = launch_tests(testlist, "strlen"); + clear_tests(&testlist); + return (res); } diff --git a/real_tests/ft_strlen/02_null.c b/real_tests/ft_strlen/02_null.c index ae665f8..fbf978f 100644 --- a/real_tests/ft_strlen/02_null.c +++ b/real_tests/ft_strlen/02_null.c @@ -12,6 +12,7 @@ #include "../tests.h" -int test_null(void) { - return (ft_strlen(NULL) == 0); +int test_null(void) +{ + return (ft_strlen(NULL) == 0); } diff --git a/real_tests/ft_strlen/03_large.c b/real_tests/ft_strlen/03_large.c index 492270a..f471b2e 100644 --- a/real_tests/ft_strlen/03_large.c +++ b/real_tests/ft_strlen/03_large.c @@ -12,14 +12,16 @@ #include "../tests.h" -int test_large(void) { - size_t i; - char s[10000]; +int test_large(void) +{ + size_t i; + char s[10000]; - i = 0; - while (i < sizeof(s)) { - s[i] = ' '; - i++; - } - return (ft_strlen(s) == sizeof(s) + 1); + i = 0; + while (i < sizeof(s)) + { + s[i] = ' '; + i++; + } + return (ft_strlen(s) == sizeof(s) + 1); } diff --git a/real_tests/main.c b/real_tests/main.c index ac63287..2be44c8 100644 --- a/real_tests/main.c +++ b/real_tests/main.c @@ -1,5 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: elagouch +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/24 18:53:18 by elagouch #+# #+# */ +/* Updated: 2026/01/24 18:53:18 by elagouch ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "tests.h" -int main(void) { - strlen_launcher(); +int main(void) +{ + strlen_launcher(); } diff --git a/real_tests/tests.h b/real_tests/tests.h index a9ec790..7b7d3f9 100644 --- a/real_tests/tests.h +++ b/real_tests/tests.h @@ -16,11 +16,11 @@ # include "libunit.h" // LAUNCHERS -int strlen_launcher(void); +int strlen_launcher(void); // strlen -int test_basic(void); -int test_null(void); -int test_large(void); +int test_basic(void); +int test_null(void); +int test_large(void); #endif // !TESTS_H diff --git a/tests/libunit/00_launcher.c b/tests/libunit/00_launcher.c index 9c2bdc3..4f9aa3e 100644 --- a/tests/libunit/00_launcher.c +++ b/tests/libunit/00_launcher.c @@ -12,18 +12,17 @@ #include "../tests.h" -int libunit_launcher(void) { - t_unit_test *testlist; - size_t res; +int libunit_launcher(void) +{ + t_unit_test *testlist; + size_t res; - testlist = NULL; - load_test(&testlist, "successful", &test_ok); - load_test(&testlist, "unsuccessful", &test_ko); - load_test(&testlist, "sigsegv", &test_sigsegv); - load_test(&testlist, "sigbus", &test_sigbus); - - res = launch_tests(testlist, "libunit"); - clear_tests(&testlist); - - return (res); + testlist = NULL; + load_test(&testlist, "successful", &test_ok); + load_test(&testlist, "unsuccessful", &test_ko); + load_test(&testlist, "sigsegv", &test_sigsegv); + load_test(&testlist, "sigbus", &test_sigbus); + res = launch_tests(testlist, "libunit"); + clear_tests(&testlist); + return (res); } diff --git a/tests/libunit/02_ko.c b/tests/libunit/02_ko.c index 22cd63c..f8cf1a2 100644 --- a/tests/libunit/02_ko.c +++ b/tests/libunit/02_ko.c @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ -int test_ko(void) { - return (0); +int test_ko(void) +{ + return (0); } diff --git a/tests/libunit/03_sigsegv.c b/tests/libunit/03_sigsegv.c index b7cc362..b92429e 100644 --- a/tests/libunit/03_sigsegv.c +++ b/tests/libunit/03_sigsegv.c @@ -12,7 +12,8 @@ #include -int test_sigsegv(void) { - raise(SIGSEGV); - return (1); +int test_sigsegv(void) +{ + raise(SIGSEGV); + return (1); } diff --git a/tests/libunit/04_sigbus.c b/tests/libunit/04_sigbus.c index b8c568a..06aca74 100644 --- a/tests/libunit/04_sigbus.c +++ b/tests/libunit/04_sigbus.c @@ -12,7 +12,8 @@ #include -int test_sigbus(void) { - raise(SIGBUS); - return (1); +int test_sigbus(void) +{ + raise(SIGBUS); + return (1); } diff --git a/tests/main.c b/tests/main.c index 3f9c5f9..11bf0f7 100644 --- a/tests/main.c +++ b/tests/main.c @@ -1,5 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: elagouch +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/24 18:53:13 by elagouch #+# #+# */ +/* Updated: 2026/01/24 18:53:14 by elagouch ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "tests.h" -int main(void) { - libunit_launcher(); +int main(void) +{ + libunit_launcher(); } diff --git a/tests/tests.h b/tests/tests.h index bc413c6..0fc03ff 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -16,12 +16,12 @@ # include "libunit.h" // LAUNCHERS -int libunit_launcher(void); +int libunit_launcher(void); // libunit -int test_ok(void); -int test_ko(void); -int test_sigsegv(void); -int test_sigbus(void); +int test_ok(void); +int test_ko(void); +int test_sigsegv(void); +int test_sigbus(void); #endif // !TESTS_H