diff --git a/src/parser/remove_quotes/remove_quotes.c b/src/parser/remove_quotes/remove_quotes.c index 030e01c..97f17fb 100644 --- a/src/parser/remove_quotes/remove_quotes.c +++ b/src/parser/remove_quotes/remove_quotes.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/28 13:52:02 by khais #+# #+# */ -/* Updated: 2025/03/07 11:09:17 by khais ### ########.fr */ +/* Updated: 2025/03/07 11:09:30 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,11 +18,15 @@ ** unquoted quotes. ** ** The new worddesc will have the marker set to NULL. +** +** If word is null return null. */ t_worddesc *remove_quotes(t_worddesc *word) { t_worddesc *output; + if (word == NULL) + return (NULL); output = worddesc_create(ft_strdup(word->word), word->flags, NULL); if (output->word == NULL) return (worddesc_destroy(output), NULL); diff --git a/tests/quote_removal.c b/tests/quote_removal.c index 956f6e9..47ced45 100644 --- a/tests/quote_removal.c +++ b/tests/quote_removal.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/28 13:46:56 by khais #+# #+# */ -/* Updated: 2025/03/07 10:59:54 by khais ### ########.fr */ +/* Updated: 2025/03/07 11:07:59 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,15 @@ static void test_quote_removal_no_quotes_single_word(void) worddesc_destroy(got_word); } +static void test_quote_removal_null(void) +{ + t_worddesc *word = NULL; + t_worddesc *got_word = remove_quotes(word); + assert(got_word == NULL); +} + int main(void) { test_quote_removal_no_quotes_single_word(); + test_quote_removal_null(); return (0); }