#include <stdlib.h>
#include "curl_config.h"
#include "setup.h"

#include "llist.h"

#include <check.h>

struct curl_llist *llist;

void test_curl_llist_dtor(void *key , void *value)
{
  // nothing for now
}

void setup( void )
{
  llist = Curl_llist_alloc( test_curl_llist_dtor );
}

void teardown( void )
{
  free( llist );
}

START_TEST( test_llist_initiate )
{
  fail_unless( llist->size == 0 , "list initial size should be zero" );
  fail_unless( llist->head == NULL , "list head should initiate to NULL" );
  fail_unless( llist->tail == NULL , "list tail should intiate to NULL" );
  fail_unless( llist->dtor == test_curl_llist_dtor , "list dtor shold initiate to test_curl_llist_dtor" );
}
END_TEST

Suite *
llist_suit (void)
{
  Suite *s = suite_create ("Curl_llust");

  /* Core test case */
  TCase *tc_core = tcase_create ("Core");
  tcase_add_checked_fixture (tc_core, setup, teardown);
  tcase_add_test (tc_core, test_llist_initiate);
  suite_add_tcase (s, tc_core);


  return s;
}

int main( void )
{
  int number_failed = 0;
  Suite *s = llist_suit ();
  SRunner *sr = srunner_create (s);
  srunner_run_all (sr, CK_NORMAL);
  number_failed = srunner_ntests_failed (sr);
  srunner_free (sr);
  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}