aboutsummaryrefslogtreecommitdiff
path: root/test/src/mem/test_ft_memccpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/mem/test_ft_memccpy.c')
-rw-r--r--test/src/mem/test_ft_memccpy.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/src/mem/test_ft_memccpy.c b/test/src/mem/test_ft_memccpy.c
index 6b7a1a5..39925a1 100644
--- a/test/src/mem/test_ft_memccpy.c
+++ b/test/src/mem/test_ft_memccpy.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/13 03:34:13 by cacharle #+# #+# */
-/* Updated: 2020/02/13 03:40:18 by cacharle ### ########.fr */
+/* Updated: 2020/02/13 19:35:17 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,5 +22,24 @@ TEST_TEAR_DOWN(ft_memccpy)
TEST(ft_memccpy, basic)
{
+ char buf[32] = "bonjour";
+ char buf2[32] = {0};
+ char *ptr = ft_memccpy(buf2, buf, 0x0, 32);
+ TEST_ASSERT_EQUAL_PTR(&buf2[8], ptr);
+ for (int i = 0; i < 32; i++)
+ TEST_ASSERT_EQUAL_CHAR(buf[i], buf2[i]);
+
+ ptr = ft_memccpy(buf2, buf, 0x1, 32);
+ TEST_ASSERT_NULL(ptr);
+ for (int i = 0; i < 32; i++)
+ TEST_ASSERT_EQUAL_CHAR(buf[i], buf2[i]);
+
+ char buf3[10] = "aurevoir";
+ ptr = ft_memccpy(buf, buf3, 'e', 10);
+ TEST_ASSERT_EQUAL_PTR(buf + 4, ptr);
+ for (int i = 0; i < 4; i++)
+ TEST_ASSERT_EQUAL_CHAR(buf[i], buf3[i]);
+ for (int i = 4; i < 32; i++)
+ TEST_ASSERT_EQUAL_CHAR(buf[i], buf2[i]);
}