mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit: handle double quotes
This commit is contained in:
parent
5276aba278
commit
1676cf6696
2 changed files with 27 additions and 7 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||
/* Updated: 2025/02/14 17:37:46 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/17 13:52:55 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
/*
|
||||
** https://bash-hackers.gabe565.com/syntax/words/
|
||||
*/
|
||||
void test_wordsplit_singleword(void)
|
||||
static void test_wordsplit_singleword(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ void test_wordsplit_singleword(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
void test_wordsplit_singleword_with_blanks(void)
|
||||
static void test_wordsplit_singleword_with_blanks(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ void test_wordsplit_singleword_with_blanks(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
void test_wordsplit_multiword(void)
|
||||
static void test_wordsplit_multiword(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ void test_wordsplit_multiword(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
void test_wordsplit_multiword_with_single_quotes(void)
|
||||
static void test_wordsplit_multiword_with_single_quotes(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
|
|
@ -65,10 +65,22 @@ void test_wordsplit_multiword_with_single_quotes(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_multiword_with_double_quotes(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("\t echo\t\" \t The file is named $MYFILE \" \t");
|
||||
assert_strequal("echo", wordlist_get(words, 0)->word);
|
||||
assert_strequal("\" \t The file is named $MYFILE \"", wordlist_get(words, 1)->word);
|
||||
assert(NULL == wordlist_get(words, 2));
|
||||
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();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue