diff options
author | Luca Deri <deri@ntop.org> | 2020-06-29 19:09:38 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-06-29 19:09:38 +0200 |
commit | 2c263bc726c0a13302134b2b40e3677c9667e3f2 (patch) | |
tree | 2f98b9627f30748cd453ef4b136542b91dab670d /example/ndpiReader.c | |
parent | 93a4a4387af951a4680061bf4e1effa87fa65406 (diff) |
Added ndpi_bin_similarity() for computing bin similarity
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 2ded09888..6c851179c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -3110,6 +3110,26 @@ void test_lib() { /* *********************************************** */ +static void binUnitTest() { + struct ndpi_bin b1, b2; + u_int8_t num_bins = 32; + u_int32_t i; + + srand(time(NULL)); + + ndpi_init_bin(&b1, ndpi_bin_family8, num_bins), ndpi_init_bin(&b2, ndpi_bin_family8, num_bins); + + for(i=0; i<32; i++) + ndpi_inc_bin(&b1, rand() % num_bins), ndpi_inc_bin(&b2, rand() % num_bins); + + ndpi_bin_similarity(&b1, &b1, 0); + ndpi_bin_similarity(&b1, &b2, 0); + + ndpi_free_bin(&b1), ndpi_free_bin(&b2); +} + +/* *********************************************** */ + static void dgaUnitTest() { const char *dga[] = { "lbjamwptxz", @@ -3495,6 +3515,7 @@ int orginal_main(int argc, char **argv) { if(ndpi_info_mod == NULL) return -1; /* Internal checks */ + binUnitTest(); dgaUnitTest(); hllUnitTest(); bitmapUnitTest(); |