diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-05-09 12:31:50 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-05-09 12:31:50 +0200 |
| commit | 02abc030a68cb2fdd2f21c96db830ec8cb9176ad (patch) | |
| tree | 0c2d67c94a3618639fc2cd29d8bc78820e41c254 /test/src/dstr/test_ft_dstrsubstitute.c | |
| parent | b5124347359833fcde33452978c62133879c6c9e (diff) | |
| parent | 3a2d19df9e509d0b015c786eb02f8315ff0ad91c (diff) | |
| download | libft-02abc030a68cb2fdd2f21c96db830ec8cb9176ad.tar.gz libft-02abc030a68cb2fdd2f21c96db830ec8cb9176ad.tar.bz2 libft-02abc030a68cb2fdd2f21c96db830ec8cb9176ad.zip | |
Merge remote-tracking branch 'origin/minishell'
Diffstat (limited to 'test/src/dstr/test_ft_dstrsubstitute.c')
| -rw-r--r-- | test/src/dstr/test_ft_dstrsubstitute.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/src/dstr/test_ft_dstrsubstitute.c b/test/src/dstr/test_ft_dstrsubstitute.c new file mode 100644 index 0000000..d81b944 --- /dev/null +++ b/test/src/dstr/test_ft_dstrsubstitute.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* test_ft_dstrsubstitute.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 19:41:59 by charles #+# #+# */ +/* Updated: 2020/04/05 01:09:47 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_test.h" + +TEST_GROUP(ft_dstrsubstitute); + +TEST_SETUP(ft_dstrsubstitute) +{} + +TEST_TEAR_DOWN(ft_dstrsubstitute) +{} + +TEST(ft_dstrsubstitute, basic) +{ + t_ftdstr *dstr; + + dstr = ft_dstrnew("bonjour"); + TEST_ASSERT_NULL(ft_dstrsubstitute(dstr, "bonjour", 8, 1)); + + TEST_ASSERT_NOT_NULL(ft_dstrsubstitute(dstr, "{{{", 0, 0)); + TEST_ASSERT_NOT_NULL(dstr); + TEST_ASSERT_NOT_NULL(dstr->str); + TEST_ASSERT_EQUAL(10, dstr->length); + TEST_ASSERT_GREATER_OR_EQUAL(11, dstr->capacity); + TEST_ASSERT_EQUAL_STRING("{{{bonjour", dstr->str); + + TEST_ASSERT_NOT_NULL(ft_dstrsubstitute(dstr, "]]]", dstr->length, 0)); + TEST_ASSERT_NOT_NULL(dstr); + TEST_ASSERT_NOT_NULL(dstr->str); + TEST_ASSERT_EQUAL(13, dstr->length); + TEST_ASSERT_GREATER_OR_EQUAL(14, dstr->capacity); + TEST_ASSERT_EQUAL_STRING("{{{bonjour]]]", dstr->str); + + TEST_ASSERT_NOT_NULL(ft_dstrsubstitute(dstr, "aurevoir", 3, 7)); + TEST_ASSERT_NOT_NULL(dstr); + TEST_ASSERT_NOT_NULL(dstr->str); + TEST_ASSERT_EQUAL(14, dstr->length); + TEST_ASSERT_GREATER_OR_EQUAL(15, dstr->capacity); + TEST_ASSERT_EQUAL_STRING("{{{aurevoir]]]", dstr->str); + + TEST_ASSERT_NOT_NULL(ft_dstrsubstitute(dstr, "<>", 0, dstr->length)); + TEST_ASSERT_NOT_NULL(dstr); + TEST_ASSERT_NOT_NULL(dstr->str); + TEST_ASSERT_EQUAL(2, dstr->length); + TEST_ASSERT_GREATER_OR_EQUAL(3, dstr->capacity); + TEST_ASSERT_EQUAL_STRING("<>", dstr->str); + + TEST_ASSERT_NOT_NULL(ft_dstrsubstitute(dstr, "<>", 0, dstr->length)); + TEST_ASSERT_NOT_NULL(dstr); + TEST_ASSERT_NOT_NULL(dstr->str); + TEST_ASSERT_EQUAL(2, dstr->length); + TEST_ASSERT_GREATER_OR_EQUAL(3, dstr->capacity); + TEST_ASSERT_EQUAL_STRING("<>", dstr->str); +} |
