#include "acutest.h"
#include "config.h"
#include "mutt/mutt.h"
+#include "common.h"
void test_mutt_list_insert_head(void)
{
TEST_CHECK((newnode = mutt_list_insert_head(&listhead, NULL)) != NULL);
FREE(&newnode);
}
+
+ {
+ static const char *start_names[] = { "Amy", "Beth", "Cathy", NULL };
+ static const char *expected_names[] = { "Zelda", "Amy", "Beth", "Cathy", NULL };
+ char *insert = "Zelda";
+ struct ListHead start = test_list_create(start_names, false);
+ struct ListHead expected = test_list_create(expected_names, false);
+ TEST_CHECK(mutt_list_insert_head(&start, insert) != NULL);
+ TEST_CHECK(mutt_list_compare(&start, &expected) == true);
+ mutt_list_clear(&start);
+ mutt_list_clear(&expected);
+ }
+
+ {
+ static const char *expected_names[] = { "Zelda", NULL };
+ char *insert = "Zelda";
+ struct ListHead start = STAILQ_HEAD_INITIALIZER(start);
+ struct ListHead expected = test_list_create(expected_names, false);
+ TEST_CHECK(mutt_list_insert_head(&start, insert) != NULL);
+ TEST_CHECK(mutt_list_compare(&start, &expected) == true);
+ mutt_list_clear(&start);
+ mutt_list_clear(&expected);
+ }
+
+ {
+ static const char *start_names[] = { "Amy", "Beth", "Cathy", NULL };
+ static const char *expected_names[] = { "Zelda", "Amy", "Beth", "Cathy", NULL };
+ char *insert = "Zelda";
+ struct ListHead start = test_list_create(start_names, false);
+ struct ListHead expected = test_list_create(expected_names, false);
+ TEST_CHECK(mutt_list_insert_head(&start, insert) != NULL);
+ TEST_CHECK(mutt_list_compare(&start, &expected) == true);
+ mutt_list_clear(&start);
+ mutt_list_clear(&expected);
+ }
}