Пример #1
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);

}
Пример #2
0
OMX_ERRORTYPE
tiz_os_register_type (tiz_os_t * ap_os, const tiz_os_type_init_f a_type_init_f,
                      const OMX_STRING a_type_name)
{
  assert (ap_os);
  return os_register_type (ap_os, a_type_init_f, a_type_name,
                           tiz_map_size (ap_os->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);
}
Пример #4
0
void *
tiz_os_get_type (const tiz_os_t * ap_os, const char * a_type_name)
{
  void * res = NULL;
  assert (ap_os);
  assert (ap_os->p_map);
  assert (a_type_name);
  res = tiz_map_find (ap_os->p_map, (OMX_PTR) a_type_name);
  TIZ_TRACE (ap_os->p_hdl, "Get type [%s]->[%p] - total types [%d]",
             a_type_name, res, tiz_map_size (ap_os->p_map));
  if (!res)
    {
      if (OMX_ErrorNone
          == register_additional_type ((tiz_os_t *) ap_os, a_type_name))
        {
          print_types (ap_os);
          res = tiz_map_find (ap_os->p_map, (OMX_PTR) a_type_name);
        }
    }
  assert (res);
  return res;
}