|
@@ -15,87 +15,114 @@
|
15
|
15
|
extern rbtree_t *MEMORY_INFO;
|
16
|
16
|
bool check_red_black_tree(rbtree_t *current, bool valid, bool strict);
|
17
|
17
|
|
|
18
|
+int *i, *j, *k;
|
|
19
|
+float *l, *m, *n;
|
|
20
|
+
|
|
21
|
+void integerTeardown(void *) {
|
|
22
|
+ free(i);
|
|
23
|
+ free(j);
|
|
24
|
+ free(k);
|
|
25
|
+}
|
|
26
|
+
|
|
27
|
+void floatTeardown(void *) {
|
|
28
|
+ free(l);
|
|
29
|
+ free(m);
|
|
30
|
+ free(n);
|
|
31
|
+}
|
|
32
|
+
|
18
|
33
|
TEST singleInteger() {
|
19
|
|
- int *i = new int;
|
|
34
|
+ i = new int;
|
20
|
35
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
21
|
36
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), sizeof(int));
|
22
|
37
|
|
23
|
38
|
delete i;
|
|
39
|
+ i = NULL;
|
24
|
40
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
25
|
41
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
26
|
42
|
PASS();
|
27
|
43
|
}
|
28
|
44
|
|
29
|
45
|
TEST arrayInteger() {
|
30
|
|
- int *i = new int[3];
|
|
46
|
+ i = new int[3];
|
31
|
47
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
32
|
48
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 3 * sizeof(int));
|
33
|
49
|
|
34
|
50
|
delete [] i;
|
|
51
|
+ i = NULL;
|
35
|
52
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
36
|
53
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
37
|
54
|
PASS();
|
38
|
55
|
}
|
39
|
56
|
|
40
|
57
|
TEST arrayCombinedInteger() {
|
41
|
|
- int *i = new int[3];
|
42
|
|
- int *j = new int;
|
43
|
|
- int *k = new int[3];
|
|
58
|
+ i = new int[3];
|
|
59
|
+ j = new int;
|
|
60
|
+ k = new int[3];
|
44
|
61
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
45
|
62
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 7 * sizeof(int));
|
46
|
63
|
|
47
|
64
|
delete [] i;
|
48
|
65
|
delete j;
|
49
|
66
|
delete [] k;
|
|
67
|
+ i = NULL;
|
|
68
|
+ j = NULL;
|
|
69
|
+ k = NULL;
|
50
|
70
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
51
|
71
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
52
|
72
|
PASS();
|
53
|
73
|
}
|
54
|
74
|
|
55
|
75
|
SUITE(integerSuite) {
|
|
76
|
+ SET_TEARDOWN(integerTeardown, NULL);
|
56
|
77
|
RUN_TEST(singleInteger);
|
57
|
78
|
RUN_TEST(arrayInteger);
|
58
|
79
|
RUN_TEST(arrayCombinedInteger);
|
59
|
80
|
}
|
60
|
81
|
|
61
|
82
|
TEST singleFloat() {
|
62
|
|
- float *i = new float;
|
|
83
|
+ l = new float;
|
63
|
84
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
64
|
85
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), sizeof(float));
|
65
|
86
|
|
66
|
|
- delete i;
|
|
87
|
+ delete l;
|
|
88
|
+ l = NULL;
|
67
|
89
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
68
|
90
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
69
|
91
|
PASS();
|
70
|
92
|
}
|
71
|
93
|
|
72
|
94
|
TEST arrayFloat() {
|
73
|
|
- float *i = new float[3];
|
|
95
|
+ l = new float[3];
|
74
|
96
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
75
|
97
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 3 * sizeof(float));
|
76
|
98
|
|
77
|
|
- delete [] i;
|
|
99
|
+ delete [] l;
|
|
100
|
+ l = NULL;
|
78
|
101
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
79
|
102
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
80
|
103
|
PASS();
|
81
|
104
|
}
|
82
|
105
|
|
83
|
106
|
TEST arrayCombinedFloat() {
|
84
|
|
- float *i = new float[3];
|
85
|
|
- float *j = new float;
|
86
|
|
- float *k = new float[3];
|
|
107
|
+ l = new float[3];
|
|
108
|
+ m = new float;
|
|
109
|
+ n = new float[3];
|
87
|
110
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
88
|
111
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 7 * sizeof(float));
|
89
|
112
|
|
90
|
|
- delete [] i;
|
91
|
|
- delete j;
|
92
|
|
- delete [] k;
|
|
113
|
+ delete [] l;
|
|
114
|
+ delete m;
|
|
115
|
+ delete [] n;
|
|
116
|
+ l = NULL;
|
|
117
|
+ m = NULL;
|
|
118
|
+ n = NULL;
|
93
|
119
|
ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
|
94
|
120
|
ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
|
95
|
121
|
PASS();
|
96
|
122
|
}
|
97
|
123
|
|
98
|
124
|
SUITE(floatSuite) {
|
|
125
|
+ SET_TEARDOWN(floatTeardown, NULL);
|
99
|
126
|
RUN_TEST(singleFloat);
|
100
|
127
|
RUN_TEST(arrayFloat);
|
101
|
128
|
RUN_TEST(arrayCombinedFloat);
|