+ if (!iter)
+ {
+ yaz_log(YLOG_WARN, "test_iter: input=%s !iter", input);
+ return 0;
+ }
+
+ token = icu_buf_utf8_create(0);
+
+ if (icu_iter_next(iter, token))
+ {
+ yaz_log(YLOG_WARN, "test_iter: expecting 0 before icu_iter_first");
+ return 0;
+ }
+
+ result = wrbuf_alloc();
+ icu_iter_first(iter, input);
+ while (icu_iter_next(iter, token))
+ {
+ wrbuf_puts(result, "[");
+ wrbuf_write(result, (const char *) token->utf8, (int) token->utf8_len);
+ wrbuf_puts(result, "]");
+ }
+
+
+ second = wrbuf_alloc();
+ icu_iter_first(iter, input);
+ while (icu_iter_next(iter, token))
+ {
+ wrbuf_puts(second, "[");
+ wrbuf_write(second, (const char *) token->utf8, (int) token->utf8_len);
+ wrbuf_puts(second, "]");
+ }
+
+ icu_buf_utf8_destroy(token);
+ icu_iter_destroy(iter);
+
+ if (strcmp(expected, wrbuf_cstr(result)))
+ {
+ yaz_log(YLOG_WARN, "test_iter: input=%s expected=%s got=%s",
+ input, expected, wrbuf_cstr(result));
+ success = 0;
+ }
+
+ if (strcmp(expected, wrbuf_cstr(second)))
+ {
+ yaz_log(YLOG_WARN, "test_iter: input=%s expected=%s got=%s (2nd)",
+ input, expected, wrbuf_cstr(second));
+ success = 0;
+ }
+
+ wrbuf_destroy(result);
+ wrbuf_destroy(second);
+ return success;