1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
11 #include <yaz/rpn2cql.h>
12 #include <yaz/wrbuf.h>
13 #include <yaz/pquery.h>
15 static int compare(cql_transform_t ct, const char *pqf, const char *cql)
18 ODR odr = odr_createmem(ODR_ENCODE);
19 WRBUF w = wrbuf_alloc();
20 Z_RPNQuery *q = p_query_rpn(odr, pqf);
24 int r = cql_transform_rpn2cql_wrbuf(ct, w, q);
29 yaz_log(YLOG_LOG, "%s -> Error %d", pqf, r);
30 if (!cql) /* also expected error? */
35 yaz_log(YLOG_LOG, "%s -> %s", pqf, wrbuf_cstr(w));
36 if (cql && !strcmp(wrbuf_cstr(w), cql))
47 cql_transform_t ct = cql_transform_create();
48 YAZ_CHECK(compare(ct, "abc", "abc"));
49 YAZ_CHECK(compare(ct, "@and a b", "a and b"));
50 cql_transform_close(ct);
53 int main (int argc, char **argv)
55 YAZ_CHECK_INIT(argc, argv);
64 * indent-tabs-mode: nil
66 * vim: shiftwidth=4 tabstop=8 expandtab