1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#define LIBSSH_STATIC
#include "torture.h"
#include "error.c"
#include "misc.c"
static void torture_ssh_list_new(void **state) {
struct ssh_list *xlist;
(void) state;
xlist = ssh_list_new();
assert_true(xlist != NULL);
assert_true(xlist->root == NULL);
assert_true(xlist->end == NULL);
ssh_list_free(xlist);
}
static void torture_ssh_list_append(void **state) {
struct ssh_list *xlist;
int rc;
(void) state;
xlist = ssh_list_new();
assert_true(xlist != NULL);
rc = ssh_list_append(xlist, "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");
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");
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);
}
static void torture_ssh_list_prepend(void **state) {
struct ssh_list *xlist;
int rc;
(void) state;
xlist = ssh_list_new();
assert_true(xlist != NULL);
rc = ssh_list_prepend(xlist, "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");
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");
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);
}
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
unit_test(torture_ssh_list_new),
unit_test(torture_ssh_list_append),
unit_test(torture_ssh_list_prepend),
};
ssh_init();
rc=run_tests(tests);
ssh_finalize();
return rc;
}
|