mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
cmdgroup parsing: parse empty wordlist
This commit is contained in:
parent
8f919b33df
commit
bc5be67bf6
5 changed files with 98 additions and 0 deletions
46
tests/test_cmdgroup_parsing.c
Normal file
46
tests/test_cmdgroup_parsing.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue