wordsplit: handle multiple words

This commit is contained in:
Khaïs COLIN 2025-02-14 15:44:10 +01:00
parent 00fd2380cf
commit 4171a3d07b
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 68 additions and 17 deletions

View file

@ -6,12 +6,13 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/02/14 15:06:50 by khais ### ########.fr */
/* Updated: 2025/02/14 16:16:14 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include <assert.h>
#include "testutil.h"
#include "libft.h"
#include "../src/parser/wordsplit/wordsplit.h"
#include <stdlib.h>
@ -38,11 +39,11 @@ void test_wordsplit_singleword_with_blanks(void)
wordlist_destroy(words);
}
void test_wordsplit_basic(void)
void test_wordsplit_multiword(void)
{
t_wordlist *words;
words = minishell_wordsplit("echo The file is named $MYFILE");
words = minishell_wordsplit("\t echo\tThe file is named $MYFILE \t");
assert_strequal("echo", wordlist_get(words, 0)->word);
assert_strequal("The", wordlist_get(words, 1)->word);
assert_strequal("file", wordlist_get(words, 2)->word);
@ -56,5 +57,6 @@ void test_wordsplit_basic(void)
int main(void) {
test_wordsplit_singleword();
test_wordsplit_singleword_with_blanks();
test_wordsplit_multiword();
return (0);
}