renamed existing tests to be consistent w/ type names they test
added lam_value_array test This commit was SVN r728.
Этот коммит содержится в:
родитель
78617ebceb
Коммит
c266f0d556
@ -3,4 +3,7 @@ Makefile.in
|
||||
*.lo
|
||||
.deps
|
||||
.libs
|
||||
list_test
|
||||
lam_list
|
||||
lam_hash_table
|
||||
lam_pointer_array
|
||||
lam_value_array
|
||||
|
@ -7,22 +7,23 @@ include $(top_srcdir)/config/Makefile.options
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/test/support -DLAM_ENABLE_DEBUG=1
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
hash_table \
|
||||
list_test \
|
||||
test_lam_pointer_array
|
||||
lam_hash_table \
|
||||
lam_list \
|
||||
lam_value_array \
|
||||
lam_pointer_array
|
||||
|
||||
list_test_SOURCES = list_test.c
|
||||
list_test_LDADD = \
|
||||
lam_list_SOURCES = lam_list.c
|
||||
lam_list_LDADD = \
|
||||
$(top_builddir)/src/lam/lfc/lam_list.lo \
|
||||
$(top_builddir)/src/lam/lfc/lam_object.lo \
|
||||
$(top_builddir)/src/lam/mem/malloc.lo \
|
||||
$(top_builddir)/src/lam/util/output.lo \
|
||||
$(top_builddir)/src/lam/threads/mutex.lo \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
list_test_DEPENDENCIES = $(list_test_LDADD)
|
||||
lam_list_DEPENDENCIES = $(lam_list_LDADD)
|
||||
|
||||
hash_table_SOURCES = hash_table.c
|
||||
hash_table_LDADD = \
|
||||
lam_hash_table_SOURCES = lam_hash_table.c
|
||||
lam_hash_table_LDADD = \
|
||||
$(top_builddir)/src/lam/lfc/lam_hash_table.lo \
|
||||
$(top_builddir)/src/lam/lfc/lam_list.lo \
|
||||
$(top_builddir)/src/lam/lfc/lam_object.lo \
|
||||
@ -32,13 +33,25 @@ hash_table_LDADD = \
|
||||
$(top_builddir)/src/lam/util/libutil.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
|
||||
test_lam_pointer_array_SOURCES = test_lam_pointer_array.c
|
||||
test_lam_pointer_array_LDADD = \
|
||||
lam_pointer_array_SOURCES = lam_pointer_array.c
|
||||
lam_pointer_array_LDADD = \
|
||||
$(top_builddir)/src/lam/lfc/lam_pointer_array.lo \
|
||||
$(top_builddir)/src/lam/mem/malloc.lo \
|
||||
$(top_builddir)/src/lam/util/output.lo \
|
||||
$(top_builddir)/src/lam/threads/mutex.lo \
|
||||
$(top_builddir)/src/lam/util/libutil.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
test_lam_pointer_array_DEPENDENCIES = $(test_lam_pointer_array_LDADD)
|
||||
lam_pointer_array_DEPENDENCIES = $(lam_pointer_array_LDADD)
|
||||
|
||||
lam_value_array_SOURCES = lam_value_array.c
|
||||
lam_value_array_LDADD = \
|
||||
$(top_builddir)/src/lam/lfc/lam_value_array.lo \
|
||||
$(top_builddir)/src/lam/lfc/lam_object.lo \
|
||||
$(top_builddir)/src/lam/mem/malloc.lo \
|
||||
$(top_builddir)/src/lam/util/output.lo \
|
||||
$(top_builddir)/src/lam/threads/mutex.lo \
|
||||
$(top_builddir)/src/lam/util/libutil.la \
|
||||
$(top_builddir)/test/support/libsupport.la
|
||||
lam_value_array_DEPENDENCIES = $(lam_value_array_LDADD)
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ static void validate_table(lam_hash_table_t *table, char *keys[], int is_numeric
|
||||
val = lam_hash_table_get_value_uint32(table, atoi(keys[j]));
|
||||
else
|
||||
val = lam_hash_table_get_value_ptr(table, keys[j], strlen(keys[j]));
|
||||
test_verify(keys[j+1], val);
|
||||
test_verify_str(keys[j+1], val);
|
||||
}
|
||||
test_verify_int(j/2, lam_hash_table_get_size(table));
|
||||
}
|
||||
@ -134,11 +134,10 @@ static void test_static(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* local variables */
|
||||
test_init("Hash Table");
|
||||
test_init("lam_hash_table_t");
|
||||
|
||||
test_dynamic();
|
||||
test_static();
|
||||
|
||||
test_finalize();
|
||||
return 0;
|
||||
return test_finalize();
|
||||
}
|
@ -26,7 +26,7 @@ int main(int argc, char **argv)
|
||||
int size_elements,i,indx,error_cnt;
|
||||
test_data_t *elements, *ele;
|
||||
|
||||
test_init("List");
|
||||
test_init("lam_list_t");
|
||||
|
||||
/* initialize list */
|
||||
lam_list_set_size(&list,0Xdeadbeaf);
|
||||
@ -301,6 +301,5 @@ int main(int argc, char **argv)
|
||||
test_failure(" error in list order - lam_list_remove_item ");
|
||||
}
|
||||
|
||||
test_finalize();
|
||||
return 0;
|
||||
return test_finalize();
|
||||
}
|
@ -137,7 +137,5 @@ int main(int argc, char **argv)
|
||||
/* run through tests with thread usage set to true */
|
||||
test(true);
|
||||
|
||||
test_finalize();
|
||||
|
||||
return 0;
|
||||
return test_finalize();
|
||||
}
|
81
test/lam/lfc/lam_value_array.c
Обычный файл
81
test/lam/lfc/lam_value_array.c
Обычный файл
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test is intended to test the lam_value_array class
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "support.h"
|
||||
#include "lam/lfc/lam_value_array.h"
|
||||
|
||||
|
||||
#define NUM_ITEMS 10
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
uint64_t count;
|
||||
test_init("lam_value_array_t");
|
||||
|
||||
lam_value_array_t array;
|
||||
OBJ_CONSTRUCT(&array, lam_value_array_t);
|
||||
|
||||
lam_value_array_init(&array, sizeof(int));
|
||||
test_verify_int(0, lam_value_array_get_size(&array));
|
||||
|
||||
/* add several items to the array */
|
||||
for(i=0; i < NUM_ITEMS; i++)
|
||||
lam_value_array_append_item(&array, &i);
|
||||
test_verify_int(NUM_ITEMS, lam_value_array_get_size(&array));
|
||||
|
||||
/* verify contents */
|
||||
for(i=0; i < NUM_ITEMS; i++)
|
||||
test_verify_int(i, LAM_VALUE_ARRAY_GET_ITEM(&array, int, i));
|
||||
|
||||
/* re-init array with new type */
|
||||
lam_value_array_init(&array, sizeof(uint64_t));
|
||||
test_verify_int(0, lam_value_array_get_size(&array));
|
||||
|
||||
/* set fixed size */
|
||||
lam_value_array_set_size(&array, NUM_ITEMS);
|
||||
|
||||
/* initialize array */
|
||||
count = 0;
|
||||
for(i=0; i < NUM_ITEMS; i++)
|
||||
LAM_VALUE_ARRAY_SET_ITEM(&array, uint64_t, i, count++);
|
||||
|
||||
/* grow it */
|
||||
for(i=0; i < NUM_ITEMS; i++) {
|
||||
lam_value_array_append_item(&array, &count);
|
||||
count++;
|
||||
}
|
||||
/* check size */
|
||||
test_verify_int(count, lam_value_array_get_size(&array));
|
||||
|
||||
/* validate contents */
|
||||
for(i=0; i < count; i++)
|
||||
test_verify_int(i, LAM_VALUE_ARRAY_GET_ITEM(&array, uint64_t, i));
|
||||
|
||||
/* remove an item */
|
||||
lam_value_array_remove_item(&array, NUM_ITEMS);
|
||||
|
||||
/* check size */
|
||||
test_verify_int(count-1, lam_value_array_get_size(&array));
|
||||
|
||||
/* validate contents */
|
||||
for(i=0; i < count-1; i++)
|
||||
if(i >= NUM_ITEMS)
|
||||
test_verify_int(i+1, LAM_VALUE_ARRAY_GET_ITEM(&array, uint64_t, i));
|
||||
else
|
||||
test_verify_int(i, LAM_VALUE_ARRAY_GET_ITEM(&array, uint64_t, i));
|
||||
|
||||
OBJ_DESTRUCT(&array);
|
||||
return test_finalize();
|
||||
}
|
Загрузка…
x
Ссылка в новой задаче
Block a user