void test_mutt_hash_delete(void)
{
// void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data);
+
+ {
+ mutt_hash_delete(NULL, "apple", "banana");
+ TEST_CHECK_(1, "mutt_hash_delete(NULL, \"apple\", \"banana\")");
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ mutt_hash_delete(hash, NULL, "banana");
+ TEST_CHECK_(1, "mutt_hash_delete(hash, NULL, \"banana\")");
+ mutt_hash_free(&hash);
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ mutt_hash_delete(hash, "apple", NULL);
+ TEST_CHECK_(1, "mutt_hash_delete(hash, \"apple\", NULL)");
+ mutt_hash_free(&hash);
+ }
}
void test_mutt_hash_find(void)
{
// void *mutt_hash_find(const struct Hash *table, const char *strkey);
+
+ {
+ TEST_CHECK(!mutt_hash_find(NULL, "apple"));
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ TEST_CHECK(!mutt_hash_find(hash, "apple"));
+ mutt_hash_free(&hash);
+ }
}
void test_mutt_hash_find_bucket(void)
{
// struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey);
+
+ {
+ TEST_CHECK(!mutt_hash_find_bucket(NULL, "apple"));
+ }
+
+ {
+ struct Hash hash = { 0 };
+ TEST_CHECK(!mutt_hash_find_bucket(&hash, NULL));
+ }
}
void test_mutt_hash_find_elem(void)
{
// struct HashElem *mutt_hash_find_elem(const struct Hash *table, const char *strkey);
+
+ {
+ TEST_CHECK(!mutt_hash_find_elem(NULL, "apple"));
+ }
+
+ {
+ struct Hash hash = { 0 };
+ TEST_CHECK(!mutt_hash_find_elem(&hash, NULL));
+ }
}
void test_mutt_hash_free(void)
{
// void mutt_hash_free(struct Hash **ptr);
+
+ {
+ mutt_hash_free(NULL);
+ TEST_CHECK_(1, "mutt_hash_free(NULL)");
+ }
+
+ {
+ struct Hash *hash = NULL;
+ mutt_hash_free(&hash);
+ TEST_CHECK_(1, "mutt_hash_free(&hash)");
+ }
}
void test_mutt_hash_insert(void)
{
// struct HashElem *mutt_hash_insert(struct Hash *table, const char *strkey, void *data);
+
+ {
+ TEST_CHECK(!mutt_hash_insert(NULL, "apple", "banana"));
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ TEST_CHECK(!mutt_hash_insert(hash, NULL, "banana"));
+ mutt_hash_free(&hash);
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ TEST_CHECK(mutt_hash_insert(hash, "apple", NULL) != NULL);
+ mutt_hash_free(&hash);
+ }
}
void test_mutt_hash_int_delete(void)
{
// void mutt_hash_int_delete(struct Hash *table, unsigned int intkey, const void *data);
+
+ {
+ mutt_hash_int_delete(NULL, 0, "apple");
+ TEST_CHECK_(1, "mutt_hash_int_delete(NULL, 0, \"apple\")");
+ }
+
+ {
+ struct Hash *hash = mutt_hash_int_new(10, MUTT_HASH_NO_FLAGS);
+ mutt_hash_int_delete(hash, 0, NULL);
+ TEST_CHECK_(1, "mutt_hash_int_delete(hash, 0, NULL)");
+ mutt_hash_free(&hash);
+ }
}
void test_mutt_hash_int_find(void)
{
// void *mutt_hash_int_find(const struct Hash *table, unsigned int intkey);
+
+ {
+ mutt_hash_int_find(NULL, 0);
+ TEST_CHECK_(1, "mutt_hash_int_find(NULL, 0)");
+ }
}
void test_mutt_hash_int_insert(void)
{
// struct HashElem *mutt_hash_int_insert(struct Hash *table, unsigned int intkey, void *data);
+
+ {
+ TEST_CHECK(!mutt_hash_int_insert(NULL, 0, "apple"));
+ }
+
+ {
+ struct Hash *hash = mutt_hash_int_new(10, MUTT_HASH_NO_FLAGS);
+ TEST_CHECK(mutt_hash_int_insert(hash, 0, NULL) != NULL);
+ mutt_hash_free(&hash);
+ }
}
#include "config.h"
#include "mutt/mutt.h"
+void dummy_free(int type, void *obj, intptr_t data)
+{
+}
+
void test_mutt_hash_set_destructor(void)
{
// void mutt_hash_set_destructor(struct Hash *table, hashelem_free_t fn, intptr_t fn_data);
+
+ {
+ hashelem_free_t fn = dummy_free;
+ mutt_hash_set_destructor(NULL, fn, (intptr_t) "apple");
+ TEST_CHECK_(1, "mutt_hash_set_destructor(NULL, fn, \"apple\")");
+ }
+
+ {
+ struct Hash hash = { 0 };
+ mutt_hash_set_destructor(&hash, NULL, (intptr_t) "apple");
+ TEST_CHECK_(1, "mutt_hash_set_destructor(&hash, NULL, \"apple\")");
+ }
+
+ {
+ struct Hash hash = { 0 };
+ hashelem_free_t fn = dummy_free;
+ mutt_hash_set_destructor(&hash, fn, 0);
+ TEST_CHECK_(1, "mutt_hash_set_destructor(&hash, fn, NULL)");
+ }
}
void test_mutt_hash_typed_insert(void)
{
// struct HashElem *mutt_hash_typed_insert(struct Hash *table, const char *strkey, int type, void *data);
+
+ {
+ TEST_CHECK(!mutt_hash_typed_insert(NULL, "apple", 0, "banana"));
+ }
+
+ {
+ struct Hash hash = { 0 };
+ TEST_CHECK(!mutt_hash_typed_insert(&hash, NULL, 0, "banana"));
+ }
+
+ {
+ struct Hash *hash = mutt_hash_new(10, MUTT_HASH_NO_FLAGS);
+ TEST_CHECK(mutt_hash_typed_insert(hash, "apple", 0, NULL) != NULL);
+ mutt_hash_free(&hash);
+ }
}
void test_mutt_hash_walk(void)
{
// struct HashElem *mutt_hash_walk(const struct Hash *table, struct HashWalkState *state);
+
+ {
+ struct HashWalkState hashwalkstate = { 0 };
+ TEST_CHECK(!mutt_hash_walk(NULL, &hashwalkstate));
+ }
+
+ {
+ struct Hash hash = { 0 };
+ TEST_CHECK(!mutt_hash_walk(&hash, NULL));
+ }
}