#include <gtk/gtk.h>

int main( int argc, char *argv[])
{
  GtkTextBuffer *buffer;
  GtkTextIter iter;
  gboolean found;

  gtk_init(&argc, &argv);

  buffer = gtk_text_buffer_new(NULL);
  gtk_text_buffer_create_tag(buffer, "tag", "pixels_above_lines", 30, NULL);
  gtk_text_buffer_get_start_iter(buffer, &iter);

  /* Fill buffer with "test" string marked with "tag" tag */
  gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "test", -1, 
      "tag", NULL);

  /* From buffer end start searching next iterator position that toggles any 
   * tag */
  gtk_text_buffer_get_end_iter(buffer, &iter);
  found = gtk_text_iter_forward_to_tag_toggle(&iter, NULL);

  /* According to documentation:
   * <<If no matching tag toggles are found, returns FALSE, otherwise TRUE. 
   *   Does not return toggles located at iter, only toggles after iter.>> 
   * But it returns TRUE for toggle located at iter (at end).
   */
  printf("gtk_text_iter_forward_to_tag_toggle(<end>, NULL) returns: %d\n", 
      (gint)found); /* prints 1, but expected 0 */

  return 0;
}
