2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 static void test_selection(void) {
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");
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);
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);