aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-12-21 16:56:05 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-12-21 16:56:05 +0100
commitcca3d303023d53b5d0af96751f379b2d0e28cd18 (patch)
treeabc9d454a06e9902d4424cebefce0564d864dd0f /core
parent869152604e454582a5e4a0908d4e7c88125c4e5b (diff)
downloadvis-cca3d303023d53b5d0af96751f379b2d0e28cd18.tar.gz
vis-cca3d303023d53b5d0af96751f379b2d0e28cd18.tar.xz
test/core: make core tests asan clean
Diffstat (limited to 'core')
-rw-r--r--core/Makefile2
-rw-r--r--core/array.c14
-rw-r--r--core/buffer.c5
-rw-r--r--core/text.c1
4 files changed, 19 insertions, 3 deletions
diff --git a/core/Makefile b/core/Makefile
index 6a2d672..d3d0fdd 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -30,7 +30,7 @@ array: config.h array.c ../../array.c
@${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${SRC} ${LDFLAGS} -o $@
debug: clean
- $(MAKE) CFLAGS_EXTRA='${CFLAGS_DEBUG}'
+ $(MAKE) CFLAGS_EXTRA='${CFLAGS_EXTRA} ${CFLAGS_DEBUG}'
coverage: clean
$(MAKE) CFLAGS_EXTRA='--coverage'
diff --git a/core/array.c b/core/array.c
index ced8e26..e6c0265 100644
--- a/core/array.c
+++ b/core/array.c
@@ -48,6 +48,8 @@ static void test_small_objects(void) {
array_clear(&arr);
ok(array_length(&arr) == 0 && array_get(&arr, 0) == NULL && errno == EINVAL, "Clear");
+
+ array_release(&arr);
}
static void test_large_objects(void) {
@@ -87,6 +89,8 @@ static void test_large_objects(void) {
array_clear(&arr);
ok(array_length(&arr) == 0 && array_get(&arr, 0) == NULL && errno == EINVAL, "Clear");
+
+ array_release(&arr);
}
static void test_pointers(void) {
@@ -100,9 +104,11 @@ static void test_pointers(void) {
for (size_t i = 0; i < len; i++) {
items[i] = malloc(sizeof(Item));
-
snprintf(items[i]->key, sizeof(items[i]->key), "key: %zu", i);
items[i]->value = values[i];
+ }
+
+ for (size_t i = 0; i < len; i++) {
Item *item;
ok(array_add_ptr(&arr, items[i]) && array_length(&arr) == i+1,
"Add item: %zu = %p", i, (void*)items[i]);
@@ -124,6 +130,12 @@ static void test_pointers(void) {
array_clear(&arr);
ok(array_length(&arr) == 0 && array_get_ptr(&arr, 0) == NULL && errno == EINVAL, "Clear");
+
+ for (size_t i = 0; i < len; i++) {
+ ok(array_add_ptr(&arr, items[i]) && array_length(&arr) == i+1,
+ "Re-add item: %zu = %p", i, (void*)items[i]);
+ }
+ array_release_full(&arr);
}
int main(int argc, char *argv[]) {
diff --git a/core/buffer.c b/core/buffer.c
index 05bbb12..14ad667 100644
--- a/core/buffer.c
+++ b/core/buffer.c
@@ -69,12 +69,15 @@ int main(int argc, char *argv[]) {
for (int i = 1; i <= 10; i++)
append &= buffer_appendf(&buf, "%d", i);
ok(append && compare0(&buf, "12345678910"), "Append formatted");
-
buffer_clear(&buf);
+
append = true;
for (int i = 1; i <= 10; i++)
append &= buffer_appendf(&buf, "");
ok(append && compare0(&buf, ""), "Append formatted empty string");
+ buffer_clear(&buf);
+
+ buffer_release(&buf);
return exit_status();
}
diff --git a/core/text.c b/core/text.c
index 7154b70..01aa322 100644
--- a/core/text.c
+++ b/core/text.c
@@ -132,6 +132,7 @@ int main(int argc, char *argv[]) {
ok(text_mark_get(txt, mof) == EPOS, "Mark in the middle deleted");
text_undo(txt);
ok(text_mark_get(txt, mof) == newpos, "Mark restored");
+ text_free(txt);
return exit_status();
}