diff options
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 168bd7b15..618f10524 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -2,6 +2,7 @@ * ndpiReader.c * * Copyright (C) 2011-16 - ntop.org + * * nDPI is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -40,7 +41,7 @@ #include <signal.h> #include <pthread.h> #include <sys/socket.h> - +#include <assert.h> #include "../config.h" #include "ndpi_api.h" @@ -1302,6 +1303,18 @@ void test_lib() { } } +void automataUnitTest() { + void *automa; + + set_ndpi_malloc(malloc_wrapper), set_ndpi_free(free_wrapper); + assert(automa = ndpi_init_automa()); + assert(ndpi_add_string_to_automa(automa, "hello") == 0); + assert(ndpi_add_string_to_automa(automa, "world") == 0); + ndpi_finalize_automa(automa); + assert(ndpi_match_string(automa, "This is the wonderful world of nDPI") == 0); + + ndpi_free_automa(automa); +} /** @brief MAIN FUNCTION @@ -1310,6 +1323,8 @@ int main(int argc, char **argv) { int i; + automataUnitTest(); + memset(ndpi_thread_info, 0, sizeof(ndpi_thread_info)); memset(&pcap_start, 0, sizeof(pcap_start)); memset(&pcap_end, 0, sizeof(pcap_end)); |