This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arith_expr_test_1.c
69 lines (58 loc) · 1.74 KB
/
arith_expr_test_1.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* arith_expr_test_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mgautier <mgautier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/22 13:12:54 by mgautier #+# #+# */
/* Updated: 2018/01/22 13:12:54 by mgautier ### ########.fr */
/* */
/* ************************************************************************** */
#include "test_interface.h"
#include "libft.h"
#include <stdlib.h>
void *create_expr(__attribute__((unused))void const *no_val)
{
int *expr;
expr = malloc(sizeof(*expr));
if (expr != NULL)
*expr = 0;
return (expr);
}
t_bool give_expr(void *v_expr, void *to_give)
{
int *expr;
int *term;
expr = v_expr;
term = to_give;
*expr = *expr + *term;
free(term);
return (TRUE);
}
void *create_term(__attribute__((unused))void const *no_val)
{
int *term;
term = malloc(sizeof(*term));
if (term != NULL)
*term = 1;
return (term);
}
t_bool give_term(void *v_term, void *to_give)
{
int *term;
int *factor;
term = v_term;
factor = to_give;
*term = *term * *factor;
free(factor);
return (TRUE);
}
void *create_factor(__attribute__((unused))void const *no_val)
{
int *factor;
factor = malloc(sizeof(*factor));
if (factor != NULL)
*factor = 0;
return (factor);
}