env_set_entry: use ft_errno to indicate error conditions

This commit is contained in:
Jérôme Guélen 2025-02-17 16:52:17 +01:00 committed by Khaïs COLIN
parent df8aec148f
commit e985fcc562
5 changed files with 32 additions and 17 deletions

View file

@ -6,11 +6,12 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/18 15:11:14 by khais #+# #+# */
/* Updated: 2025/02/19 12:23:50 by khais ### ########.fr */
/* Updated: 2025/02/19 13:15:43 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "../src/env_manip.h"
#include "../src/ft_errno.h"
#include "libft.h"
#include "testutil.h"
#include "unistd.h"
@ -79,9 +80,13 @@ static void test_env_set_entry_nullargs(void)
env = NULL;
assert(env_set_entry(&env, ft_strdup("VAR"), ft_strdup("hello")) != NULL);
ft_errno(FT_ESUCCESS);
assert(env_set_entry(&env, NULL, ft_strdup("hello")) == NULL);
assert(ft_errno_get() == FT_EINVAL);
assert(env_set_entry(&env, ft_strdup("VAR"), NULL) == NULL);
assert(env_set_entry(&env, ft_strdup(""), ft_strdup("value")) == env);
ft_errno(FT_ESUCCESS);
assert(env_set_entry(&env, ft_strdup(""), ft_strdup("value")) == NULL);
assert(ft_errno_get() == FT_EBADID);
assert_env_value(env, "VAR", "hello");
assert(1 == env_get_size(env));
env_destroy(env);