mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
quote detection: ensure the rest of the test cases pass
This commit is contained in:
parent
f60e922680
commit
4f6910eccd
1 changed files with 10 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||
/* Updated: 2025/03/06 16:42:12 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/06 16:50:56 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -254,22 +254,25 @@ static void test_wordsplit_var_substitution_quotes(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
// kco work marker
|
||||
|
||||
static void test_wordsplit_quote_detection_nonnested(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("echo 'single quotes' here \"double quotes\" here");
|
||||
assert_strequal("echo", wordlist_get(words, 0)->word);
|
||||
assert_strequal(" ", wordlist_get(words, 0)->marker);
|
||||
assert(0 == wordlist_get(words, 0)->flags);
|
||||
assert_strequal("'single quotes'", wordlist_get(words, 1)->word);
|
||||
assert_strequal(" ''''''''''''' ", wordlist_get(words, 1)->marker);
|
||||
assert(W_QUOTED == wordlist_get(words, 1)->flags);
|
||||
assert_strequal("here", wordlist_get(words, 2)->word);
|
||||
assert_strequal(" ", wordlist_get(words, 2)->marker);
|
||||
assert(0 == wordlist_get(words, 2)->flags);
|
||||
assert_strequal("\"double quotes\"", wordlist_get(words, 3)->word);
|
||||
assert_strequal(" \"\"\"\"\"\"\"\"\"\"\"\"\" ", wordlist_get(words, 3)->marker);
|
||||
assert((W_QUOTED | W_DQUOTE) == wordlist_get(words, 3)->flags);
|
||||
assert_strequal("here", wordlist_get(words, 4)->word);
|
||||
assert_strequal(" ", wordlist_get(words, 4)->marker);
|
||||
assert(0 == wordlist_get(words, 4)->flags);
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
|
@ -282,11 +285,13 @@ static void test_wordsplit_quote_detection_nested_double_in_simple(void)
|
|||
str = "'these are single quotes \"with double\" inside'";
|
||||
words = minishell_wordsplit(str);
|
||||
assert_strequal(str, wordlist_get(words, 0)->word);
|
||||
assert_strequal(" '''''''''''''''''''''''''''''''''''''''''''' ", wordlist_get(words, 0)->marker);
|
||||
assert(W_QUOTED == wordlist_get(words, 0)->flags);
|
||||
wordlist_destroy(words);
|
||||
str = "'\"these are single quotes with double inside\"'";
|
||||
words = minishell_wordsplit(str);
|
||||
assert_strequal(str, wordlist_get(words, 0)->word);
|
||||
assert_strequal(" '''''''''''''''''''''''''''''''''''''''''''' ", wordlist_get(words, 0)->marker);
|
||||
assert(W_QUOTED == wordlist_get(words, 0)->flags);
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
|
@ -300,10 +305,12 @@ static void test_wordsplit_quote_detection_nested_single_in_double(void)
|
|||
words = minishell_wordsplit(str);
|
||||
assert_strequal(str, wordlist_get(words, 0)->word);
|
||||
assert((W_QUOTED | W_DQUOTE) == wordlist_get(words, 0)->flags);
|
||||
assert_strequal(" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" ", wordlist_get(words, 0)->marker);
|
||||
wordlist_destroy(words);
|
||||
str = "\"'these are double quotes with single inside'\"";
|
||||
words = minishell_wordsplit(str);
|
||||
assert_strequal(str, wordlist_get(words, 0)->word);
|
||||
assert_strequal(" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" ", wordlist_get(words, 0)->marker);
|
||||
assert((W_QUOTED | W_DQUOTE) == wordlist_get(words, 0)->flags);
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue