cmdgroup parsing: parse empty wordlist

This commit is contained in:
Khaïs COLIN 2025-03-11 15:20:19 +01:00
parent 8f919b33df
commit bc5be67bf6
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
5 changed files with 98 additions and 0 deletions

View file

@ -30,6 +30,7 @@ srcs = \
src/executing/here_doc/strip_newline.c \ src/executing/here_doc/strip_newline.c \
src/ft_errno.c \ src/ft_errno.c \
src/get_command.c \ src/get_command.c \
src/parser/cmdgroup/cmdgroup.c \
src/parser/command_list/command_list_builder.c \ src/parser/command_list/command_list_builder.c \
src/parser/command_list/command_list.c \ src/parser/command_list/command_list.c \
src/parser/command_list/operator.c \ src/parser/command_list/operator.c \

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmdgroup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
/* Updated: 2025/03/11 15:18:59 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "cmdgroup.h"
#include <stdlib.h>
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words)
{
(void)words;
return (NULL);
}
void cmdgroup_destroy(t_cmdgroup *cmd)
{
(void)cmd;
}

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmdgroup.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:11:57 by khais #+# #+# */
/* Updated: 2025/03/11 15:17:22 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CMDGROUP_H
# define CMDGROUP_H
# include "../wordlist/wordlist.h"
typedef struct s_cmdgroup
{
} t_cmdgroup;
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words);
void cmdgroup_destroy(t_cmdgroup *cmd);
#endif // CMDGROUP_H

View file

@ -2,6 +2,7 @@
# file are prefixed with test_ # file are prefixed with test_
rawtests = \ rawtests = \
expansion \ expansion \
test_cmdgroup_parsing \
test_here_doc \ test_here_doc \
test_wordlist_idx \ test_wordlist_idx \
test_redirection_parsing \ test_redirection_parsing \

View file

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_cmdgroup_parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:07:23 by khais #+# #+# */
/* Updated: 2025/03/11 15:20:17 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "testutil.h"
#include <assert.h>
#include "libft.h"
#include "../src/parser/cmdgroup/cmdgroup.h"
#include "../src/parser/wordsplit/wordsplit.h"
static t_cmdgroup *parse_cmdgroup(char *input)
{
ft_dprintf(STDERR_FILENO, "Now checking command group with input [%s]\n", input);
t_wordlist *words = minishell_wordsplit(input);
t_cmdgroup *cmd = cmdgroup_from_wordlist(words);
wordlist_destroy(words);
return (cmd);
}
static void test_cmdgroup_parsing_empty(void)
{
t_cmdgroup *cmd;
// arange
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
cmd = parse_cmdgroup("");
// assert
assert(NULL == cmd);
// cleanup
cmdgroup_destroy(cmd);
do_leak_check();
}
int main(void)
{
test_cmdgroup_parsing_empty();
return (0);
}