Release 1.6.4
[yazpp-moved-to-github.git] / src / test_query.cpp
1 /* This file is part of the yazpp toolkit.
2  * Copyright (C) Index Data 
3  * See the file LICENSE for details.
4  */
5
6 #if HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 #include <stdlib.h>
10 #include <yazpp/z-query.h>
11 #include <yaz/test.h>
12 #include <yaz/log.h>
13
14 using namespace yazpp_1;
15
16 int tst1(const char *query_str_in, const char *query_expected)
17 {
18     Yaz_Z_Query q;
19
20     q = query_str_in;
21
22     Yaz_Z_Query q2;
23
24     q2 = q;
25
26     char query_str_out[100];
27     q2.print(query_str_out, sizeof(query_str_out)-1);
28
29     if (strcmp(query_str_out, query_expected))
30     {
31         yaz_log(YLOG_LOG, "query mismatch out=%s expected=%s",
32                 query_str_out, query_expected);
33         return 0;
34     }
35     return 1;
36 }
37
38 int main(int argc, char **argv)
39 {
40     YAZ_CHECK_INIT(argc, argv);
41     YAZ_CHECK(tst1("", ""));
42     YAZ_CHECK(tst1("x", "RPN @attrset Bib-1 x"));
43     YAZ_CHECK(tst1("@and a b", "RPN @attrset Bib-1 @and a b"));
44     YAZ_CHECK_TERM;
45 }
46
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * c-file-style: "Stroustrup"
51  * indent-tabs-mode: nil
52  * End:
53  * vim: shiftwidth=4 tabstop=8 expandtab
54  */
55