diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-07-14 15:28:50 +0300 |
---|---|---|
committer | Costa Tsaousis <costa@netdata.cloud> | 2022-07-14 15:28:50 +0300 |
commit | 38dbc8cac4dc565baadc252eff6ba8d92ed0e9ab (patch) | |
tree | 9aa7a5869fbfd4b54d4afa04560a6ec8d612a14e | |
parent | 635825572d3a4866153b661ffd454c0ffcbf77f5 (diff) |
fix string unittest when there are some strings already in the index
-rw-r--r-- | libnetdata/dictionary/dictionary.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c index 6a1ceaa2ea..0417c10906 100644 --- a/libnetdata/dictionary/dictionary.c +++ b/libnetdata/dictionary/dictionary.c @@ -2208,10 +2208,12 @@ int dictionary_unittest(size_t entries) { // check string { + long string_entries_starting = dictionary_stats_entries(&string_dictionary); + fprintf(stderr, "\nChecking strings...\n"); - STRING *s1 = string_strdupz("hello"); - STRING *s2 = string_strdupz("hello"); + STRING *s1 = string_strdupz("hello unittest"); + STRING *s2 = string_strdupz("hello unittest"); if(s1 != s2) { errors++; fprintf(stderr, "ERROR: duplicating strings are not deduplicated\n"); @@ -2235,7 +2237,7 @@ int dictionary_unittest(size_t entries) { else fprintf(stderr, "OK: string refcount is 3\n"); - STRING *s4 = string_strdupz("world"); + STRING *s4 = string_strdupz("world unittest"); if(s4 == s1) { errors++; fprintf(stderr, "ERROR: string is sharing pointers on different strings\n"); @@ -2270,9 +2272,9 @@ int dictionary_unittest(size_t entries) { freez(strings); - if(dictionary_stats_entries(&string_dictionary) != 2) { + if(dictionary_stats_entries(&string_dictionary) != string_entries_starting + 2) { errors++; - fprintf(stderr, "ERROR: strings dictionary should have 2 items but it has %ld\n", dictionary_stats_entries(&string_dictionary)); + fprintf(stderr, "ERROR: strings dictionary should have %ld items but it has %ld\n", string_entries_starting + 2, dictionary_stats_entries(&string_dictionary)); } else fprintf(stderr, "OK: strings dictionary has 2 items\n"); |