X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_wrbuf.c;h=e7886c45adae7b048b58099995508dab4fdc48e4;hp=007258a46de6f0fd7a237394fa0a51d2f374ac85;hb=7efed25c2ed807d32001e749f87f2eb300548c22;hpb=43a9d38d20c1b1bcd1a03b2445a501d27526bd35 diff --git a/test/test_wrbuf.c b/test/test_wrbuf.c index 007258a..e7886c4 100644 --- a/test/test_wrbuf.c +++ b/test/test_wrbuf.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -41,7 +42,7 @@ static void tstwrbuf(void) buf[i] = '\0'; wrbuf_puts(wr, buf); } - + cp = wrbuf_buf(wr); len = wrbuf_len(wr); YAZ_CHECK(len == step * (step-1) / 2); @@ -54,6 +55,36 @@ static void tstwrbuf(void) } wrbuf_rewind(wr); } + + wrbuf_rewind(wr); + wrbuf_puts(wr, "1234"); + wrbuf_insert(wr, 0, "abc", 3); + YAZ_CHECK(!strcmp(wrbuf_cstr(wr), "abc1234")); + + wrbuf_rewind(wr); + wrbuf_puts(wr, "1234"); + wrbuf_insert(wr, 1, "abc", 3); + YAZ_CHECK(!strcmp(wrbuf_cstr(wr), "1abc234")); + + wrbuf_rewind(wr); + wrbuf_puts(wr, "1234"); + wrbuf_insert(wr, 4, "abc", 3); + YAZ_CHECK(!strcmp(wrbuf_cstr(wr), "1234abc")); + + wrbuf_rewind(wr); + wrbuf_puts(wr, "1234"); + wrbuf_insert(wr, 5, "abc", 3); + YAZ_CHECK(!strcmp(wrbuf_cstr(wr), "1234")); + +#if HAVE_GCRYPT_H + { + const char *msg = "Hello world\n"; + wrbuf_rewind(wr); + wrbuf_sha1_write(wr, msg, strlen(msg), 1); + YAZ_CHECK(!strcmp(wrbuf_cstr(wr), + "33ab5639bfd8e7b95eb1d8d0b87781d4ffea4d5d")); + } +#endif wrbuf_destroy(wr); }