summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Hash.cs
blob: e064e47a13d7f33f018b34a894f2c13ff00cf573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;

namespace TestSuite {

class TestHash
{

    public static void test_del_value()
    {
        var hash = new Eina.Hash<int, int>();
        Test.AssertEquals(hash.Count, 0);
        hash.Add(0, 1);
        Test.Assert(hash.DelByValue(1));
        Test.AssertEquals(hash.Count, 0);

        hash.Add(0, 1);
        hash.Add(1, 100);
        hash.Add(2, 101);

        Test.Assert(hash.DelByValue(100));
        Test.AssertEquals(hash.Count, 2);

        Test.Assert(!hash.DelByValue(200));
    }

    public static void test_del_value_string()
    {
        var hash = new Eina.Hash<int, string>();
        Test.AssertEquals(hash.Count, 0);
        hash.Add(0, "E F L");
        Test.Assert(hash.DelByValue("E F L"));
        Test.AssertEquals(hash.Count, 0);

        hash.Add(0, "Eina");
        hash.Add(1, "Eo");
        hash.Add(2, "Ecore");

        Test.Assert(hash.DelByValue("Ecore"));
        Test.AssertEquals(hash.Count, 2);

        Test.Assert(!hash.DelByValue("Elementary"));
    }

    public static void test_del_key()
    {
        var hash = new Eina.Hash<int, int>();
        hash.Add(0, 1);
        hash.Add(1, 100);
        hash.Add(2, 101);

        hash.DelByKey(1);
        Test.AssertEquals(hash.Count, 2);
    }
}
} // namespace TestSuite