b252c19506bd68a535a056533a158f9531b7563e
[profile/ivi/libgee.git] / tests / testhashset.vala
1 /* testhashset.vala
2  *
3  * Copyright (C) 2009  Didier Villevalois, Julien Peeters
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18  *
19  * Author:
20  *      Didier 'Ptitjes' Villevalois <ptitjes@free.fr>
21  *      Julien Peeters <contact@julienpeeters.fr>
22  */
23
24 using Gee;
25
26 public class HashSetTests : SetTests {
27
28         public HashSetTests () {
29                 base ("HashSet");
30                 add_test ("[HashSet] selected functions", test_selected_functions);
31                 add_test ("[HashSet] GObject properties", test_gobject_properties);
32         }
33
34         public override void set_up () {
35                 test_collection = new HashSet<string> ();
36         }
37
38         public override void tear_down () {
39                 test_collection = null;
40         }
41
42         public void test_selected_functions () {
43                 var test_set = test_collection as HashSet<string>;
44
45                 // Check the map exists
46                 assert (test_set != null);
47
48                 // Check the selected hash and equal functions
49                 assert (test_set.hash_func == str_hash);
50                 assert (test_set.equal_func == str_equal);
51         }
52
53         public new void test_gobject_properties () {
54                 var test_set = test_collection as HashSet<string>;
55
56                 // Check the list exists
57                 assert (test_set != null);
58                 Value value;
59
60                 value = Value (typeof (HashFunc));
61                 test_set.get_property ("hash-func", ref value);
62                 assert (value.get_pointer () == (void*) test_set.hash_func);
63                 value.unset ();
64
65                 value = Value (typeof (EqualFunc));
66                 test_set.get_property ("equal-func", ref value);
67                 assert (value.get_pointer () == (void*) test_set.equal_func);
68                 value.unset ();
69         }
70 }