mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: handle commands with no redirections
This commit is contained in:
parent
42bccd0a06
commit
06ebcf132a
7 changed files with 116 additions and 3 deletions
36
tests/test_redirection_parsing.c
Normal file
36
tests/test_redirection_parsing.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue