-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisdigit.cpp
More file actions
124 lines (96 loc) · 2.66 KB
/
Copy pathisdigit.cpp
File metadata and controls
124 lines (96 loc) · 2.66 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* isdigit.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjurkows <kjurkows@student.42warsaw.pl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/06/17 13:56:42 by kjurkows #+# #+# */
/* Updated: 2026/06/25 17:48:28 by kjurkows ### ########.fr */
/* */
/* ************************************************************************** */
#include "_main.hpp"
#include <ctype.h>
TEST(isdigit, space)
{
const char ch = ' ';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, digit)
{
const char ch = '5';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, lowercase)
{
const char ch = 'a';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, uppercase)
{
const char ch = 'A';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, punctuation)
{
const char ch = '-';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, null_char)
{
const char ch = 0;
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, control_char)
{
const char ch = '\r';
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, non_ascii)
{
const char ch = 255;
const int c = !!isdigit(ch);
const int ft = !!ft_isdigit(ch);
ASSERT_EQ(c, ft);
}
TEST(isdigit, undefined_behavior)
{
int ch = 256 + 'a';
int d = 256 + '0';
int e = 256 + '-';
int f = 256 + ' ';
int g = 256 + '\r';
int h = -1;
const int c_ch = !!isdigit(ch);
const int ft_ch = !!ft_isdigit(ch);
const int c_d = !!isdigit(d);
const int ft_d = !!ft_isdigit(d);
const int c_e = !!isdigit(e);
const int ft_e = !!ft_isdigit(e);
const int c_f = !!isdigit(f);
const int ft_f = !!ft_isdigit(f);
const int c_g = !!isdigit(g);
const int ft_g = !!ft_isdigit(g);
const int c_h = !!isdigit(h);
const int ft_h = !!ft_isdigit(h);
EXPECT_EQ(c_ch, ft_ch);
EXPECT_EQ(c_d, ft_d);
EXPECT_EQ(c_e, ft_e);
EXPECT_EQ(c_f, ft_f);
EXPECT_EQ(c_g, ft_g);
EXPECT_EQ(c_h, ft_h);
}