-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathconfig_d03.pl
224 lines (202 loc) · 2.94 KB
/
config_d03.pl
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
ex00
ft_ft(int *nbr)
main ====
int main()
{
int v = 15;
ft_ft(&v);
printf("%d", v);
return 0;
}
====
check -e ====
$expected = '42';
====
ex01
ft_ultimate_ft(int *********nbr)
main ====
int main()
{
int a = 15;
int* b = &a;
int** c = &b;
int*** d = &c;
int**** e = &d;
int***** f = &e;
int****** g = &f;
int******* h = &g;
int******** i = &h;
int********* j = &i;
ft_ultimate_ft(j);
printf("%d", a);
return 0;
}
====
check -e ====
$expected = '42';
====
ex02
ft_swap(int *a, int *b)
main ====
int main()
{
int a = 15;
int b = -25;
ft_swap(&a, &b);
printf("%d,%d", a, b);
return 0;
}
====
check -e ====
$expected = '-25,15';
====
ex03
ft_div_mod(int a, int b, int *div, int *mod)
main ====
int main()
{
int div = 0, mod = 0;
ft_div_mod(40, 15, &div, &mod);
printf("%d,%d", div, mod);
return 0;
}
====
check -e ====
$expected = '2,10';
====
ex04
ft_ultimate_div_mod(int *a, int *b)
main ====
int main()
{
int a = 40, b = 15;
ft_ultimate_div_mod(&a, &b);
printf("%d,%d", a, b);
return 0;
}
====
check -e ====
$expected = '2,10';
====
ex05
ft_putstr(char *str)
main_basic ====
int main()
{
ft_putstr("hello world!");
return 0;
}
====
check_basic -e ====
$expected = 'hello world!';
====
main_multiple ====
int main()
{
ft_putstr("test1\n");
ft_putstr("test2\n");
ft_putstr("test3\n");
return 0;
}
====
check_multiple -e ====
$expected = "test1\ntest2\ntest3\n";
====
main_empty ====
int main ()
{
ft_putstr("");
ft_putstr("");
ft_putstr("");
return 0;
}
====
check_empty -e ====
$expected = '';
====
ex06
int ft_strlen(char *str)
main_basic ====
int main()
{
printf("%d,%d,%d", ft_strlen("asdf"), ft_strlen("qwerty"), ft_strlen("zxc0zxc"));
return 0;
}
====
check_basic -e ====
$expected = '4,6,7';
====
main_empty ====
int main()
{
printf("%d", ft_strlen(""));
return 0;
}
====
check_empty -e ====
$expected = '0';
====
ex07
char* ft_strrev(char *str)
main_basic ====
int main ()
{
char test1[] = "asdf";
printf("%s\n", ft_strrev(test1));
char test2[] = "qwert";
printf("%s\n", ft_strrev(test2));
char test3[] = "z";
printf("%s\n", ft_strrev(test3));
char test4[] = "bc";
printf("%s\n", ft_strrev(test4));
}
====
check_basic -e ====
$expected = "fdsa\ntrewq\nz\ncb\n";
====
main_empty ====
int main ()
{
char test[] = "";
printf("%s", ft_strrev(test));
}
====
check_empty -e ====
$expected = '';
====
ex08
int ft_atoi(char *str)
main_basic ====
int main()
{
printf("%d,%d,%d", ft_atoi("15"), ft_atoi("0"), ft_atoi("-25"));
return 0;
}
====
check_basic -e ====
$expected = '15,0,-25';
====
main_big ====
int main()
{
printf("%d,%d", ft_atoi("2147483647"), ft_atoi("-2147483648"));
}
====
check_big -e ====
$expected = '2147483647,-2147483648';
====
ex09
ft_sort_integer_table(int *tab, int size)
main_basic ====
int main()
{
int test1[] = {1,5,4,2,3};
int size = 5;
ft_sort_integer_table(test1, size);
for (int i = 0; i < size; i++)
printf("%d,", test1[i]);
}
====
check_basic -e ====
$expected = join '', map "$_,", 1 .. 5;
====