X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fcodec%2Ftstcodec.c;h=ca279a37aa1e59e7adf9163822a9496f0fdc7403;hb=e26fd4d7361802023a6264f406e98d71503050cd;hp=fdfa8c50200cb8fb75cb73d2a72ea288ac306daf;hpb=cef013b96c9508d5fd8552e7fd05962029b37e6f;p=idzebra-moved-to-github.git diff --git a/test/codec/tstcodec.c b/test/codec/tstcodec.c index fdfa8c5..ca279a3 100644 --- a/test/codec/tstcodec.c +++ b/test/codec/tstcodec.c @@ -1,6 +1,6 @@ -/* $Id: tstcodec.c,v 1.3 2004-09-15 08:13:51 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 - Index Data Aps +/* $Id: tstcodec.c,v 1.12 2007-01-15 15:10:21 adam Exp $ + Copyright (C) 1995-2007 + Index Data ApS This file is part of the Zebra server. @@ -15,11 +15,12 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include #include "../../index/index.h" char *prog = ""; @@ -42,7 +43,7 @@ int tst_encode(int num) const char *src = (const char *) &key; key.len = 2; - key.mem[0] = i >> 8; + key.mem[0] = i << 8; key.mem[1] = i & 255; iscz1_encode (codec_handle, &dst, &src); if (dst > dst_buf + num*10) @@ -76,7 +77,7 @@ int tst_encode(int num) printf ("\n"); return 2; } - if (key.mem[0] != (i>>8)) + if (key.mem[0] != (i<<8)) { printf ("%s: i=%d mem[0]=" ZINT_FORMAT " expected " "%d\n", prog, i, key.mem[0], i>>8); @@ -108,14 +109,126 @@ int tst_encode(int num) return 0; } +void tstcodec1(void) +{ + char buf[100]; + char *dst = buf; + const char *src; + struct it_key key1; + struct it_key key2; + void *codec_handle =iscz1_start(); + + memset(&key1, 0, sizeof(key1)); + memset(&key2, 0, sizeof(key2)); + + key1.len = 4; + key1.mem[0] = 4*65536+1016; + key1.mem[1] = 24339; + key1.mem[2] = 125060; + key1.mem[3] = 1; + + src = (char*) &key1; + dst = buf; + iscz1_encode(codec_handle, &dst, &src); + + iscz1_stop(codec_handle); + + codec_handle =iscz1_start(); + + dst = (char*) &key2; + src = buf; + + iscz1_decode(codec_handle, &dst, &src); + + iscz1_stop(codec_handle); + + if (memcmp(&key1, &key2, sizeof(key1))) + { + const char *cp1 = (char*) &key1; + const char *cp2 = (char*) &key2; + int i; + for (i = 0; i 1) num = atoi(argv[1]); if (num < 1 || num > 100000000) num = 10000; - exit(tst_encode(num)); + tstcodec1(); + ret = tstcodec2(500); + ret = tst_encode(num); + exit(ret); } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +