+static void test_selection(void) {
+ hash *h;
+ fprintf(stderr, "test_selection\n");
+ insist((h = selection_new()) != 0);
+ selection_set(h, "one", 1);
+ selection_set(h, "two", 1);
+ selection_set(h, "three", 0);
+ selection_set(h, "four", 1);
+ insist(selection_selected(h, "one") == 1);
+ insist(selection_selected(h, "two") == 1);
+ insist(selection_selected(h, "three") == 0);
+ insist(selection_selected(h, "four") == 1);
+ insist(selection_selected(h, "five") == 0);
+ insist(hash_count(h) == 3);
+ selection_flip(h, "one");
+ selection_flip(h, "three");
+ insist(selection_selected(h, "one") == 0);
+ insist(selection_selected(h, "three") == 1);
+ insist(hash_count(h) == 3);
+ selection_live(h, "one");
+ selection_live(h, "two");
+ selection_live(h, "three");
+ selection_cleanup(h);
+ insist(selection_selected(h, "one") == 0);
+ insist(selection_selected(h, "two") == 1);
+ insist(selection_selected(h, "three") == 1);
+ insist(selection_selected(h, "four") == 0);
+ insist(selection_selected(h, "five") == 0);
+ insist(hash_count(h) == 2);
+ selection_empty(h);
+ insist(selection_selected(h, "one") == 0);
+ insist(selection_selected(h, "two") == 0);
+ insist(selection_selected(h, "three") == 0);
+ insist(selection_selected(h, "four") == 0);
+ insist(selection_selected(h, "five") == 0);
+ insist(hash_count(h) == 0);
+}
+