Add include of string.h
[yaz-moved-to-github.git] / test / test_wrbuf.c
index d7013e2..7c27fe5 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
 /* 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
  * See the file LICENSE for details.
  */
 #if HAVE_CONFIG_H
@@ -8,6 +8,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <yaz/wrbuf.h>
 #include <yaz/test.h>
 
 #include <yaz/wrbuf.h>
 #include <yaz/test.h>
@@ -41,7 +42,7 @@ static void tstwrbuf(void)
             buf[i] = '\0';
             wrbuf_puts(wr, buf);
         }
             buf[i] = '\0';
             wrbuf_puts(wr, buf);
         }
-        
+
         cp = wrbuf_buf(wr);
         len = wrbuf_len(wr);
         YAZ_CHECK(len == step * (step-1) / 2);
         cp = wrbuf_buf(wr);
         len = wrbuf_len(wr);
         YAZ_CHECK(len == step * (step-1) / 2);
@@ -54,6 +55,27 @@ static void tstwrbuf(void)
             }
         wrbuf_rewind(wr);
     }
             }
         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);
 }
 
     wrbuf_destroy(wr);
 }