-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemset.cpp
More file actions
96 lines (77 loc) · 2.18 KB
/
Copy pathmemset.cpp
File metadata and controls
96 lines (77 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* memset.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjurkows <kjurkows@student.42warsaw.pl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/06/18 14:35:54 by kjurkows #+# #+# */
/* Updated: 2026/06/25 17:47:24 by kjurkows ### ########.fr */
/* */
/* ************************************************************************** */
#include "_main.hpp"
#include <string.h>
TEST(memset, basic)
{
ASSERT_EXIT({
char ft[] = "Hello, World!";
char c[] = "Hello, World!";
int n = 5;
memset(c, 'x', n);
ft_memset(ft, 'x', n);
exit(memcmp(ft, c, 14));
}, ::testing::ExitedWithCode(0), "");
}
TEST(memset, full_length)
{
ASSERT_EXIT({
char ft[] = "Hello, World!";
char c[] = "Hello, World!";
int n = 14;
memset(c, 'x', n);
ft_memset(ft, 'x', n);
exit(memcmp(ft, c, n));
}, ::testing::ExitedWithCode(0), "");
}
TEST(memset, non_printable)
{
ASSERT_EXIT({
char ft[] = "Hello, World!";
char c[] = "Hello, World!";
int n = 5;
memset(c, '\0', n);
ft_memset(ft, '\0', n);
exit(memcmp(ft, c, 14));
}, ::testing::ExitedWithCode(0), "");
}
TEST(memset, zero_length)
{
ASSERT_EXIT({
char ft[] = "Hello, World!";
char c[] = "Hello, World!";
int n = 0;
memset(c, 'x', n);
ft_memset(ft, 'x', n);
exit(memcmp(ft, c, 14));
}, ::testing::ExitedWithCode(0), "");
}
TEST(memset, cast)
{
ASSERT_EXIT({
char ft[20];
char c[20];
int n = 20;
memset(ft, 256, n);
ft_memset(c, 256, n);
exit(memcmp(ft, c, n));
}, ::testing::ExitedWithCode(0), "");
}
TEST(memsetDeathTest, nullptr)
{
ASSERT_EXIT({
char *ft = nullptr;
int n = 5;
ft_memset(ft, 'x', n);
exit(0);
}, ::testing::ExitedWithCode(0), "");
}