diff --git a/tests/Makefile b/tests/Makefile index b295b71..af97f60 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,5 @@ rawtests = \ + env_manip \ metacharacters \ tests = $(addprefix test_,$(rawtests)) diff --git a/tests/env_manip.c b/tests/env_manip.c new file mode 100644 index 0000000..48f22df --- /dev/null +++ b/tests/env_manip.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* env_manip.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: khais +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/02/18 15:11:14 by khais #+# #+# */ +/* Updated: 2025/02/18 15:25:35 by khais ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../src/env_manip.h" +#include "libft.h" +#include + +static void test_envp_get_key(char *line, char *expected_key) +{ + char *value = envp_get_key(line); + ft_dprintf(STDERR_FILENO, "for envp value '%s', expecting key to eq '%s', and got '%s'\n", line, expected_key, value); + assert(expected_key == value || ft_strcmp(expected_key, value) == 0); + free(value); +} + +int main(void) { + test_envp_get_key("SHELL=/bin/fish", "SHELL"); + test_envp_get_key("=/bin/fish", ""); + test_envp_get_key(NULL, NULL); + test_envp_get_key("", NULL); + return (0); +}