Update libgee to 0.9.92 (3462b25)
[profile/ivi/libgee.git] / tests / testmultiset.vala
1 /* testmultiset.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  *      Jürg Billeter <j@bitron.ch>
22  *      Didier 'Ptitjes' Villevalois <ptitjes@free.fr>
23  *      Julien Peeters <contact@julienpeeters.fr>
24  */
25
26 using GLib;
27 using Gee;
28
29 public abstract class MultiSetTests : CollectionTests {
30
31         public MultiSetTests (string name) {
32                 base (name);
33                 add_test ("[MultiSet] duplicates are retained",
34                           test_duplicates_are_retained);
35         }
36
37         private void test_duplicates_are_retained () {
38                 var test_multi_set = test_collection as MultiSet<string>;
39
40                 // Check the test set is not null
41                 assert (test_multi_set != null);
42
43                 assert (test_multi_set.count ("one") == 0);
44
45                 assert (test_multi_set.add ("one"));
46                 assert (test_multi_set.contains ("one"));
47                 assert (test_multi_set.size == 1);
48                 assert (test_multi_set.count ("one") == 1);
49
50                 assert (test_multi_set.add ("one"));
51                 assert (test_multi_set.contains ("one"));
52                 assert (test_multi_set.size == 2);
53                 assert (test_multi_set.count ("one") == 2);
54
55                 assert (test_multi_set.add ("one"));
56                 assert (test_multi_set.contains ("one"));
57                 assert (test_multi_set.size == 3);
58                 assert (test_multi_set.count ("one") == 3);
59
60                 assert (test_multi_set.remove ("one"));
61                 assert (test_multi_set.contains ("one"));
62                 assert (test_multi_set.size == 2);
63                 assert (test_multi_set.count ("one") == 2);
64
65                 assert (test_multi_set.remove ("one"));
66                 assert (test_multi_set.contains ("one"));
67                 assert (test_multi_set.size == 1);
68                 assert (test_multi_set.count ("one") == 1);
69
70                 assert (test_multi_set.remove ("one"));
71                 assert (!test_multi_set.contains ("one"));
72                 assert (test_multi_set.size == 0);
73                 assert (test_multi_set.count ("one") == 0);
74         }
75 }