From 4f6910eccd6b6a7a1902eaeea278e50dc15b46d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Thu, 6 Mar 2025 16:50:45 +0100 Subject: [PATCH] quote detection: ensure the rest of the test cases pass --- tests/word_splitting.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/word_splitting.c b/tests/word_splitting.c index 276cb8d..e54d4dc 100644 --- a/tests/word_splitting.c +++ b/tests/word_splitting.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }