]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_c/Maasha/src/test/test_barray.c
added barray.c and cleaned hash.c
[biopieces.git] / code_c / Maasha / src / test / test_barray.c
diff --git a/code_c/Maasha/src/test/test_barray.c b/code_c/Maasha/src/test/test_barray.c
new file mode 100644 (file)
index 0000000..b6e100d
--- /dev/null
@@ -0,0 +1,158 @@
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
+#include "common.h"
+#include "barray.h"
+
+static void test_barray_new();
+static void test_barray_new_size();
+static void test_barray_resize();
+static void test_barray_print();
+static void test_barray_interval_inc();
+static void test_barray_interval_scan();
+static void test_barray_destroy();
+
+
+int main()
+{
+    fprintf( stderr, "Running all tests for barray.c\n" );
+
+    test_barray_new();
+    test_barray_new_size();
+    test_barray_resize();
+    test_barray_print();
+    test_barray_interval_inc();
+    test_barray_interval_scan();
+    test_barray_destroy();
+
+    fprintf( stderr, "Done\n\n" );
+
+    return EXIT_SUCCESS;
+}
+
+
+void test_barray_new()
+{
+    fprintf( stderr, "   Testing barray_new ... " );
+
+    size_t  nmemb = 10;
+    barray *ba    = NULL;
+
+    ba = barray_new( nmemb );
+//    barray_print( ba );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_new_size()
+{
+    fprintf( stderr, "   Testing barray_new_size ... " );
+
+    size_t  nmemb_old = 1100000;
+    size_t  nmemb_new = 0;
+
+    nmemb_new = barray_new_size( nmemb_old );
+
+//    printf( "old: %zu   new: %zu\n", nmemb_old, nmemb_new );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_resize()
+{
+    fprintf( stderr, "   Testing barray_resize ... " );
+
+    size_t  nmemb_old = 10;
+    size_t  nmemb_new = 20;
+    barray *ba        = NULL;
+
+    ba = barray_new( nmemb_old );
+
+    barray_resize( ba, nmemb_new );
+
+//    barray_print( ba );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_print()
+{
+    fprintf( stderr, "   Testing barray_print ... " );
+
+    size_t  nmemb = 10;
+    barray *ba    = NULL;
+
+    ba = barray_new( nmemb );
+
+//    barray_print( ba );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_interval_inc()
+{
+    fprintf( stderr, "   Testing barray_interval_inc ... " );
+
+    size_t  nmemb = 10;
+    barray *ba    = NULL;
+
+    ba = barray_new( nmemb );
+
+    barray_interval_inc( ba, 0, 0, 3 );
+    barray_interval_inc( ba, 0, 3, 3 );
+    barray_interval_inc( ba, 9, 9, 3 );
+
+//    barray_print( ba );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_interval_scan()
+{
+    fprintf( stderr, "   Testing barray_interval_scan ... " );
+
+    size_t  nmemb = 10;
+    size_t  pos   = 0;
+    size_t  beg   = 0;
+    size_t  end   = 0;
+    barray *ba    = NULL;
+
+    ba = barray_new( nmemb );
+
+    barray_interval_inc( ba, 0, 0, 3 );
+    barray_interval_inc( ba, 0, 3, 3 );
+    barray_interval_inc( ba, 9, 9, 3 );
+    barray_interval_inc( ba, 99, 100, 111 );
+    barray_interval_inc( ba, 19, 29, 3 );
+    barray_interval_inc( ba, 25, 35, 2 );
+
+    while ( barray_interval_scan( ba, &pos, &beg, &end ) ) {
+//        printf( "pos: %zu   beg: %zu   end: %zu\n", pos, beg, end );
+    }
+
+//    barray_print( ba );
+
+    fprintf( stderr, "OK\n" );
+}
+
+
+void test_barray_destroy()
+{
+    fprintf( stderr, "   Testing barray_destroy ... " );
+
+    size_t  nmemb = 10;
+    barray *ba    = NULL;
+
+    ba = barray_new( nmemb );
+
+    barray_destroy( &ba );
+
+    assert( ba == NULL );
+
+    fprintf( stderr, "OK\n" );
+}
+