void
__test_enumerate(Journald *journald)
{
  const void *data;
  const void *prev_data;
  gsize length;
  gsize prev_len;
  gint result;

  journald_restart_data(journald);
  result = journald_enumerate_data(journald, &data, &length);
  assert_gint(result, 1, ASSERTION_ERROR("Data should exist"));

  prev_data = data;
  prev_len = length;

  result = journald_enumerate_data(journald, &data, &length);
  assert_gint(result, 1, ASSERTION_ERROR("Data should exist"));
  result = journald_enumerate_data(journald, &data, &length);
  assert_gint(result, 1, ASSERTION_ERROR("Data should exist"));
  result = journald_enumerate_data(journald, &data, &length);
  assert_gint(result, 0, ASSERTION_ERROR("Data should not exist"));

  journald_restart_data(journald);

  result = journald_enumerate_data(journald, &data, &length);
  assert_gint(result, 1, ASSERTION_ERROR("Data should exist"));
  assert_gpointer((gpointer )data, (gpointer )prev_data, ASSERTION_ERROR("restart data should seek the start of the data"));
  assert_gint(length, prev_len, ASSERTION_ERROR("Bad length after restart data"));

  result = journald_next(journald);
  assert_gint(result, 0, ASSERTION_ERROR("Should not contain more elements"));
}
Example #2
0
void
__test_enumerate(Journald *journald)
{
  const void *data;
  const void *prev_data;
  gsize length;
  gsize prev_len;
  gint result;

  journald_restart_data(journald);
  result = journald_enumerate_data(journald, &data, &length);
  cr_assert_eq(result, 1, "%s", "Data should exist");

  prev_data = data;
  prev_len = length;

  result = journald_enumerate_data(journald, &data, &length);
  cr_assert_eq(result, 1, "%s", "Data should exist");
  result = journald_enumerate_data(journald, &data, &length);
  cr_assert_eq(result, 1, "%s", "Data should exist");
  result = journald_enumerate_data(journald, &data, &length);
  cr_assert_eq(result, 0, "%s", "Data should not exist");

  journald_restart_data(journald);

  result = journald_enumerate_data(journald, &data, &length);
  cr_assert_eq(result, 1, "%s", "Data should exist");
  cr_assert_eq((gpointer )data, (gpointer )prev_data,
               "%s", "restart data should seek the start of the data");
  cr_assert_eq(length, prev_len, "%s", "Bad length after restart data");

  result = journald_next(journald);
  cr_assert_eq(result, 0, "%s", "Should not contain more elements");
}