Result of libxml2 turbo marc conversion
[yaz-moved-to-github.git] / test / tstwrbuf.c
index a31115e..8b94634 100644 (file)
@@ -1,24 +1,27 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
  * See the file LICENSE for details.
- *
- * $Id: tstwrbuf.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdlib.h>
 #include <stdio.h>
 
 #include <yaz/wrbuf.h>
+#include <yaz/test.h>
 
-int main (int argc, char **argv)
+static void tstwrbuf(void)
 {
     int step;
     WRBUF wr = wrbuf_alloc();
 
-    wrbuf_free(wr, 1);
+    YAZ_CHECK(wr);
+
+    wrbuf_destroy(wr);
 
     wr = wrbuf_alloc();
 
+    YAZ_CHECK(wr);
+
     for (step = 1; step < 65; step++)
     {
         int i, j, k;
@@ -35,31 +38,30 @@ int main (int argc, char **argv)
         
         cp = wrbuf_buf(wr);
         len = wrbuf_len(wr);
-        if (len != step * (step-1) / 2)
-        {
-            printf ("tstwrbuf 1 %d len=%d\n", step, len);
-            exit(1);
-        }
+        YAZ_CHECK(len == step * (step-1) / 2);
         k = 0;
         for (j = 1; j<step; j++)
             for (i = 0; i<j; i++)
             {
-                if (cp[k] != i+1)
-                {
-                    printf ("tstwrbuf 2 %d k=%d\n", step, k);
-                    exit(1);
-                }
+                YAZ_CHECK(cp[k] == i+1);
                 k++;
             }
         wrbuf_rewind(wr);
     }
-    wrbuf_free(wr, 1);
-    exit(0);
+    wrbuf_destroy(wr);
+}
+
+int main (int argc, char **argv)
+{
+    YAZ_CHECK_INIT(argc, argv);
+    tstwrbuf();
+    YAZ_CHECK_TERM;
 }
 
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab