Line data Source code
1 : /***************************************************************************//**
2 :
3 : @file linkedlisttest.c
4 :
5 : @author Stephen Brennan
6 :
7 : @date Created Thursday, 12 September 2013
8 :
9 : @brief Test of the linked list.
10 :
11 : @copyright Copyright (c) 2013-2015, Stephen Brennan. Released under the
12 : Revised BSD License. See the LICENSE.txt file for details.
13 :
14 : *******************************************************************************/
15 :
16 : #include <stdio.h>
17 :
18 : #include "tests.h"
19 : #include "libstephen/ll.h"
20 : #include "libstephen/ut.h"
21 :
22 1 : int ll_test_create()
23 : {
24 1 : smb_status status = SMB_SUCCESS;
25 : DATA d;
26 1 : d.data_llint = 13;
27 :
28 1 : smb_ll *list = ll_create();
29 1 : ll_append(list, d);
30 :
31 1 : TEST_ASSERT(ll_length(list) == 1);
32 :
33 1 : TEST_ASSERT(ll_get(list, 0, &status).data_llint == 13);
34 1 : TEST_ASSERT(status == SMB_SUCCESS);
35 :
36 1 : ll_delete(list);
37 1 : return 0;
38 : }
39 :
40 1 : int ll_test_create_empty()
41 : {
42 1 : smb_ll *list = ll_create();
43 1 : TEST_ASSERT(ll_length(list) == 0);
44 1 : ll_delete(list);
45 1 : return 0;
46 : }
47 :
48 1 : void linked_list_test()
49 : {
50 : // Use the smbunit test framework. Load tests and run them.
51 1 : smb_ut_group *group = su_create_test_group("linked list");
52 :
53 1 : smb_ut_test *create = su_create_test("create", ll_test_create);
54 1 : su_add_test(group, create);
55 :
56 1 : smb_ut_test *create_empty = su_create_test("create_empty", ll_test_create_empty);
57 1 : su_add_test(group, create_empty);
58 :
59 1 : su_run_group(group);
60 1 : su_delete_group(group);
61 1 : }
|