+static int test_uri(yaz_sparql_t s, const char *uri, const char *schema,
+ const char *expect)
+{
+ int ret = 0;
+ WRBUF addinfo = wrbuf_alloc();
+ WRBUF w = wrbuf_alloc();
+
+ int r = yaz_sparql_from_uri_wrbuf(s, addinfo, w, uri, schema);
+ if (expect)
+ {
+ if (!r)
+ {
+ if (!strcmp(expect, wrbuf_cstr(w)))
+ ret = 1;
+ else
+ {
+ yaz_log(YLOG_WARN, "test_sparql: uri=%s", uri);
+ yaz_log(YLOG_WARN, " expect: %s", expect);
+ yaz_log(YLOG_WARN, " got: %s", wrbuf_cstr(w));
+ }
+ }
+ else
+ {
+ yaz_log(YLOG_WARN, "test_sparql: uri=%s", uri);
+ yaz_log(YLOG_WARN, " expect: %s", expect);
+ yaz_log(YLOG_WARN, " got error: %d:%s", r, wrbuf_cstr(addinfo));
+ }
+ }
+ else
+ {
+ if (r)
+ ret = 1;
+ else
+ {
+ yaz_log(YLOG_WARN, "test_sparql: uri=%s", uri);
+ yaz_log(YLOG_WARN, " expect error");
+ yaz_log(YLOG_WARN, " got: %s", wrbuf_cstr(w));
+ }
+ }
+ wrbuf_destroy(w);
+ wrbuf_destroy(addinfo);
+ return ret;
+}
+
+