Bump copyright year
[idzebra-moved-to-github.git] / test / rusmarc / t1.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 2004-2013 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <yaz/yaz-iconv.h>
24
25 #include "../api/testlib.h"
26
27 void check_koi8r(void)
28 {
29     yaz_iconv_t cd = yaz_iconv_open("koi8-r", "utf-8");
30     if (!cd)
31     {
32         yaz_log(YLOG_WARN, "koi8-r to utf-8 unsupported");
33         exit(0);
34     }
35     yaz_iconv_close(cd);
36 }
37
38 static void tst(int argc, char **argv)
39 {
40
41     ZebraService zs = tl_start_up(0, argc, argv);
42     ZebraHandle  zh = zebra_open(zs, 0);
43     char path[256];
44
45     check_koi8r();
46
47     YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
48
49     zebra_init(zh);
50
51     YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK);
52     sprintf(path, "%.200s/records/simple-rusmarc", tl_get_srcdir());
53     zebra_repository_update(zh, path);
54     YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
55     zebra_commit(zh);
56
57     YAZ_CHECK(tl_query(zh, "@attr 1=21 \xfa\xc1\xcd\xd1\xd4\xc9\xce", 1));
58
59     YAZ_CHECK(tl_close_down(zh, zs));
60 }
61
62 TL_MAIN
63 /*
64  * Local variables:
65  * c-basic-offset: 4
66  * c-file-style: "Stroustrup"
67  * indent-tabs-mode: nil
68  * End:
69  * vim: shiftwidth=4 tabstop=8 expandtab
70  */
71