+static int test_iter(struct icu_chain *chain, const char *input,
+ const char *expected)
+{
+ struct icu_iter *iter = icu_iter_create(chain, input);
+ WRBUF result;
+ struct icu_buf_utf8 *token;
+
+ if (!iter)
+ {
+ yaz_log(YLOG_WARN, "test_iter: input=%s !iter", input);
+ return 0;
+ }
+
+ token = icu_buf_utf8_create(0);
+ result = wrbuf_alloc();
+ while (icu_iter_next(iter, token))
+ {
+ wrbuf_puts(result, "[");
+ wrbuf_write(result, (const char *) token->utf8, (int) token->utf8_len);
+ wrbuf_puts(result, "]");
+ }
+ 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));
+ wrbuf_destroy(result);
+ return 0;
+ }
+ wrbuf_destroy(result);
+ return 1;
+}
+
+static void *iter_thread(void *p)
+{
+ struct icu_chain *chain = (struct icu_chain *) p;
+ int i;
+
+ for (i = 0; i < 10000; i++)
+ {
+ YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
+ "[adobe][acrobat][reader][1991][][1999][]"));
+ }
+ return 0;
+}