mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
pipeline: ensure that parsing works for three and four commands
This commit is contained in:
parent
5f1485d1d5
commit
68e923c09e
1 changed files with 31 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/21 13:13:58 by khais #+# #+# */
|
||||
/* Updated: 2025/02/21 14:07:52 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/21 15:29:48 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -67,10 +67,40 @@ static void test_parse_pipeline_two_cmd(void)
|
|||
pipeline_destroy(pipeline);
|
||||
}
|
||||
|
||||
static void test_parse_pipeline_three_cmd(void)
|
||||
{
|
||||
t_pipeline *pipeline = parse_pipeline("echo hello world | tee output.txt | cat -e");
|
||||
assert_pipeline_cmd_word(pipeline, "echo", 0, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "hello", 0, 1);
|
||||
assert_pipeline_cmd_word(pipeline, "world", 0, 2);
|
||||
assert_pipeline_cmd_word(pipeline, "tee", 1, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "output.txt", 1, 1);
|
||||
assert_pipeline_cmd_word(pipeline, "cat", 2, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "-e", 2, 1);
|
||||
pipeline_destroy(pipeline);
|
||||
}
|
||||
|
||||
static void test_parse_pipeline_four_cmd(void)
|
||||
{
|
||||
t_pipeline *pipeline = parse_pipeline("echo hello world | tee output.txt | cat -e | hexdump -C");
|
||||
assert_pipeline_cmd_word(pipeline, "echo", 0, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "hello", 0, 1);
|
||||
assert_pipeline_cmd_word(pipeline, "world", 0, 2);
|
||||
assert_pipeline_cmd_word(pipeline, "tee", 1, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "output.txt", 1, 1);
|
||||
assert_pipeline_cmd_word(pipeline, "cat", 2, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "-e", 2, 1);
|
||||
assert_pipeline_cmd_word(pipeline, "hexdump", 3, 0);
|
||||
assert_pipeline_cmd_word(pipeline, "-C", 3, 1);
|
||||
pipeline_destroy(pipeline);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_parse_empty_pipeline();
|
||||
test_parse_pipeline_single_cmd();
|
||||
test_parse_pipeline_two_cmd();
|
||||
test_parse_pipeline_three_cmd();
|
||||
test_parse_pipeline_four_cmd();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue