Ejemplo n.º 1
0
int main ()
{
    BEGIN_TESTS(0);

    test_basic::test<stdcxx::json_t>();
    test_iterator::test<stdcxx::json_t>();
    test_reference_wrapper::test<stdcxx::json_t>();
    test_parse::test<stdcxx::json_t>();
    test_stringify::test<stdcxx::json_t>();
    test_pretty_printer::test<stdcxx::json_t>();
    test_serialize::test<stdcxx::json_t>();
    test_rpc::test<stdcxx::json_t>();

// #ifdef HAVE_QT_CORE
//     std::cout << "===== HAVE_QT_CORE =====" << std::endl;
//     test_basic::test<qt::json>();
//     test_iterator::test<qt::json>();
//     test_reference_wrapper::test<qt::json>();
//     test_parse::test<qt::json>();
//     test_stringify::test<qt::json>();
//     test_pretty_printer::test<qt::json>();
//     test_serialize::test<qt::json>();
// #endif

    return END_TESTS;
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    struct core_buffered_reader reader;
    char file[] = "/home/boisvert/dropbox/SRS213780-Ecoli/SRR306102_1.fastq.gz";
    char buffer[BUFFER_SIZE];
    int expected;
    int actual;

    expected = 17222992;

    core_buffered_reader_init(&reader, file, 0);

    actual = 0;

    while (core_buffered_reader_read_line(&reader, buffer, BUFFER_SIZE) > 0) {

        ++actual;

            /*
        printf("Line= %s\n", buffer);
        */
    }

    TEST_INT_EQUALS(actual, expected);

    core_buffered_reader_destroy(&reader);

    END_TESTS();

    return 0;
}
Ejemplo n.º 3
0
int main ()
{
    BEGIN_TESTS(0);

    test_constructor();
    test_compare();
    test_timezone();


    return END_TESTS;
}
Ejemplo n.º 4
0
int main ()
{
    BEGIN_TESTS(0);

    test_constructors();
    test_assignments();
    test_access();
    test_iterators();
    test_capacity();
    test_operations();
    test_search();

    return END_TESTS;
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    {
        struct core_memory_pool memory;

        core_memory_pool_init(&memory, 16777216, -1);

        test_allocator(&memory);

        core_memory_pool_disable_tracking(&memory);
        test_allocator(&memory);
        test_allocator(NULL);

        core_memory_pool_destroy(&memory);
    }

    END_TESTS();

    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    struct core_fast_ring ring;
    int capacity = 64;
    int i;
    int value;
    int elements;

    elements = 0;

#if 0
    printf("Required %d\n", capacity);
#endif
    core_fast_ring_init(&ring, capacity, sizeof(int));

    capacity = core_fast_ring_capacity(&ring);

#if 0
    printf("Provided %d\n", capacity);
#endif

    TEST_BOOLEAN_EQUALS(core_fast_ring_is_empty_from_consumer(&ring), 1);

    for (i = 0; i < capacity; i++) {
        TEST_BOOLEAN_EQUALS(core_fast_ring_push_from_producer(&ring, &i), 1);
        elements++;

        TEST_INT_EQUALS(core_fast_ring_size_from_producer(&ring), elements);
        TEST_INT_EQUALS(core_fast_ring_size_from_consumer(&ring), elements);
    }

    TEST_BOOLEAN_EQUALS(core_fast_ring_is_full_from_producer(&ring), 1);

    for (i = 0; i < capacity; i++) {
        TEST_BOOLEAN_EQUALS(core_fast_ring_pop_from_consumer(&ring, &value), 1);
        elements--;
        TEST_INT_EQUALS(value, i);
        TEST_INT_EQUALS(core_fast_ring_size_from_producer(&ring), elements);
        TEST_INT_EQUALS(core_fast_ring_size_from_consumer(&ring), elements);
    }
    core_fast_ring_destroy(&ring);

    {
        struct core_fast_ring ring;
        int capacity = 64;
        struct thorium_message message;
        int action;
        int count;
        void *buffer;
        int inserted;
        int pulled;

        action = 1234;
        count = 0;
        buffer = NULL;

        thorium_message_init(&message, action, count, buffer);

        core_fast_ring_init(&ring, capacity, sizeof(struct thorium_message));
        core_fast_ring_use_multiple_producers(&ring);

        inserted = 0;

        while (core_fast_ring_push_from_producer(&ring, &message)) {
            ++inserted;
        }

        /*
         * 64 + 1 = 65, 128 is the next power of 2 for the mask.
         */
        /*
        TEST_INT_EQUALS(inserted, capacity);
        */

        pulled = 0;

        while (core_fast_ring_pop_from_consumer(&ring, &message)) {
            ++pulled;
        }

        TEST_INT_EQUALS(inserted, pulled);

        core_fast_ring_destroy(&ring);

        thorium_message_destroy(&message);
    }

    END_TESTS();

    return 0;
}
Ejemplo n.º 7
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    {
        /* test when inserting more than array size */

        struct core_queue queue;
        int i;
        core_queue_init(&queue, sizeof(int));

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 16;
        while (i--) {
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
        }

        i = 16;
        while (i--) {
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
        }

        TEST_INT_EQUALS(core_queue_full(&queue), 0);

        i = 16;
        while (i--) {
            int item;
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &item), 1);
        }

        i = 16;
        while (i--) {
            int item;
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &item), 1);
        }

        core_queue_destroy(&queue);
    }

    {
        /* push 1000 elements, and verify them after */

        struct core_queue queue;
        int i;
        core_queue_init(&queue, sizeof(int));

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 1000;
        while (i--) {
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
        }

        TEST_INT_EQUALS(core_queue_full(&queue), 0);

        i = 1000;
        while (i--) {
            int item;
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &item), 1);
            TEST_INT_EQUALS(item, i);
            /* printf("%i %i\n", item, i); */
        }

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        core_queue_destroy(&queue);
    }

    {
        /* use array size of 1 and 2000 elements */

        struct core_queue queue;
        int i;
        core_queue_init(&queue, sizeof(int));

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 2000;
        while (i--) {
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
        }

        TEST_INT_EQUALS(core_queue_full(&queue), 0);

        i = 2000;
        while (i--) {
            int item;
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &item), 1);
            TEST_INT_EQUALS(item, i);
            /* printf("%i %i\n", item, i); */
        }

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        core_queue_destroy(&queue);
    }

    {
        /* stress test the code by inserting one element,
           and then removing. */

        struct core_queue queue;
        int i;
        int expected;
        core_queue_init(&queue, sizeof(int));

        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 3000;
        while (i--) {
            expected = i;

            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &i), 1);

            TEST_INT_EQUALS(i, expected);

            TEST_INT_EQUALS(core_queue_empty(&queue), 1);
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &i), 1);
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &i), 1);

            TEST_INT_EQUALS(i, expected);
        }

        TEST_INT_EQUALS(core_queue_full(&queue), 0);
        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        /*
         * At any time, there is 0 or 1 elements in the queue.
         */
        /*
        core_queue_print(&queue);
        */

        TEST_INT_IS_LOWER_THAN(core_queue_capacity(&queue), 100);

        core_queue_destroy(&queue);
    }

    {
        struct core_queue queue;
        int i;
        int value;
        core_queue_init(&queue, sizeof(int));

#if 0
        printf("Test 3\n");
#endif
        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 3000;
        while (i--) {
            value = i;
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &value), 1);
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &value), 1);
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &value), 1);
        }

