예제 #1
0
void
tiz_os_destroy (tiz_os_t * ap_os)
{
  if (ap_os)
    {
      while (!tiz_map_empty (ap_os->p_map))
        {
          tiz_map_erase_at (ap_os->p_map, 0);
        };
      tiz_map_destroy (ap_os->p_map);
      os_free (ap_os->p_soa, ap_os);
    }
}
예제 #2
0
END_TEST

START_TEST (test_map_insert_find_erase_size_empty_at_for_each)
{
  OMX_U32 i;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  int *p_item = NULL;
  tiz_map_t *p_map = NULL;;
  OMX_U32 index = 0;

  error = tiz_map_init (&p_map, check_map_cmp_f, check_map_free_f, NULL);
  fail_if (error != OMX_ErrorNone);

  fail_if (false == tiz_map_empty (p_map));

  for (i = 0; i < 10; i++)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;
      error = tiz_map_insert (p_map, p_item, p_item, &index);
      fail_if (error != OMX_ErrorNone);
      fail_if (index != i);
      fail_if (tiz_map_size (p_map) != i+1);
    }

  fail_if (10 != tiz_map_size (p_map));
  fail_if (true == tiz_map_empty (p_map));

  i = 5;
  fail_if (5 != *(p_item = tiz_map_find (p_map, &i)));

  fail_if (5 != *(p_item = tiz_map_value_at (p_map, i)));

  fail_if (OMX_ErrorNone != tiz_map_for_each (p_map,
                                              check_map_for_each_f,
                                              NULL));


  for (i = 0; i < 10; i++)
    {
      int d = i;
      tiz_map_erase (p_map, &d);
      fail_if (tiz_map_size (p_map) != 9-i);
    }

  tiz_map_destroy (p_map);

}
예제 #3
0
END_TEST

START_TEST (test_map_clear)
{
  OMX_U32 i;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  int *p_item = NULL;
  tiz_map_t *p_map = NULL;;
  OMX_U32 index = 0;

  error = tiz_map_init (&p_map, check_map_cmp_f, check_map_free_f, NULL);
  fail_if (error != OMX_ErrorNone);

  fail_if (false == tiz_map_empty (p_map));

  for (i = 0; i < 10; i++)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;
      error = tiz_map_insert (p_map, p_item, p_item, &index);
      fail_if (error != OMX_ErrorNone);
      fail_if (index != i);
      fail_if (tiz_map_size (p_map) != i+1);
    }

  fail_if (10 != tiz_map_size (p_map));
  fail_if (true == tiz_map_empty (p_map));

  fail_if (OMX_ErrorNone != tiz_map_clear (p_map));

  fail_if (0 != tiz_map_size (p_map));
  fail_if (false == tiz_map_empty (p_map));

  tiz_map_destroy (p_map);
}