quote marking: ensure that mixed quotes also work

This commit is contained in:
Khaïs COLIN 2025-03-06 15:44:53 +01:00
parent 616cb0bc09
commit 3a341e601d
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */ /* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/03/06 15:46:23 by khais ### ########.fr */ /* Updated: 2025/03/06 15:50:01 by khais ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -101,8 +101,11 @@ static void test_wordsplit_mixed_single_in_double(void)
words = minishell_wordsplit("hello \"mixed ' \tquotes \t'\" there"); words = minishell_wordsplit("hello \"mixed ' \tquotes \t'\" there");
assert_strequal("hello", wordlist_get(words, 0)->word); assert_strequal("hello", wordlist_get(words, 0)->word);
assert_strequal(" ", wordlist_get(words, 0)->marker);
assert_strequal("\"mixed ' \tquotes \t'\"", wordlist_get(words, 1)->word); assert_strequal("\"mixed ' \tquotes \t'\"", wordlist_get(words, 1)->word);
assert_strequal(" \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" ", wordlist_get(words, 1)->marker);
assert_strequal("there", wordlist_get(words, 2)->word); assert_strequal("there", wordlist_get(words, 2)->word);
assert_strequal(" ", wordlist_get(words, 2)->marker);
assert(NULL == wordlist_get(words, 3)); assert(NULL == wordlist_get(words, 3));
wordlist_destroy(words); wordlist_destroy(words);
} }
@ -113,8 +116,11 @@ static void test_wordsplit_mixed_double_in_single(void)
words = minishell_wordsplit("hello 'mixed \" quotes \"' there"); words = minishell_wordsplit("hello 'mixed \" quotes \"' there");
assert_strequal("hello", wordlist_get(words, 0)->word); assert_strequal("hello", wordlist_get(words, 0)->word);
assert_strequal(" ", wordlist_get(words, 0)->marker);
assert_strequal("'mixed \" quotes \"'", wordlist_get(words, 1)->word); assert_strequal("'mixed \" quotes \"'", wordlist_get(words, 1)->word);
assert_strequal(" '''''''''''''''' ", wordlist_get(words, 1)->marker);
assert_strequal("there", wordlist_get(words, 2)->word); assert_strequal("there", wordlist_get(words, 2)->word);
assert_strequal(" ", wordlist_get(words, 2)->marker);
assert(NULL == wordlist_get(words, 3)); assert(NULL == wordlist_get(words, 3));
wordlist_destroy(words); wordlist_destroy(words);
} }
@ -125,8 +131,11 @@ static void test_wordsplit_mixed_broken(void)
words = minishell_wordsplit("hello '\"mixed 'quotes'\"' there"); words = minishell_wordsplit("hello '\"mixed 'quotes'\"' there");
assert_strequal("hello", wordlist_get(words, 0)->word); assert_strequal("hello", wordlist_get(words, 0)->word);
assert_strequal("'\"mixed \'quotes'\"'", wordlist_get(words, 1)->word); assert_strequal(" ", wordlist_get(words, 0)->marker);
assert_strequal("'\"mixed 'quotes'\"'", wordlist_get(words, 1)->word);
assert_strequal(" ''''''' ' ", wordlist_get(words, 1)->marker);
assert_strequal("there", wordlist_get(words, 2)->word); assert_strequal("there", wordlist_get(words, 2)->word);
assert_strequal(" ", wordlist_get(words, 2)->marker);
assert(NULL == wordlist_get(words, 3)); assert(NULL == wordlist_get(words, 3));
wordlist_destroy(words); wordlist_destroy(words);
} }
@ -147,6 +156,8 @@ static void test_wordsplit_unclosed_double(void)
assert(words == NULL); assert(words == NULL);
} }
// kco work marker
static void test_wordsplit_operator_word(void) static void test_wordsplit_operator_word(void)
{ {
t_wordlist *words; t_wordlist *words;