-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests_2.c
82 lines (70 loc) · 2.59 KB
/
tests_2.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
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "tests_2.h"
void double_t2_gs_elem_dump(FILE *file, double x)
{
fprintf(file, " %lf ", x * 4);
}
void int_t2_gs_elem_dump(FILE *file, int x)
{
fprintf(file, " %d ", x / 2);
}
int test_2()
{
generic_stack_double_t2 *zd = new_generic_stack_ptr(double)(5);
generic_stack_push(double)(zd, 13);
generic_stack_push(double)(zd, 12.0);
generic_stack_push(double)(zd, 11);
generic_stack_push(double)(zd, 10);
generic_stack_pop(double)(zd);
generic_stack_pop(double)(zd);
//zd->size++;//crash by hash
generic_stack_push(double)(zd, 10);
generic_stack_push(double)(zd, 10);
generic_stack_push(double)(zd, 9);
generic_stack_pop(double)(zd);
generic_stack_push(double)(zd, 8);
generic_stack_push(double)(zd, 7);
generic_stack_push(double)(zd, 6);
generic_stack_push(double)(zd, 5.32);
generic_stack_pop(double)(zd);
generic_stack_push(double)(zd, 5.30);
generic_stack_push(double)(zd, 5.27);
generic_stack_push(double)(zd, 5.21);
generic_stack_push(double)(zd, 11.21);
generic_stack_push(double)(zd, 13.212);
generic_stack_double_t2 *zd2 = new_generic_stack_ptr(double)(77);
generic_stack(double) zd3 = new_generic_stack_double_t2(77);
generic_stack(int) zi = new_generic_stack_int_t2(7);
generic_stack(int) zi2 = new_generic_stack(int)(17);
generic_stack_empty(double)(zd);
generic_stack_double_t2 *gs_d_4 = new_generic_stack_ptr_double_t2(0);
generic_stack_push(double)(gs_d_4, 10);
generic_stack_pop(double)(gs_d_4);
generic_stack_push(double)(gs_d_4, 9);
generic_stack_push(double)(gs_d_4, 8);
generic_stack(double) *zd_p = zd;
GENERIC_STACK_LOG(double, zd_p, 20, "");
GENERIC_STACK_LOG(int, (&zi), 20, "{JUST CHECK:T2}");
#ifdef GENERIC_STACK_LOG_PSOTFIX_0xEF542EH4
printf("%lf\n", generic_stack_pop(double)(gs_d_4));
#endif
free_generic_stack(double)(zd);
free_generic_stack(double)(zd2);
free_generic_stack(double)(&zd3);
free_generic_stack(double)(gs_d_4);
free_generic_stack(int)(&zi);
free_generic_stack(int)(&zi2);
generic_stack(int) *gs_i = new_generic_stack_ptr(int)(0);
for (int i = 0; i < 25; i++) {
generic_stack_push(int)(gs_i, i * 4);
}
GENERIC_STACK_LOG(int, gs_i, -1, "");
for (int i = 24; i >= 5; i--) {
if (i * 4 != generic_stack_pop(int)(gs_i)) {
printf("WRONG VALUE\n");
exit(1);
}
}
GENERIC_STACK_LOG(int, gs_i, -1, "");
free_generic_stack(int)(gs_i);
return 0;
}