aboutsummaryrefslogtreecommitdiff
path: root/tests/list.c
blob: 722568b550abfb0b28a85c61f72d147102d3aca6 (plain)
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
/*
 * tests/list.c
 * (c) 2021 Jonas Gunz <himself@jonasgunz.de>
 * License: All rights reserved.
 */

#include "tests.h"
#include "../src/list.h"

START_TEST ( test_list_all ) {
	list_element_t* root = NULL;
	unsigned int i;
	/*int values[] = {7,1,6,8,4,5,2,0,3};*/
	int values[] = {0,1,2,3,4,5,6,7,8};


	for ( i=0; i<=8; i++ )
		list_add(&root, &values[i]);


	/* Not implemented
	list_sort(&root);
	*/
	ck_assert_int_ne( list_sort(&root), 0 );
	ck_assert_int_eq( list_length(&root), 9 );

	for ( i=0; i<=8; i++ )
		ck_assert_int_eq(*(int*)list_pop_front(&root), i);

	ck_assert_int_eq( list_length(&root), 0 );

} END_TEST

TCase* test_list(void) {
	TCase *tc = tcase_create("List");

	tcase_add_test(tc, test_list_all);

	return tc;
}