1
1

tests: Migrated torture_list to cmockery.

Этот коммит содержится в:
Andreas Schneider 2010-12-28 14:47:19 +01:00
родитель 99d45c686c
Коммит d44919dfd4
2 изменённых файлов: 44 добавлений и 45 удалений

Просмотреть файл

@ -4,7 +4,7 @@ add_cmockery_test(torture_buffer torture_buffer.c ${TORTURE_LIBRARY})
add_cmockery_test(torture_callbacks torture_callbacks.c ${TORTURE_LIBRARY})
add_cmockery_test(torture_init torture_init.c ${TORTURE_LIBRARY})
add_cmockery_test(torture_keyfiles torture_keyfiles.c ${TORTURE_LIBRARY})
#add_check_test(torture_list torture_list.c ${TORTURE_LIBRARY})
add_cmockery_test(torture_list torture_list.c ${TORTURE_LIBRARY})
#add_check_test(torture_misc torture_misc.c ${TORTURE_LIBRARY})
#add_check_test(torture_options torture_options.c ${TORTURE_LIBRARY})
#add_check_test(torture_rand torture_rand.c ${TORTURE_LIBRARY})

Просмотреть файл

@ -1,87 +1,86 @@
#define LIBSSH_STATIC
#include <libssh/priv.h>
#include "torture.h"
#include "misc.c"
START_TEST(torture_ssh_list_new)
{
static void torture_ssh_list_new(void **state) {
struct ssh_list *xlist;
(void) state;
xlist = ssh_list_new();
ck_assert(xlist != NULL);
ck_assert(xlist->root == NULL);
ck_assert(xlist->end == NULL);
assert_true(xlist != NULL);
assert_true(xlist->root == NULL);
assert_true(xlist->end == NULL);
ssh_list_free(xlist);
}
END_TEST
START_TEST(torture_ssh_list_append)
{
static void torture_ssh_list_append(void **state) {
struct ssh_list *xlist;
int rc;
(void) state;
xlist = ssh_list_new();
ck_assert(xlist != NULL);
assert_true(xlist != NULL);
rc = ssh_list_append(xlist, "item1");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item1");
ck_assert_str_eq((const char *) xlist->end->data, "item1");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item1");
assert_string_equal((const char *) xlist->end->data, "item1");
rc = ssh_list_append(xlist, "item2");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item1");
ck_assert_str_eq((const char *) xlist->end->data, "item2");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item1");
assert_string_equal((const char *) xlist->end->data, "item2");
rc = ssh_list_append(xlist, "item3");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item1");
ck_assert_str_eq((const char *) xlist->root->next->data, "item2");
ck_assert_str_eq((const char *) xlist->root->next->next->data, "item3");
ck_assert_str_eq((const char *) xlist->end->data, "item3");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item1");
assert_string_equal((const char *) xlist->root->next->data, "item2");
assert_string_equal((const char *) xlist->root->next->next->data, "item3");
assert_string_equal((const char *) xlist->end->data, "item3");
ssh_list_free(xlist);
}
END_TEST
START_TEST(torture_ssh_list_prepend)
{
static void torture_ssh_list_prepend(void **state) {
struct ssh_list *xlist;
int rc;
(void) state;
xlist = ssh_list_new();
ck_assert(xlist != NULL);
assert_true(xlist != NULL);
rc = ssh_list_prepend(xlist, "item1");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item1");
ck_assert_str_eq((const char *) xlist->end->data, "item1");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item1");
assert_string_equal((const char *) xlist->end->data, "item1");
rc = ssh_list_append(xlist, "item2");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item1");
ck_assert_str_eq((const char *) xlist->end->data, "item2");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item1");
assert_string_equal((const char *) xlist->end->data, "item2");
rc = ssh_list_prepend(xlist, "item3");
ck_assert(rc == 0);
ck_assert_str_eq((const char *) xlist->root->data, "item3");
ck_assert_str_eq((const char *) xlist->root->next->data, "item1");
ck_assert_str_eq((const char *) xlist->root->next->next->data, "item2");
ck_assert_str_eq((const char *) xlist->end->data, "item2");
assert_true(rc == 0);
assert_string_equal((const char *) xlist->root->data, "item3");
assert_string_equal((const char *) xlist->root->next->data, "item1");
assert_string_equal((const char *) xlist->root->next->next->data, "item2");
assert_string_equal((const char *) xlist->end->data, "item2");
ssh_list_free(xlist);
}
END_TEST
Suite *torture_make_suite(void) {
Suite *s = suite_create("libssh_list");
int torture_run_tests(void) {
const UnitTest tests[] = {
unit_test(torture_ssh_list_new),
unit_test(torture_ssh_list_append),
unit_test(torture_ssh_list_prepend),
};
torture_create_case(s, "torture_ssh_list_new", torture_ssh_list_new);
torture_create_case(s, "torture_ssh_list_append", torture_ssh_list_append);
torture_create_case(s, "torture_ssh_list_prepend", torture_ssh_list_prepend);
return s;
return run_tests(tests);
}