#if 0
        printf("Test 3, size %d\n",
                        core_queue_size(&queue));
#endif

        core_queue_destroy(&queue);
    }

    {
        struct core_queue queue;
        int i;
        int value;
        core_queue_init(&queue, sizeof(int));

#if 0
        printf("Test 4\n");
#endif
        TEST_INT_EQUALS(core_queue_empty(&queue), 1);

        i = 3000000;
        while (i--) {
            value = i;
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &value), 1);
            TEST_INT_EQUALS(core_queue_enqueue(&queue, &value), 1);
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &value), 1);
            TEST_INT_EQUALS(core_queue_dequeue(&queue, &value), 1);
        }

#if 0
        printf("Test 4, size %d\n",
                        core_queue_size(&queue));
#endif

        core_queue_destroy(&queue);
    }

    END_TESTS();

    return 0;
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    {
        struct core_map big_map;
        int kmer_length = 43;
        struct biosal_dna_kmer kmer;
        int count;
        int run_test;
        int coverage;
        void *key;
        int key_length;
        int *bucket;
        int i;
        struct biosal_dna_codec codec;
        struct core_memory_pool memory;

        core_memory_pool_init(&memory, 1048576, -1);
        biosal_dna_codec_init(&codec);

        run_test = 1;
        count = 100000000;

        printf("STRESS TEST\n");

        biosal_dna_kmer_init_mock(&kmer, kmer_length, &codec, &memory);
        key_length = biosal_dna_kmer_pack_size(&kmer, kmer_length, &codec);
        biosal_dna_kmer_destroy(&kmer, &memory);

        core_map_init(&big_map, key_length, sizeof(coverage));

        key = core_memory_allocate(key_length, -1);

        i = 0;
        while (i < count && run_test) {

            biosal_dna_kmer_init_random(&kmer, kmer_length, &codec, &memory);
            biosal_dna_kmer_pack_store_key(&kmer, key, kmer_length, &codec, &memory);

            bucket = core_map_add(&big_map, key);
            coverage = 99;
            (*bucket) = coverage;

            biosal_dna_kmer_destroy(&kmer, &memory);

            if (i % 100000 == 0) {
                printf("ADD %d/%d %" PRIu64 "\n", i, count,
                                core_map_size(&big_map));
            }
            i++;
        }

        core_map_destroy(&big_map);
        core_memory_free(key, -1);
        biosal_dna_codec_destroy(&codec);
        core_memory_pool_destroy(&memory);
    }

    END_TESTS();

    return 0;
}
Ejemplo n.º 9
0
int main(int argc, char **argv)
{
    struct biosal_assembly_vertex vertex;
    int i;
    int has_c;
    int has_g;
    int has_t;
    int count;
    int code;

    BEGIN_TESTS();

    biosal_assembly_vertex_init(&vertex);

    TEST_INT_EQUALS(biosal_assembly_vertex_parent_count(&vertex), 0);
    TEST_INT_EQUALS(biosal_assembly_vertex_child_count(&vertex), 0);


    /*
     * Add some links
     */

    biosal_assembly_vertex_add_child(&vertex, BIOSAL_NUCLEOTIDE_CODE_G);
    biosal_assembly_vertex_add_child(&vertex, BIOSAL_NUCLEOTIDE_CODE_C);
    biosal_assembly_vertex_add_child(&vertex, BIOSAL_NUCLEOTIDE_CODE_T);

    TEST_INT_EQUALS(biosal_assembly_vertex_parent_count(&vertex), 0);
    TEST_INT_EQUALS(biosal_assembly_vertex_child_count(&vertex), 3);

    has_g = 0;
    has_c = 0;
    has_t = 0;

    count = biosal_assembly_vertex_child_count(&vertex);


    for (i = 0; i < count; i++) {

        code = biosal_assembly_vertex_get_child(&vertex, i);

        if (code == BIOSAL_NUCLEOTIDE_CODE_G) {
            has_g = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_C) {
            has_c = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_T) {
            has_t = 1;
        }
    }

    TEST_INT_EQUALS(has_t, 1);
    TEST_INT_EQUALS(has_g, 1);
    TEST_INT_EQUALS(has_c, 1);

    biosal_assembly_vertex_delete_child(&vertex, BIOSAL_NUCLEOTIDE_CODE_C);

    has_g = 0;
    has_c = 0;
    has_t = 0;

    count = biosal_assembly_vertex_child_count(&vertex);


    for (i = 0; i < count; i++) {

        code = biosal_assembly_vertex_get_child(&vertex, i);

        if (code == BIOSAL_NUCLEOTIDE_CODE_G) {
            has_g = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_C) {
            has_c = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_T) {
            has_t = 1;
        }
    }

    TEST_INT_EQUALS(has_t, 1);
    TEST_INT_EQUALS(has_g, 1);
    TEST_INT_EQUALS(has_c, 0);


    code = biosal_assembly_vertex_get_parent(&vertex, 0);

    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_A);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_C);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_G);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_T);

    code = biosal_assembly_vertex_get_child(&vertex, 99);

    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_A);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_C);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_G);
    TEST_INT_NOT_EQUALS(code, BIOSAL_NUCLEOTIDE_CODE_T);


    biosal_assembly_vertex_add_parent(&vertex, BIOSAL_NUCLEOTIDE_CODE_G);

    TEST_INT_EQUALS(biosal_assembly_vertex_parent_count(&vertex), 1);

    has_g = 0;
    has_c = 0;
    has_t = 0;

    count = biosal_assembly_vertex_parent_count(&vertex);


    for (i = 0; i < count; i++) {

        code = biosal_assembly_vertex_get_parent(&vertex, i);

        if (code == BIOSAL_NUCLEOTIDE_CODE_G) {
            has_g = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_C) {
            has_c = 1;
        }

        if (code == BIOSAL_NUCLEOTIDE_CODE_T) {
            has_t = 1;
        }
    }

    TEST_INT_EQUALS(has_t, 0);
    TEST_INT_EQUALS(has_g, 1);
    TEST_INT_EQUALS(has_c, 0);



    biosal_assembly_vertex_destroy(&vertex);

    END_TESTS();

    return 0;
}
Ejemplo n.º 10
0
int main(int argc, char **argv)
{
    BEGIN_TESTS();

    {
        struct core_dynamic_hash_table table;
        uint64_t i;
        uint64_t elements;

        elements = 900;
        core_dynamic_hash_table_init(&table, 1140, sizeof(int), 0);

        for (i = 0; i < elements; i++) {
            /*
            printf("insert %d\n", i);

            printf("before actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i);

            core_dynamic_hash_table_add(&table, &i);

            /*
            printf("after1 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
            /*
            printf("after2 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
            /*
            printf("after3 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
            /*
            printf("after4 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
            /*
            printf("after5 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
            /*
            printf("after6 actual %d expected %d\n", (int)core_dynamic_hash_table_size(&table), i + 1);
            */
        }

        core_dynamic_hash_table_destroy(&table);
    }

    {
        struct core_dynamic_hash_table table;
        struct core_dynamic_hash_table_iterator iterator;
        int key_size;
        int value_size;
        uint64_t buckets;
        uint64_t i;
        int j;
        uint64_t inserted;
        int key;
        int *key_bucket;
        int *value_bucket;
        int found;

        key_size = sizeof(int);
        value_size = sizeof(int);
        buckets = 4;
        inserted = 0;

        core_dynamic_hash_table_init(&table, buckets, key_size, value_size);

        for (i = 0; i < buckets; i++) {
            key = inserted;
            value_bucket = core_dynamic_hash_table_add(&table, &key);
            inserted++;

            TEST_POINTER_NOT_EQUALS(value_bucket, NULL);

            *value_bucket = i;

            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), inserted);

            value_bucket = core_dynamic_hash_table_get(&table, &key);

            TEST_POINTER_NOT_EQUALS(value_bucket, NULL);
        }

        key = inserted;
        value_bucket = core_dynamic_hash_table_add(&table, &key);
        inserted++;

        for (j = 0; j < 1000; j++) {
            for (i = 0; i < buckets; i++) {
                key = inserted;
                value_bucket = core_dynamic_hash_table_add(&table, &key);
                inserted++;

                TEST_POINTER_NOT_EQUALS(value_bucket, NULL);

                *value_bucket = i;

                /*
                printf("DEBUG actual %d expected %d\n",
                                (int)core_dynamic_hash_table_size(&table), inserted);
                                */

                TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), inserted);

                value_bucket = core_dynamic_hash_table_get(&table, &key);

                TEST_POINTER_NOT_EQUALS(value_bucket, NULL);
            }
        }

        key = 9999;
        value_bucket = core_dynamic_hash_table_add(&table, &key);
        *value_bucket = 8888;

        core_dynamic_hash_table_iterator_init(&iterator, &table);

        i = 0;
        found = 0;

        while (core_dynamic_hash_table_iterator_has_next(&iterator)) {
            core_dynamic_hash_table_iterator_next(&iterator, (void **)&key_bucket,
                                                  (void **)&value_bucket);

            if (*key_bucket == 9999 && *value_bucket == 8888) {
                found = 1;
            }
            i++;
        }

        TEST_UINT64_T_EQUALS(i, core_dynamic_hash_table_size(&table));
        TEST_INT_EQUALS(found, 1);

        core_dynamic_hash_table_iterator_destroy(&iterator);

        core_dynamic_hash_table_destroy(&table);
    }

    {
        struct core_dynamic_hash_table table;
        int key;
        int *value;

        /*
        printf("-------------------\n");
        printf("DEBUG TEST-alpha-89\n");
        */

        core_dynamic_hash_table_init(&table, 8, sizeof(int), sizeof(int));

        for (key = 0; key < 1000000; key++) {

            /*
                        printf("DEBUG key %d\n", key);
                        */
            core_dynamic_hash_table_add(&table, &key);

            value = (int *)core_dynamic_hash_table_get(&table, &key);

            TEST_POINTER_NOT_EQUALS(value, NULL);

            *value = key;
        }

        core_dynamic_hash_table_destroy(&table);
    }

    {
        struct core_dynamic_hash_table table;
        uint64_t i;

        core_dynamic_hash_table_init(&table, 2, sizeof(int), sizeof(int));

        for (i = 0; i < 999; i++) {

            core_dynamic_hash_table_add(&table, &i);

            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
        }

        core_dynamic_hash_table_destroy(&table);
    }

    {
        struct core_dynamic_hash_table table;
        uint64_t i;
        void *bucket;

        core_dynamic_hash_table_init(&table, 2, sizeof(int), 128);

        for (i = 0; i < 999; i++) {

            core_dynamic_hash_table_add(&table, &i);

            TEST_UINT64_T_EQUALS(core_dynamic_hash_table_size(&table), i + 1);
        }

        for (i = 0; i < 999; i++) {
            bucket = core_dynamic_hash_table_get(&table, &i);

            TEST_POINTER_NOT_EQUALS(bucket, NULL);
        }

        core_dynamic_hash_table_destroy(&table);

    }

    END_TESTS();

    return 0;
}