enhance zarray library function
This commit is contained in:
parent
ae658c4a23
commit
a27c8bfe6e
3 changed files with 100 additions and 29 deletions
|
|
@ -71,6 +71,26 @@ static void test_zarray_put(void)
|
|||
zarray_fini(&array);
|
||||
}
|
||||
|
||||
static void test_zarray_put_get_ex(void)
|
||||
{
|
||||
zarray_t array;
|
||||
int idxs[2] = { 1, 3 };
|
||||
char* s1 = "hello";
|
||||
char* s2 = "test";
|
||||
void* datas1[2] = { s1, s2 };
|
||||
void* datas2[2];
|
||||
int rc;
|
||||
|
||||
zarray_init(&array, 8, NULL);
|
||||
rc = zarray_put_ex(&array, 2, &idxs[0], &datas1[0]);
|
||||
TEST_ASSERT_TRUE(rc >= 0);
|
||||
rc = zarray_get_ex(&array, 2, &idxs[0], &datas2[0]);
|
||||
TEST_ASSERT_TRUE(rc >= 0);
|
||||
TEST_ASSERT_TRUE((datas1[0] == datas2[0]) && (datas1[1] == datas2[1]));
|
||||
|
||||
zarray_fini(&array);
|
||||
}
|
||||
|
||||
static int sum_(void* arg1, void* arg2)
|
||||
{
|
||||
int* pv = (int*)arg1;
|
||||
|
|
@ -106,4 +126,5 @@ void test_zarray(void)
|
|||
RUN_TEST(test_zarray_del);
|
||||
RUN_TEST(test_zarray_put);
|
||||
RUN_TEST(test_zarray_iter);
|
||||
RUN_TEST(test_zarray_put_get_ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue