mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
quote removal: ensure quotes in middle of word are correctly handled
This commit is contained in:
parent
94e55d1d8b
commit
836e24bcb7
1 changed files with 24 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/28 13:46:56 by khais #+# #+# */
|
/* Created: 2025/02/28 13:46:56 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 11:19:37 by khais ### ########.fr */
|
/* Updated: 2025/03/07 11:24:30 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -82,6 +82,27 @@ static void test_quote_removal_mixed_double_in_single(void)
|
||||||
worddesc_destroy(got_word);
|
worddesc_destroy(got_word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_quote_removal_middle_of_word(void)
|
||||||
|
{
|
||||||
|
t_worddesc *word = create_single_word("var='VALUE'here");
|
||||||
|
t_worddesc *got_word = remove_quotes(word);
|
||||||
|
assert_strequal("var=VALUEhere", got_word->word);
|
||||||
|
assert(got_word->marker == NULL);
|
||||||
|
worddesc_destroy(word);
|
||||||
|
worddesc_destroy(got_word);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_quote_removal_nested_middle_of_word(void)
|
||||||
|
{
|
||||||
|
t_worddesc *word = create_single_word("var=\"'VALUE'here\"");
|
||||||
|
t_worddesc *got_word = remove_quotes(word);
|
||||||
|
assert_strequal("var='VALUE'here", got_word->word);
|
||||||
|
assert(got_word->marker == NULL);
|
||||||
|
worddesc_destroy(word);
|
||||||
|
worddesc_destroy(got_word);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
test_quote_removal_no_quotes_single_word();
|
test_quote_removal_no_quotes_single_word();
|
||||||
test_quote_removal_null();
|
test_quote_removal_null();
|
||||||
|
|
@ -89,5 +110,7 @@ int main(void) {
|
||||||
test_quote_removal_double_quotes();
|
test_quote_removal_double_quotes();
|
||||||
test_quote_removal_mixed_single_in_double();
|
test_quote_removal_mixed_single_in_double();
|
||||||
test_quote_removal_mixed_double_in_single();
|
test_quote_removal_mixed_double_in_single();
|
||||||
|
test_quote_removal_middle_of_word();
|
||||||
|
test_quote_removal_nested_middle_of_word();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue