2 * libdpkg - Debian packaging suite library routines
3 * t-pkg-list.c - test pkg-list implementation
5 * Copyright © 2010,2012 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <dpkg/test.h>
25 #include <dpkg/dpkg-db.h>
26 #include <dpkg/pkg-list.h>
29 test_pkg_list_new(void)
31 struct pkg_list *l1, *l2, *l3;
32 struct pkginfo pkg1, pkg2, pkg3;
34 l1 = pkg_list_new(&pkg1, NULL);
35 test_pass(l1 != NULL);
36 test_pass(l1->next == NULL);
37 test_pass(l1->pkg == &pkg1);
39 l2 = pkg_list_new(&pkg2, l1);
40 test_pass(l2 != NULL);
41 test_pass(l2->next == l1);
42 test_pass(l2->pkg == &pkg2);
44 l3 = pkg_list_new(&pkg3, l2);
45 test_pass(l3 != NULL);
46 test_pass(l3->next == l2);
47 test_pass(l3->pkg == &pkg3);
53 test_pkg_list_prepend(void)
55 struct pkg_list *head = NULL, *l1, *l2, *l3;
56 struct pkginfo pkg1, pkg2, pkg3, pkg4;
58 pkg_list_prepend(&head, &pkg1);
59 test_pass(head != NULL);
60 test_pass(head->next == NULL);
61 test_pass(head->pkg == &pkg1);
64 pkg_list_prepend(&head, &pkg2);
65 test_pass(head != NULL);
66 test_pass(head->next == l1);
67 test_pass(head->pkg == &pkg2);
70 pkg_list_prepend(&head, &pkg3);
71 test_pass(head != NULL);
72 test_pass(head->next == l2);
73 test_pass(head->pkg == &pkg3);
76 pkg_list_prepend(&head, &pkg4);
77 test_pass(head != NULL);
78 test_pass(head->next == l3);
79 test_pass(head->pkg == &pkg4);
88 test_pkg_list_prepend();