X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=odr%2Ftstodr.c;h=ead978d5e62fcb1b70b45c0fd6f31365925cbc67;hb=29a22396d7d7b1219f5b83c35983c8fb1cd79e8f;hp=f302b20288c55d15739e50959408624ab328c654;hpb=b2efa1743e712eb8d713ff1b934a09cc19b35a55;p=yaz-moved-to-github.git diff --git a/odr/tstodr.c b/odr/tstodr.c index f302b20..ead978d 100644 --- a/odr/tstodr.c +++ b/odr/tstodr.c @@ -2,14 +2,14 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: tstodr.c,v 1.1 2003-05-06 10:08:30 adam Exp $ + * $Id: tstodr.c,v 1.5 2003-05-26 13:47:23 adam Exp $ * */ #include #include #include "tstodrcodec.h" -void tst_MySequence(ODR encode, ODR decode) +void tst_MySequence1(ODR encode, ODR decode) { char *ber_buf; int ber_len; @@ -30,7 +30,7 @@ void tst_MySequence(ODR encode, ODR decode) ber_buf = odr_getbuf(encode, &ber_len, 0); - odr_setbuf(decode, ber_buf, ber_len, 1); + odr_setbuf(decode, ber_buf, ber_len, 0); if (!yc_MySequence(decode, &t, 0, 0)) exit(2); @@ -48,12 +48,66 @@ void tst_MySequence(ODR encode, ODR decode) exit(8); } +void tst_MySequence2(ODR encode, ODR decode) +{ + char *ber_buf; + int ber_len; + Yc_MySequence *s = odr_malloc(encode, sizeof(*s)); + Yc_MySequence *t; + + s->first = 0; /* deliberately miss this .. */ + s->second = odr_malloc(encode, sizeof(*s->second)); + s->second->buf = "hello"; + s->second->len = 5; + s->second->size = 0; + s->third = odr_intdup(encode, 1); + s->fourth = odr_nullval(); + s->fifth = odr_intdup(encode, YC_MySequence_enum1); + + if (yc_MySequence(encode, &s, 0, 0)) /* should fail */ + exit(9); + if (odr_geterror(encode) != OREQUIRED) + exit(10); + if (strcmp(odr_getelement(encode), "first")) + exit(11); + odr_reset(encode); + + if (odr_geterror(encode) != ONONE) + exit(12); + if (strcmp(odr_getelement(encode), "")) + exit(13); +} + +void tst_MySequence3(ODR encode, ODR decode) +{ + char buf[40]; + int i; + Yc_MySequence *t; + + srand(123); + for (i = 0; i<1000; i++) + { + int j; + for (j = 0; j