-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstriteri.cpp
More file actions
78 lines (63 loc) · 1.76 KB
/
Copy pathstriteri.cpp
File metadata and controls
78 lines (63 loc) · 1.76 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* striteri.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjurkows <kjurkows@student.42warsaw.pl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/06/19 13:36:29 by kjurkows #+# #+# */
/* Updated: 2026/06/25 17:51:05 by kjurkows ### ########.fr */
/* */
/* ************************************************************************** */
#include "_main.hpp"
TEST(striteri, basic)
{
char str[] = "0123456789";
static int i_r = 0;
ft_striteri(str, [](unsigned int i, char *c)
{
EXPECT_EQ(*c, '0' + i);
i_r++;
});
ASSERT_EQ(i_r, 10);
}
TEST(striteri, empty)
{
char str[] = "";
static int i_r = 0;
ft_striteri(str, [](unsigned int i, char *c)
{
(void)i;
(void)c;
i_r++;
});
ASSERT_EQ(i_r, 0);
}
TEST(striteri, change)
{
char str[] = "0123456789";
ft_striteri(str, [](unsigned int i, char *c)
{
*c = 'a' + i;
});
ASSERT_STREQ(str, "abcdefghij");
}
TEST(striteriDeathTest, nullptr_str)
{
ASSERT_EXIT({
char *str = nullptr;
ft_striteri(str, [](unsigned int i, char *c)
{
*c = *c + i;
});
exit(0);
}, ::testing::ExitedWithCode(0), "");
}
TEST(striteriDeathTest, nullptr_f)
{
ASSERT_EXIT({
char str[] = "Hello";
ft_striteri(str, nullptr);
exit(0);
}, ::testing::ExitedWithCode(0), "");
}