From 5b0c6da1ebb9200713c6f4c958eb9c236deb58aa Mon Sep 17 00:00:00 2001 From: jkvis Date: Tue, 16 Jan 2018 14:09:41 +0100 Subject: [PATCH] More childtab examples --- src/gesa.c | 4 +++- tests/test_1.c | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gesa.c b/src/gesa.c index 037b86a..7484f71 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 2e374ff..58da878 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 -- GitLab