redirection parsing: handle commands with no redirections

This commit is contained in:
Khaïs COLIN 2025-03-07 11:55:51 +01:00
parent 42bccd0a06
commit 06ebcf132a
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
7 changed files with 116 additions and 3 deletions

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_redirection_parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/07 11:55:37 by khais #+# #+# */
/* Updated: 2025/03/07 12:00:13 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include <assert.h>
#include "../src/parser/simple_cmd/simple_cmd.h"
#include "../src/parser/wordsplit/wordsplit.h"
#include "../src/postprocess/redirections/redirections.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);
return (cmd);
}
static void test_redirection_parsing_no_redirections(void)
{
t_simple_cmd *cmd = parse_simple_cmd("echo hello world");
assert(parse_redirections(cmd) != NULL);
assert(cmd->redirections == NULL);
simple_cmd_destroy(cmd);
}
int main(void) {
test_redirection_parsing_no_redirections();
return (0);
}