diff --git a/tests/parse_pipelines.c b/tests/parse_pipelines.c index 08598a7..594af28 100644 --- a/tests/parse_pipelines.c +++ b/tests/parse_pipelines.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }