Another fix for nmem_strsplit_escape
[yaz-moved-to-github.git] / test / test_wrbuf.c
index af06e40..f213561 100644 (file)
@@ -1,7 +1,10 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2010 Index Data
+ * Copyright (C) 1995-2011 Index Data
  * See the file LICENSE for details.
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -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);
 }