closer leak debugging

This commit is contained in:
Enno Rehling 2016-09-05 20:05:36 +02:00
parent c525553c49
commit b62fa64d8c

View file

@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
#include "umlaut.h" #include "umlaut.h"
#ifdef LEAK_FREE
static void test_transliterate(CuTest * tc) static void test_transliterate(CuTest * tc)
{ {
char buffer[32]; char buffer[32];
@ -96,14 +97,15 @@ static void test_umlaut(CuTest * tc)
freetokens(tokens); freetokens(tokens);
} }
#endif
static void test_leak(CuTest *tc) { static void test_leak(CuTest *tc) {
void *tokens = NULL; void *tokens = NULL;
variant token; variant token;
token.i = 42; token.i = 42;
addtoken(&tokens, "NW", token); addtoken(&tokens, "No", token);
addtoken(&tokens, "northwest", token); addtoken(&tokens, "nw", token);
CuAssertIntEquals(tc, E_TOK_SUCCESS, findtoken(tokens, "n", &token)); CuAssertIntEquals(tc, E_TOK_SUCCESS, findtoken(tokens, "n", &token));
freetokens(tokens); freetokens(tokens);
} }
@ -111,10 +113,12 @@ static void test_leak(CuTest *tc) {
CuSuite *get_umlaut_suite(void) CuSuite *get_umlaut_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
#ifdef LEAK_FREE
SUITE_ADD_TEST(suite, test_umlaut); SUITE_ADD_TEST(suite, test_umlaut);
SUITE_ADD_TEST(suite, test_directions); SUITE_ADD_TEST(suite, test_directions);
SUITE_ADD_TEST(suite, test_transliterate); SUITE_ADD_TEST(suite, test_transliterate);
SUITE_ADD_TEST(suite, test_transliterations); SUITE_ADD_TEST(suite, test_transliterations);
#endif
SUITE_ADD_TEST(suite, test_leak); SUITE_ADD_TEST(suite, test_leak);
return suite; return suite;
} }