chiark / gitweb /
64-bit macos fix
[disorder] / libtests / t-selection.c
CommitLineData
b90f122b
RK
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
b90f122b 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
b90f122b 8 * (at your option) any later version.
e7eb3a27
RK
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
b90f122b 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b90f122b
RK
17 */
18#include "test.h"
19
c68d8eba 20static void test_selection(void) {
b90f122b 21 hash *h;
c68d8eba 22
b90f122b
RK
23 insist((h = selection_new()) != 0);
24 selection_set(h, "one", 1);
25 selection_set(h, "two", 1);
26 selection_set(h, "three", 0);
27 selection_set(h, "four", 1);
28 insist(selection_selected(h, "one") == 1);
29 insist(selection_selected(h, "two") == 1);
30 insist(selection_selected(h, "three") == 0);
31 insist(selection_selected(h, "four") == 1);
32 insist(selection_selected(h, "five") == 0);
33 insist(hash_count(h) == 3);
34 selection_flip(h, "one");
35 selection_flip(h, "three");
36 insist(selection_selected(h, "one") == 0);
37 insist(selection_selected(h, "three") == 1);
38 insist(hash_count(h) == 3);
39 selection_live(h, "one");
40 selection_live(h, "two");
41 selection_live(h, "three");
42 selection_cleanup(h);
43 insist(selection_selected(h, "one") == 0);
44 insist(selection_selected(h, "two") == 1);
45 insist(selection_selected(h, "three") == 1);
46 insist(selection_selected(h, "four") == 0);
47 insist(selection_selected(h, "five") == 0);
48 insist(hash_count(h) == 2);
49 selection_empty(h);
50 insist(selection_selected(h, "one") == 0);
51 insist(selection_selected(h, "two") == 0);
52 insist(selection_selected(h, "three") == 0);
53 insist(selection_selected(h, "four") == 0);
54 insist(selection_selected(h, "five") == 0);
55 insist(hash_count(h) == 0);
56}
57
c68d8eba
RK
58TEST(selection);
59
b90f122b
RK
60/*
61Local Variables:
62c-basic-offset:2
63comment-column:40
64fill-column:79
65indent-tabs-mode:nil
66End:
67*/