diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2019-08-05 20:57:15 +0200 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2019-08-05 20:57:15 +0200 |
commit | 66f4b6b7495cda05fed904c53dd8d04e35538653 (patch) | |
tree | 18630495eb0f6ba6769584c34b0c66acf3339967 /test/core.c | |
parent | 7347610dfdc57045578cdba7e33806ab1d0e9a8a (diff) | |
download | d2tk-66f4b6b7495cda05fed904c53dd8d04e35538653.tar.xz |
base: use d2tk_hash_dict instead of *_foreach.
Diffstat (limited to 'test/core.c')
-rw-r--r-- | test/core.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/core.c b/test/core.c index 76c7a3f..5f77aea 100644 --- a/test/core.c +++ b/test/core.c @@ -27,25 +27,31 @@ static void _test_hash() { + const uint32_t bar = 12; const char *foo = "barbarbarbar"; - const uint64_t hash1 = d2tk_hash(foo, -1); + const uint64_t hash1 = d2tk_hash(&bar, sizeof(bar)); const uint64_t hash2 = d2tk_hash(foo, strlen(foo)); - assert(hash1 == hash2); + assert(hash1 != hash2); } static void _test_hash_foreach() { - const char *foo = "barbarbarbar"; - const char *bar = "foofoofoofoo"; + const uint32_t bar = 12; + const char *foo = "foofoofoofoo"; + + const d2tk_hash_dict_t dict [] = { + { foo, strlen(foo) }, + { &bar, sizeof(bar) }, + { NULL, 0 } + }; + + const uint64_t hash1 = d2tk_hash_dict(dict); - const uint64_t hash1 = d2tk_hash_foreach(foo, -1, - bar, -1, - NULL); const uint64_t hash2 = d2tk_hash_foreach(foo, strlen(foo), - bar, strlen(bar), + &bar, sizeof(bar), NULL); assert(hash1 == hash2); |