Esempio n. 1
0
void test_list_for_each()
{
    KAA_TRACE_IN(logger);

    kaa_list_t *list = kaa_list_create();
    ASSERT_NOT_NULL(list);

    int32_t *number1_ptr;
    int node_number = 4;
    for (int i = 0; i < node_number; ++i) {
        number1_ptr = (int32_t *)KAA_MALLOC(sizeof(int32_t *));
        ASSERT_NOT_NULL(number1_ptr);
        *number1_ptr = rand();
        kaa_list_push_back(list, number1_ptr);
    }

    int number2 = rand();
    kaa_list_for_each(kaa_list_begin(list), kaa_list_back(list), (process_data)&test_process_data, &number2);

    kaa_list_node_t *it = kaa_list_begin(list);
    while (it) {
        ASSERT_EQUAL(*(int32_t *)kaa_list_get_data(kaa_list_begin(list)), number2);
        it = kaa_list_next(it);
    }

    kaa_list_destroy(list, NULL);

    KAA_TRACE_OUT(logger);
}
Esempio n. 2
0
static void test_list_create()
{
    kaa_list_t *list = kaa_list_create();
    ASSERT_NOT_NULL(list);

    ASSERT_EQUAL(kaa_list_get_size(list), 0);
    ASSERT_NULL(kaa_list_begin(list));
    ASSERT_NULL(kaa_list_back(list));

    kaa_list_destroy(list, NULL);
}
Esempio n. 3
0
void test_list_create()
{
    KAA_TRACE_IN(logger);

    kaa_list_t *list = kaa_list_create();
    ASSERT_NOT_NULL(list);

    ASSERT_EQUAL(kaa_list_get_size(list), 0);
    ASSERT_NULL(kaa_list_begin(list));
    ASSERT_NULL(kaa_list_back(list));

    kaa_list_destroy(list, NULL);

    KAA_TRACE_OUT(logger);
}
Esempio n. 4
0
static void test_list_push_back()
{
    kaa_list_t *list = kaa_list_create();
    ASSERT_NOT_NULL(list);

    int32_t *number;
    int node_number = 2;
    for (int i = 0; i < node_number; ++i) {
        number = KAA_MALLOC(sizeof(int32_t *));
        ASSERT_NOT_NULL(number);
        *number = rand();
        kaa_list_push_back(list, number);
    }

    ASSERT_EQUAL(kaa_list_get_size(list), node_number);
    ASSERT_EQUAL((*(int32_t *)kaa_list_get_data(kaa_list_back(list))), *number);

    kaa_list_destroy(list, NULL);
}