mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
envp_get_key: add tests
This commit is contained in:
parent
aad17031a8
commit
9ac8588518
2 changed files with 32 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
rawtests = \
|
||||
env_manip \
|
||||
metacharacters \
|
||||
|
||||
tests = $(addprefix test_,$(rawtests))
|
||||
|
|
|
|||
31
tests/env_manip.c
Normal file
31
tests/env_manip.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* env_manip.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <assert.h>
|
||||
|
||||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue