minishell/tests/quote_removal.c

42 lines
1.6 KiB
C
Raw Normal View History

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* quote_removal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/28 13:46:56 by khais #+# #+# */
/* Updated: 2025/03/07 10:59:54 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "../src/parser/wordlist/wordlist.h"
#include "../src/parser/wordsplit/wordsplit.h"
#include "../src/parser/remove_quotes/remove_quotes.h"
#include "testutil.h"
#include <assert.h>
static t_worddesc *create_single_word(char *str)
{
t_wordlist *words = minishell_wordsplit(str);
assert(wordlist_get(words, 0) != NULL);
assert(wordlist_get(words, 1) == NULL);
t_worddesc *word = wordlist_pop(&words);
return (word);
}
static void test_quote_removal_no_quotes_single_word(void)
{
t_worddesc *word = create_single_word("word");
t_worddesc *got_word = remove_quotes(word);
assert_strequal("word", got_word->word);
assert(got_word->marker == NULL);
worddesc_destroy(word);
worddesc_destroy(got_word);
}
int main(void) {
test_quote_removal_no_quotes_single_word();
return (0);
}