1 /* This file is part of the Zebra server.
2 Copyright (C) 1995-2008 Index Data
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
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
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
20 #include <idzebra/bfile.h>
24 static void tst1(zebra_sort_index_t si)
26 zint sysno = 12; /* just some sysno */
27 int my_type = 2; /* just some type ID */
28 WRBUF w = wrbuf_alloc();
30 zebra_sort_type(si, my_type);
32 zebra_sort_sysno(si, sysno);
33 YAZ_CHECK_EQ(zebra_sort_read(si, w), 0);
35 zebra_sort_add(si, "abcde1", 6);
37 zebra_sort_sysno(si, sysno);
38 YAZ_CHECK_EQ(zebra_sort_read(si, w), 1);
39 YAZ_CHECK(!strcmp(wrbuf_cstr(w), "abcde1"));
41 zebra_sort_sysno(si, sysno+1);
42 YAZ_CHECK_EQ(zebra_sort_read(si, w), 0);
44 zebra_sort_sysno(si, sysno-1);
45 YAZ_CHECK_EQ(zebra_sort_read(si, w), 0);
47 zebra_sort_sysno(si, sysno);
48 zebra_sort_delete(si);
49 YAZ_CHECK_EQ(zebra_sort_read(si, w), 0);
51 zebra_sort_type(si, my_type);
53 zebra_sort_sysno(si, sysno);
54 YAZ_CHECK_EQ(zebra_sort_read(si, w), 0);
57 zebra_sort_add(si, "abcde1", 6);
59 zebra_sort_sysno(si, sysno);
60 YAZ_CHECK_EQ(zebra_sort_read(si, w), 1);
61 YAZ_CHECK(!strcmp(wrbuf_cstr(w), "abcde1"));
63 zebra_sort_sysno(si, sysno);
64 zebra_sort_delete(si);
69 static void tst2(zebra_sort_index_t si)
71 zint sysno = 15; /* just some sysno */
72 int my_type = 2; /* just some type ID */
75 zebra_sort_type(si, my_type);
77 for (sysno = 1; sysno < 50; sysno++)
79 WRBUF w1 = wrbuf_alloc();
80 WRBUF w2 = wrbuf_alloc();
81 zebra_sort_sysno(si, sysno);
82 YAZ_CHECK_EQ(zebra_sort_read(si, w2), 0);
84 for (i = 0; i < 600; i++) /* 600 * 6 < max size =4K */
85 wrbuf_write(w1, "12345", 6);
87 zebra_sort_add(si, wrbuf_buf(w1), wrbuf_len(w1));
89 zebra_sort_sysno(si, sysno);
91 YAZ_CHECK_EQ(zebra_sort_read(si, w2), 1);
93 YAZ_CHECK_EQ(wrbuf_len(w1), wrbuf_len(w2));
94 YAZ_CHECK(!memcmp(wrbuf_buf(w1), wrbuf_buf(w2), wrbuf_len(w2)));
100 static void tst(int argc, char **argv)
102 BFiles bfs = bfs_create(".:50M", 0);
103 zebra_sort_index_t si;
109 si = zebra_sort_open(bfs, 1, ZEBRA_SORT_TYPE_FLAT);
114 zebra_sort_close(si);
120 si = zebra_sort_open(bfs, 1, ZEBRA_SORT_TYPE_ISAMB);
125 zebra_sort_close(si);
131 si = zebra_sort_open(bfs, 1, ZEBRA_SORT_TYPE_MULTI);
137 zebra_sort_close(si);
148 * indent-tabs-mode: nil
150 * vim: shiftwidth=4 tabstop=8 expandtab