Beispiel #1
0
void test_iterator(void)
{
  pn_list_t *list = build_list(0,
                               pn_string("one"),
                               pn_string("two"),
                               pn_string("three"),
                               pn_string("four"),
                               END);
  pn_iterator_t *it = pn_iterator();
  pn_it_state_t *state = (pn_it_state_t *) pn_iterator_start
    (it, pn_it_next, sizeof(pn_it_state_t));
  state->list = list;
  state->index = 0;

  void *obj;
  int index = 0;
  while ((obj = pn_iterator_next(it))) {
    assert(obj == pn_list_get(list, index++));
  }
  assert(index == 4);

  pn_free(list);
  pn_free(it);
}
Beispiel #2
0
pn_selectable_t *pn_selectables_next(pn_selectables_t *selectables)
{
  return (pn_selectable_t *) pn_iterator_next(selectables);
}