From 82040403bfd6d7320223a73f24dbb8b73c5e48eb Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Sat, 24 Jun 2017 14:18:35 +0300 Subject: [PATCH] tests/hash: enable the test --- Makefile.am | 6 ++++++ tests/test_hash.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Makefile.am b/Makefile.am index c58bc4f..ac9b19b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -134,6 +134,7 @@ TESTS = \ tests/test_scram \ tests/test_ctx \ tests/test_base64 \ + tests/test_hash \ tests/test_jid \ tests/test_snprintf \ tests/test_string \ @@ -157,6 +158,11 @@ tests_test_base64_CFLAGS = $(STROPHE_FLAGS) -I$(top_srcdir)/src tests_test_base64_LDADD = $(STROPHE_LIBS) tests_test_base64_LDFLAGS = -static +tests_test_hash_SOURCES = tests/test_hash.c +tests_test_hash_CFLAGS = $(STROPHE_FLAGS) -I$(top_srcdir)/src +tests_test_hash_LDADD = $(STROPHE_LIBS) +tests_test_hash_LDFLAGS = -static + tests_test_jid_SOURCES = tests/test_jid.c tests_test_jid_CFLAGS = $(STROPHE_FLAGS) -I$(top_srcdir)/src tests_test_jid_LDADD = $(STROPHE_LIBS) diff --git a/tests/test_hash.c b/tests/test_hash.c index 6d4aa89..6910794 100644 --- a/tests/test_hash.c +++ b/tests/test_hash.c @@ -76,6 +76,18 @@ int main(int argc, char **argv) return 1; } + /* test replacing old values */ + for (i = 0; i < nkeys; i++) { + err = hash_add(table, keys[0], (void*)values[i]); + if (err) return err; + if (hash_num_keys(table) != nkeys) return 1; + result = hash_get(table, keys[0]); + if (result == NULL) return 1; + if (strcmp(result, values[i]) != 0) return 1; + } + /* restore value for the 1st key */ + hash_add(table, keys[0], (void*)values[0]); + /* test cloning */ clone = hash_clone(table);