wordsplit: handle single word with spaces before or after

This commit is contained in:
Khaïs COLIN 2025-02-14 13:30:18 +01:00
parent fc985ea046
commit 8defbf4d13
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
9 changed files with 154 additions and 16 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/02/13 17:24:33 by khais ### ########.fr */
/* Updated: 2025/02/14 13:35:26 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,6 +28,16 @@ void test_wordsplit_singleword(void)
wordlist_destroy(words);
}
void test_wordsplit_singleword_with_spaces(void)
{
t_wordlist *words;
words = minishell_wordsplit(" echo ");
assert_strequal("echo", wordlist_get(words, 0)->word);
assert(NULL == wordlist_get(words, 1));
wordlist_destroy(words);
}
void test_wordsplit_basic(void)
{
t_wordlist *words;
@ -45,5 +55,6 @@ void test_wordsplit_basic(void)
int main(void) {
test_wordsplit_singleword();
test_wordsplit_singleword_with_spaces();
return (0);
}