Skip to content

Commit c5931bc

Browse files
committed
map: hide test-only functions behind #ifdef
1 parent e65d273 commit c5931bc

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.POSIX:
22

33
CC = cc
4-
CFLAGS = -Wall -Wextra -Wpedantic -Wshadow -fsanitize=$(SANITIZERS)
4+
CFLAGS = -Wall -Wextra -Wpedantic -Wshadow -DTEST -fsanitize=$(SANITIZERS)
55
LDFLAGS = -fsanitize=$(SANITIZERS)
66
SANITIZERS = address,undefined
77

map_oa.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <assert.h>
1111
#include <stdbool.h>
1212
#include <stdint.h>
13-
#include <stdio.h>
1413
#include <stdlib.h>
1514
#include <string.h>
1615

@@ -173,6 +172,9 @@ static map* map_resize(map* m, size_t n_buckets) {
173172
return m;
174173
}
175174

175+
#ifdef TEST
176+
#include <stdio.h>
177+
176178
size_t map_n_buckets(const map* m) {
177179
return m->n_buckets;
178180
}
@@ -196,6 +198,8 @@ void map_print(const map* m, void print_value(void*)) {
196198
}
197199
}
198200

201+
#endif // TEST
202+
199203
struct map_iter map_iter_new(const map* m) {
200204
assert(m != NULL);
201205
struct map_iter it = {

map_sc.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <assert.h>
1111
#include <stdbool.h>
1212
#include <stdint.h>
13-
#include <stdio.h>
1413
#include <stdlib.h>
1514
#include <string.h>
1615

@@ -170,6 +169,9 @@ static map* map_resize(map* m, size_t n_buckets) {
170169
return m;
171170
}
172171

172+
#ifdef TEST
173+
#include <stdio.h>
174+
173175
size_t map_n_buckets(const map* m) {
174176
return m->n_buckets;
175177
}
@@ -191,6 +193,8 @@ void map_print(const map* m, void print_value(void*)) {
191193
}
192194
}
193195

196+
#endif // TEST
197+
194198
struct map_iter map_iter_new(const map* m) {
195199
assert(m != NULL);
196200
struct map_iter it = {

0 commit comments

Comments
 (0)