mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit: handle mixed quotes
This commit is contained in:
parent
1676cf6696
commit
452d35acdf
2 changed files with 38 additions and 8 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||
/* Updated: 2025/02/17 13:52:55 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/17 14:27:45 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -76,11 +76,37 @@ static void test_wordsplit_multiword_with_double_quotes(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_mixed_single_in_double(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("hello \"mixed ' \tquotes \t'\" there");
|
||||
assert_strequal("hello", wordlist_get(words, 0)->word);
|
||||
assert_strequal("\"mixed ' \tquotes \t'\"", wordlist_get(words, 1)->word);
|
||||
assert_strequal("there", wordlist_get(words, 2)->word);
|
||||
assert(NULL == wordlist_get(words, 3));
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_mixed_double_in_single(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("hello 'mixed \" quotes \"' there");
|
||||
assert_strequal("hello", wordlist_get(words, 0)->word);
|
||||
assert_strequal("'mixed \" quotes \"'", wordlist_get(words, 1)->word);
|
||||
assert_strequal("there", wordlist_get(words, 2)->word);
|
||||
assert(NULL == wordlist_get(words, 3));
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_wordsplit_singleword();
|
||||
test_wordsplit_singleword_with_blanks();
|
||||
test_wordsplit_multiword();
|
||||
test_wordsplit_multiword_with_single_quotes();
|
||||
test_wordsplit_multiword_with_double_quotes();
|
||||
test_wordsplit_mixed_single_in_double();
|
||||
test_wordsplit_mixed_double_in_single();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue