6ea55828b8d4ec192ad8967f5caa39d6e9859de4
[profile/ivi/libgee.git] / tests / testhashmap.vala
1 /* testhashmap.vala
2  *
3  * Copyright (C) 2008  Jürg Billeter
4  * Copyright (C) 2009  Didier Villevalois, Julien Peeters
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
19  *
20  * Author:
21  *      Julien Peeters <contact@julienpeeters.fr>
22  */
23
24 using Gee;
25
26 public class HashMapTests : MapTests {
27
28         public HashMapTests () {
29                 base ("HashMap");
30                 add_test ("[HashMap] selected functions", test_selected_functions);
31                 add_test ("[HashMap] GObject properties", test_gobject_properties);
32         }
33
34         public override void set_up () {
35                 test_map = new HashMap<string,string> ();
36         }
37
38         public override void tear_down () {
39                 test_map = null;
40         }
41
42         public void test_selected_functions () {
43                 var test_hash_map = test_map as HashMap<string,string>;
44
45                 // Check the map exists
46                 assert (test_hash_map != null);
47
48                 // Check the selected hash and equal functions
49                 assert (test_hash_map.key_hash_func == str_hash);
50                 assert (test_hash_map.key_equal_func == str_equal);
51                 assert (test_hash_map.value_equal_func == str_equal);
52         }
53
54         public new void test_gobject_properties () {
55                 var test_hash_map = test_map as HashMap<string,string>;
56
57                 // Check the list exists
58                 assert (test_hash_map != null);
59                 Value value;
60
61                 value = Value (typeof (HashFunc));
62                 test_hash_map.get_property ("key-hash-func", ref value);
63                 assert (value.get_pointer () == (void*) test_hash_map.key_hash_func);
64                 value.unset ();
65
66                 value = Value (typeof (EqualFunc));
67                 test_hash_map.get_property ("key-equal-func", ref value);
68                 assert (value.get_pointer () == (void*) test_hash_map.key_equal_func);
69                 value.unset ();
70
71                 value = Value (typeof (EqualFunc));
72                 test_hash_map.get_property ("value-equal-func", ref value);
73                 assert (value.get_pointer () == (void*) test_hash_map.value_equal_func);
74                 value.unset ();
75         }
76 }