mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit: handle multiple words
This commit is contained in:
parent
00fd2380cf
commit
4171a3d07b
4 changed files with 68 additions and 17 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue