projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added turbo marcxml format
[yaz-moved-to-github.git]
/
test
/
tstodr.c
diff --git
a/test/tstodr.c
b/test/tstodr.c
index
3f6fecd
..
06c28ea
100644
(file)
--- a/
test/tstodr.c
+++ b/
test/tstodr.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2010 Index Data
* See the file LICENSE for details.
*/
#include <stdlib.h>
* See the file LICENSE for details.
*/
#include <stdlib.h>
@@
-105,13
+105,13
@@
void tst_MySequence3(ODR encode, ODR decode)
Yc_MySequence *t;
srand(123);
Yc_MySequence *t;
srand(123);
- for (i = 0; i<1000; i++)
+ for (i = 0; i < 1000; i++)
{
int j;
{
int j;
- for (j = 0; j<sizeof(buf); j++)
+ for (j = 0; j < (int) sizeof(buf); j++)
buf[j] = rand();
buf[j] = rand();
- for (j = 1; j<sizeof(buf); j++)
+ for (j = 1; j < (int) sizeof(buf); j++)
{
odr_setbuf(decode, buf, j, 0);
yc_MySequence(decode, &t, 0, 0);
{
odr_setbuf(decode, buf, j, 0);
yc_MySequence(decode, &t, 0, 0);
@@
-120,7
+120,7
@@
void tst_MySequence3(ODR encode, ODR decode)
}
}
}
}
-static void tst_berint(ODR encode, ODR decode)
+static void tst_berint32(ODR encode, ODR decode)
{
char *buf = 0;
int len = 0;
{
char *buf = 0;
int len = 0;
@@
-128,8
+128,8
@@
static void tst_berint(ODR encode, ODR decode)
Odr_int ret_val;
int r;
Odr_int ret_val;
int r;
- odr_reset(encode);
val = 0;
val = 0;
+ odr_reset(encode);
r = ber_integer(encode, &val);
YAZ_CHECK_EQ(r, 1);
buf = odr_getbuf(encode, &len, 0);
r = ber_integer(encode, &val);
YAZ_CHECK_EQ(r, 1);
buf = odr_getbuf(encode, &len, 0);
@@
-166,7
+166,7
@@
static void tst_berint(ODR encode, ODR decode)
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 2);
YAZ_CHECK_EQ(buf[0], 1);
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 2);
YAZ_CHECK_EQ(buf[0], 1);
- YAZ_CHECK_EQ(buf[1], -1);
+ YAZ_CHECK_EQ((unsigned char) buf[1], 255);
odr_reset(decode);
odr_setbuf(decode, buf, len, 0);
odr_reset(decode);
odr_setbuf(decode, buf, len, 0);
@@
-214,16
+214,16
@@
static void tst_berint(ODR encode, ODR decode)
YAZ_CHECK_EQ(len, 5);
YAZ_CHECK_EQ(buf[0], 4);
YAZ_CHECK_EQ(buf[1], 127);
YAZ_CHECK_EQ(len, 5);
YAZ_CHECK_EQ(buf[0], 4);
YAZ_CHECK_EQ(buf[1], 127);
- YAZ_CHECK_EQ(buf[2], -1);
- YAZ_CHECK_EQ(buf[3], -1);
- YAZ_CHECK_EQ(buf[4], -1);
+ YAZ_CHECK_EQ((unsigned char) buf[2], 255);
+ YAZ_CHECK_EQ((unsigned char) buf[3], 255);
+ YAZ_CHECK_EQ((unsigned char) buf[4], 255);
odr_reset(decode);
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, 2147483647);
odr_reset(decode);
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, 2147483647);
- val = (Odr_int) -2147483647L -1; /* -2^31 */
+ val = -2147483647L -1; /* -2^31 */
odr_reset(encode);
r = ber_integer(encode, &val);
YAZ_CHECK_EQ(r, 1);
odr_reset(encode);
r = ber_integer(encode, &val);
YAZ_CHECK_EQ(r, 1);
@@
-231,7
+231,7
@@
static void tst_berint(ODR encode, ODR decode)
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 5);
YAZ_CHECK_EQ(buf[0], 4);
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 5);
YAZ_CHECK_EQ(buf[0], 4);
- YAZ_CHECK_EQ(buf[1], -128);
+ YAZ_CHECK_EQ((unsigned char) buf[1], 128);
YAZ_CHECK_EQ(buf[2], 0);
YAZ_CHECK_EQ(buf[3], 0);
YAZ_CHECK_EQ(buf[4], 0);
YAZ_CHECK_EQ(buf[2], 0);
YAZ_CHECK_EQ(buf[3], 0);
YAZ_CHECK_EQ(buf[4], 0);
@@
-240,7
+240,17
@@
static void tst_berint(ODR encode, ODR decode)
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, (Odr_int) -2147483647L -1);
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, (Odr_int) -2147483647L -1);
+}
+static void tst_berint64(ODR encode, ODR decode)
+{
+#if NMEM_64
+ char *buf = 0;
+ int len = 0;
+ Odr_int val;
+ Odr_int ret_val;
+ int r;
+
val = (Odr_int) 2 * 2147483648UL; /* 2^32 */
odr_reset(encode);
r = ber_integer(encode, &val);
val = (Odr_int) 2 * 2147483648UL; /* 2^32 */
odr_reset(encode);
r = ber_integer(encode, &val);
@@
-260,7
+270,6
@@
static void tst_berint(ODR encode, ODR decode)
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, val);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, val);
-
val = (Odr_int) -2 * 2147483648UL; /* -2^32 */
odr_reset(encode);
r = ber_integer(encode, &val);
val = (Odr_int) -2 * 2147483648UL; /* -2^32 */
odr_reset(encode);
r = ber_integer(encode, &val);
@@
-269,7
+278,7
@@
static void tst_berint(ODR encode, ODR decode)
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 6);
YAZ_CHECK_EQ(buf[0], 5);
YAZ_CHECK(buf);
YAZ_CHECK_EQ(len, 6);
YAZ_CHECK_EQ(buf[0], 5);
- YAZ_CHECK_EQ(buf[1], -1);
+ YAZ_CHECK_EQ((unsigned char) buf[1], 255);
YAZ_CHECK_EQ(buf[2], 0);
YAZ_CHECK_EQ(buf[3], 0);
YAZ_CHECK_EQ(buf[4], 0);
YAZ_CHECK_EQ(buf[2], 0);
YAZ_CHECK_EQ(buf[3], 0);
YAZ_CHECK_EQ(buf[4], 0);
@@
-289,9
+298,9
@@
static void tst_berint(ODR encode, ODR decode)
YAZ_CHECK_EQ(len, 7);
YAZ_CHECK_EQ(buf[0], 6);
YAZ_CHECK_EQ(buf[1], 0);
YAZ_CHECK_EQ(len, 7);
YAZ_CHECK_EQ(buf[0], 6);
YAZ_CHECK_EQ(buf[1], 0);
- YAZ_CHECK_EQ(buf[2], -24);
- YAZ_CHECK_EQ(buf[3], -44);
- YAZ_CHECK_EQ(buf[4], -91);
+ YAZ_CHECK_EQ((unsigned char) buf[2], 232);
+ YAZ_CHECK_EQ((unsigned char) buf[3], 212);
+ YAZ_CHECK_EQ((unsigned char) buf[4], 165);
YAZ_CHECK_EQ(buf[5], 16);
YAZ_CHECK_EQ(buf[6], 0);
YAZ_CHECK_EQ(buf[5], 16);
YAZ_CHECK_EQ(buf[6], 0);
@@
-299,6
+308,7
@@
static void tst_berint(ODR encode, ODR decode)
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, val);
odr_setbuf(decode, buf, len, 0);
ber_integer(decode, &ret_val);
YAZ_CHECK_EQ(ret_val, val);
+#endif
}
static void tst(void)
}
static void tst(void)
@@
-313,7
+323,8
@@
static void tst(void)
tst_MySequence2(odr_encode, odr_decode);
tst_MySequence3(odr_encode, odr_decode);
tst_MySequence2(odr_encode, odr_decode);
tst_MySequence3(odr_encode, odr_decode);
- tst_berint(odr_encode, odr_decode);
+ tst_berint32(odr_encode, odr_decode);
+ tst_berint64(odr_encode, odr_decode);
odr_destroy(odr_encode);
odr_destroy(odr_decode);
odr_destroy(odr_encode);
odr_destroy(odr_decode);