mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
refactor cmdlist.num_cmds -> cmdlist.num_cmd to be more consistent
This commit is contained in:
parent
448458b37f
commit
88ed66e138
7 changed files with 27 additions and 27 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/24 17:40:48 by khais #+# #+# */
|
||||
/* Updated: 2025/03/18 15:05:05 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/20 11:57:26 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ static void test_parse_cmdlist_single_pipeline(void)
|
|||
assert(cmd != NULL);
|
||||
assert_pipelineequal("echo this | cat -e", cmd, 0);
|
||||
assert(cmd->operators[0] == OP_END);
|
||||
assert(cmd->num_cmds == 1);
|
||||
assert(cmd->num_cmd == 1);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ static void test_parse_cmdlist_simple_and(void)
|
|||
assert_pipelineequal("echo this | cat -e", cmd, 0);
|
||||
assert(cmd->operators[0] == OP_AND);
|
||||
assert_pipelineequal("echo works | wc -c", cmd, 1);
|
||||
assert(cmd->num_cmds == 2);
|
||||
assert(cmd->num_cmd == 2);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ static void test_parse_cmdlist_simple_or(void)
|
|||
assert_pipelineequal("echo this | cat -e", cmd, 0);
|
||||
assert(cmd->operators[0] == OP_OR);
|
||||
assert_pipelineequal("echo works | wc -c", cmd, 1);
|
||||
assert(cmd->num_cmds == 2);
|
||||
assert(cmd->num_cmd == 2);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ static void test_parse_cmdlist_triple_or(void)
|
|||
assert_pipelineequal("echo works | wc -c", cmd, 1);
|
||||
assert(cmd->operators[1] == OP_OR);
|
||||
assert_pipelineequal("echo as well | cut -d' ' -f1", cmd, 2);
|
||||
assert(cmd->num_cmds == 3);
|
||||
assert(cmd->num_cmd == 3);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ static void test_parse_cmdlist_triple_both_operators(void)
|
|||
assert(cmd->operators[1] == OP_AND);
|
||||
assert_pipelineequal("echo as well | cut -d' ' -f1", cmd, 2);
|
||||
assert(cmd->operators[2] == OP_END);
|
||||
assert(cmd->num_cmds == 3);
|
||||
assert(cmd->num_cmd == 3);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ static void test_parse_cmdlist_simple_command(void)
|
|||
assert(cmd != NULL);
|
||||
assert_pipelineequal("echo this", cmd, 0);
|
||||
assert(cmd->operators[0] == OP_END);
|
||||
assert(cmd->num_cmds == 1);
|
||||
assert(cmd->num_cmd == 1);
|
||||
cmdlist_destroy(cmd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:21:09 by khais #+# #+# */
|
||||
/* Updated: 2025/03/18 15:05:45 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/20 11:57:29 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -84,8 +84,8 @@ void assert_pipelineequal_raw(t_pipeline *expected, t_pipeline *got)
|
|||
|
||||
void assert_pipelineequal(char *expected, t_cmdlist *cmd, int idx)
|
||||
{
|
||||
ft_printf("Expected command list %p to have at least %d pipelines, and got %d\n", cmd, idx + 1, cmd->num_cmds);
|
||||
assert(cmd->num_cmds >= idx + 1);
|
||||
ft_printf("Expected command list %p to have at least %d pipelines, and got %d\n", cmd, idx + 1, cmd->num_cmd);
|
||||
assert(cmd->num_cmd >= idx + 1);
|
||||
t_pipeline *got = cmd->cmds[idx]->inner.pipeline;
|
||||
ft_dprintf(STDERR_FILENO, "Expected pipeline %p to equal [%s]\n", got, expected);
|
||||
t_pipeline *expected_pipeline = parse_pipeline(expected);
|
||||
|
|
@ -136,7 +136,7 @@ void assert_cmdgroup_itemlistequal(char *expected_str, t_cmdgroup *got_cmd, int
|
|||
}
|
||||
ft_dprintf(STDERR_FILENO, "checking if the list matches...\n");
|
||||
int i = 0;
|
||||
while (i < expected->num_cmds)
|
||||
while (i < expected->num_cmd)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue