diff --git a/src/gesa.c b/src/gesa.c index 037b86aaddcc526c8b07181fc1d8f81162792df8..7484f71e17c1a207e072a8daf59f94307e4077a5 100644 --- a/src/gesa.c +++ b/src/gesa.c @@ -33,7 +33,9 @@ int GESA_create(GESA* const gesa, for (size_t i = 0; i < length; ++i) { - gesa->da[i] = 0; + gesa->sa[i] = 0; + gesa->lcp[i] = 0; + gesa->da[i] = 0; } // for return sais((GESA_char_t*) string, gesa->sa, gesa->lcp, (int) length); } // GESA_create diff --git a/tests/test_1.c b/tests/test_1.c index 2e374ffbcff2f9508d2c5ca9cc26302277881516..58da878ba2223a1af69aea9c4b8a89ad764fb8d9 100644 --- a/tests/test_1.c +++ b/tests/test_1.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "../include/gesa.h" #include "utils.h" @@ -17,19 +18,28 @@ int main(int argc, char* argv[]) GESA gesa; - assert(GESA_create(&gesa, (GESA_char_t*) "accttacgacgaccttcca~", 21) == 0); + //char const* const string = "accttacgacgaccttcca~"; + char const* const string = "acaaacatat~"; + size_t const length = strlen(string) + 1; + + printf("%ld\n", length); + + assert(GESA_create(&gesa, (GESA_char_t*) string, length) == 0); GESA_print(&gesa, stdout); - GESA_index_t* childtab = malloc(21 * sizeof(*childtab)); + GESA_index_t* childtab = malloc(length * sizeof(*childtab)); assert(childtab != 0); GESA_calculate_childtab(&gesa, childtab); - for (size_t i = 0; i < 21; ++i) + for (size_t i = 0; i < length - 1; ++i) { printf("%5ld %5d\n", i, childtab[i]); } // for + free(childtab); + GESA_destroy(&gesa, GESA_KEEP_STRINGS); + return EXIT_SUCCESS; } // main