From 40db61eb7a2019ced97f09a9687139f35749f4e0 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Sat, 25 Feb 2023 21:37:48 +0100 Subject: Introduce vec and hashmap Convenience macros for a hashmap and a growable vector. --- test/command.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/command.c') diff --git a/test/command.c b/test/command.c index 52a67ac..e09cf35 100644 --- a/test/command.c +++ b/test/command.c @@ -3,12 +3,14 @@ #include "command.h" #include "hash.h" +#include "hashmap.h" void test_command_registry_create() { struct commands cmds = command_registry_create(10); - ASSERT(cmds.capacity == 10, "Expected capacity to be the specified value"); - ASSERT(cmds.ncommands == 0, + ASSERT(HASHMAP_CAPACITY(&cmds.commands) == 10, + "Expected capacity to be the specified value"); + ASSERT(HASHMAP_SIZE(&cmds.commands) == 0, "Expected number of commands to initially be empty"); command_registry_destroy(&cmds); @@ -41,7 +43,7 @@ void test_register_command() { }; register_command(&cmds, cmd); - ASSERT(cmds.ncommands == 1, + ASSERT(HASHMAP_SIZE(&cmds.commands) == 1, "Expected number of commands to be 1 after inserting one"); struct command multi[] = { @@ -50,9 +52,9 @@ void test_register_command() { }; register_commands(&cmds, multi, 2); - ASSERT(cmds.ncommands == 3, + ASSERT(HASHMAP_SIZE(&cmds.commands) == 3, "Expected number of commands to be 3 after inserting two more"); - ASSERT(cmds.capacity > 1, + ASSERT(HASHMAP_CAPACITY(&cmds.commands) > 1, "Expected capacity to have increased to accommodate new commands"); command_registry_destroy(&cmds); -- cgit v1.2.3