X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftsticonv.c;h=33b99449a724f48e99eb2283396269ca56b54180;hb=0725af5d06bfcdaf9888886f04c63810c1d8cf72;hp=7fac3c54dacb3e4eaeb2df4fe4a21ca445d01615;hpb=e69b8fde2b8c7f732e19b5d14e7c545114f7e422;p=yaz-moved-to-github.git diff --git a/test/tsticonv.c b/test/tsticonv.c index 7fac3c5..33b9944 100644 --- a/test/tsticonv.c +++ b/test/tsticonv.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: tsticonv.c,v 1.27 2007-03-17 00:10:41 adam Exp $ + * $Id: tsticonv.c,v 1.29 2007-03-20 21:37:32 adam Exp $ */ #if HAVE_CONFIG_H @@ -76,8 +76,12 @@ static int tst_convert_l(yaz_iconv_t cd, size_t in_len, const char *in_buf, return 0; } else + { + yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft); break; + } } + return compare_buffers("tsticonv 22", 0, expect_len, expect_buf, outbuf - outbuf0, outbuf0); @@ -104,13 +108,21 @@ static int tst_convert(yaz_iconv_t cd, const char *buf, const char *cmpbuf) if (e != YAZ_ICONV_E2BIG) break; } + else + { + size_t outbytesleft = sizeof(outbuf); + char *outp = outbuf; + r = yaz_iconv(cd, 0, 0, &outp, &outbytesleft); + wrbuf_write(b, outbuf, outp - outbuf); + break; + } } if (wrbuf_len(b) == strlen(cmpbuf) && !memcmp(cmpbuf, wrbuf_buf(b), wrbuf_len(b))) ret = 1; else yaz_log(YLOG_LOG, "GOT (%.*s)", wrbuf_len(b), wrbuf_buf(b)); - wrbuf_free(b, 1); + wrbuf_destroy(b); return ret; } @@ -266,6 +278,9 @@ static void dconvert(int mandatory, const char *tmpcode) return; r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); YAZ_CHECK(r != (size_t) (-1)); + + r = yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft); + YAZ_CHECK(r != (size_t) (-1)); yaz_iconv_close(cd); if (r == (size_t) (-1)) return; @@ -281,11 +296,19 @@ static void dconvert(int mandatory, const char *tmpcode) outbytesleft = sizeof(outbuf1); r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); YAZ_CHECK(r != (size_t) (-1)); + + r = yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft); + if (r == (size_t)(-1)) + { + fprintf(stderr, "failed\n"); + } + YAZ_CHECK(r != (size_t) (-1)); + if (r != (size_t)(-1)) { ret = compare_buffers("dconvert", i, strlen(iso_8859_1_a[i]), iso_8859_1_a[i], - sizeof(outbuf1) - outbytesleft, outbuf1); + sizeof(outbuf1) - outbytesleft, outbuf1); YAZ_CHECK(ret); } yaz_iconv_close(cd);