cmdlist parsing: ensure parsing works for a single simple command

This commit is contained in:
Khaïs COLIN 2025-03-04 15:17:04 +01:00 committed by Khaïs COLIN
parent 4c37ec5188
commit d30db395a0

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/24 17:40:48 by khais #+# #+# */ /* Created: 2025/02/24 17:40:48 by khais #+# #+# */
/* Updated: 2025/03/04 15:13:21 by khais ### ########.fr */ /* Updated: 2025/03/04 15:16:00 by khais ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -176,6 +176,17 @@ static void test_parse_command_list_invalid_pipeline(void)
cmdlist_destroy(cmd); cmdlist_destroy(cmd);
} }
static void test_parse_command_list_simple_command(void)
{
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
t_cmdlist *cmd = parse_command_list("echo this");
assert(cmd != NULL);
assert_pipelineequal("echo this", cmd, 0);
assert(cmd->operators[0] == OP_END);
assert(cmd->num_pipelines == 1);
cmdlist_destroy(cmd);
}
int main(void) int main(void)
{ {
test_parse_command_list_empty(); test_parse_command_list_empty();
@ -194,5 +205,7 @@ int main(void)
do_leak_check(); do_leak_check();
test_parse_command_list_invalid_pipeline(); test_parse_command_list_invalid_pipeline();
do_leak_check(); do_leak_check();
test_parse_command_list_simple_command();
do_leak_check();
return (0); return (0);
} }