wordsplit: implemet rule for variable substitution detection (rule 5)

This commit is contained in:
Khaïs COLIN 2025-02-20 14:06:28 +01:00
parent e10ed04169
commit ac8475c71d
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
7 changed files with 68 additions and 19 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/02/17 16:47:31 by khais ### ########.fr */
/* Updated: 2025/02/20 14:05:21 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -175,6 +175,21 @@ static void test_wordsplit_operator_combining(void)
wordlist_destroy(words);
}
static void test_wordsplit_var_substitution(void)
{
t_wordlist *words;
words = minishell_wordsplit("echo VAR=$VAR here");
assert_strequal("echo", wordlist_get(words, 0)->word);
assert(0 == wordlist_get(words, 0)->flags);
assert_strequal("VAR=$VAR", wordlist_get(words, 1)->word);
assert(W_HASDOLLAR == wordlist_get(words, 1)->flags);
assert_strequal("here", wordlist_get(words, 2)->word);
assert(0 == wordlist_get(words, 2)->flags);
wordlist_destroy(words);
}
int main(void) {
test_wordsplit_singleword();
test_wordsplit_singleword_with_blanks();
@ -189,5 +204,6 @@ int main(void) {
test_wordsplit_operator_word();
test_wordsplit_all_operators();
test_wordsplit_operator_combining();
test_wordsplit_var_substitution();
return (0);
}