simple_cmd: initial setup of create/destroy functions

This commit is contained in:
Khaïs COLIN 2025-02-21 12:35:51 +01:00
parent 6f175dd792
commit 49d7a2b9ff
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
6 changed files with 96 additions and 3 deletions

View file

@ -1,8 +1,9 @@
# make gets confused if a file with the same name exists in the sources, so some
# file are prefixed with test_
rawtests = \
test_env_manip \
metacharacters \
parse_simple_cmds \
test_env_manip \
word_splitting \
ifeq ($(CFLAGS),)
@ -42,6 +43,7 @@ run_test_%: test_%
@echo "====== Now running test: $* ======"
@echo
./test_$*
@echo "====== End of test: $* ======"
fclean:
rm -f $(tests)

37
tests/parse_simple_cmds.c Normal file
View file

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_simple_cmds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/21 12:20:20 by khais #+# #+# */
/* Updated: 2025/02/21 12:33:32 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include <assert.h>
#include "../src/parser/simple_cmd/simple_cmd.h"
#include "../src/parser/wordsplit/wordsplit.h"
#include "../src/parser/wordlist/wordlist.h"
static t_simple_cmd *parse_simple_cmd(char *input)
{
t_wordlist *words = minishell_wordsplit(input);
t_simple_cmd *cmd = simple_cmd_from_wordlist(words);
wordlist_destroy(words);
return (cmd);
}
static void test_parse_empty_command(void)
{
t_simple_cmd *cmd = parse_simple_cmd("");
assert(cmd != NULL);
simple_cmd_destroy(cmd);
}
int main(void)
{
test_parse_empty_command();
return (0);
}