X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_wrbuf.c;h=defdc345691aa0c71bac24ba5460cdb0333ae017;hp=af06e40d800b407c2d0cc254717121ea29815b55;hb=249f8a3fb06e57a672b21af5b00f66bdfde8633a;hpb=3107ce3a34993d2f784387f227a50343fff83bbc diff --git a/test/test_wrbuf.c b/test/test_wrbuf.c index af06e40..defdc34 100644 --- a/test/test_wrbuf.c +++ b/test/test_wrbuf.c @@ -1,7 +1,10 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -38,7 +41,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); @@ -51,6 +54,27 @@ 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")); + wrbuf_destroy(wr); }