summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 19:22:39 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 19:22:39 -0300
commite973b87bf845bc6375b7608be40ba9a0851cd4e6 (patch)
tree4db62278e5fc74f66663efcd27551291676e8931 /src/tests
parentcfae5ba28579b37932dc516a9622eb58cfebefa1 (diff)
csharp: Fix Hash.DelByValue
Summary: The C function `eina_hash_del_by_data` requires the same value that was passed to the `add` function. As C# hashes store stuff through pointers due to marshalling, this makes it hard to pass the same pointer for it. So this functionality is implemented at C# level instead of relying on the native function directly. Fixes T8198 Thanks to @brunobelo and @singh.amitesh for the test case. Reviewers: singh.amitesh, felipealmeida, brunobelo Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers, singh.amitesh, brunobelo Tags: #efl Maniphest Tasks: T8198 Differential Revision: https://phab.enlightenment.org/D9853
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl_mono/Hash.cs55
-rw-r--r--src/tests/efl_mono/meson.build1
2 files changed, 56 insertions, 0 deletions
diff --git a/src/tests/efl_mono/Hash.cs b/src/tests/efl_mono/Hash.cs
new file mode 100644
index 0000000000..e064e47a13
--- /dev/null
+++ b/src/tests/efl_mono/Hash.cs
@@ -0,0 +1,55 @@
1using System;
2
3namespace TestSuite {
4
5class TestHash
6{
7
8 public static void test_del_value()
9 {
10 var hash = new Eina.Hash<int, int>();
11 Test.AssertEquals(hash.Count, 0);
12 hash.Add(0, 1);
13 Test.Assert(hash.DelByValue(1));
14 Test.AssertEquals(hash.Count, 0);
15
16 hash.Add(0, 1);
17 hash.Add(1, 100);
18 hash.Add(2, 101);
19
20 Test.Assert(hash.DelByValue(100));
21 Test.AssertEquals(hash.Count, 2);
22
23 Test.Assert(!hash.DelByValue(200));
24 }
25
26 public static void test_del_value_string()
27 {
28 var hash = new Eina.Hash<int, string>();
29 Test.AssertEquals(hash.Count, 0);
30 hash.Add(0, "E F L");
31 Test.Assert(hash.DelByValue("E F L"));
32 Test.AssertEquals(hash.Count, 0);
33
34 hash.Add(0, "Eina");
35 hash.Add(1, "Eo");
36 hash.Add(2, "Ecore");
37
38 Test.Assert(hash.DelByValue("Ecore"));
39 Test.AssertEquals(hash.Count, 2);
40
41 Test.Assert(!hash.DelByValue("Elementary"));
42 }
43
44 public static void test_del_key()
45 {
46 var hash = new Eina.Hash<int, int>();
47 hash.Add(0, 1);
48 hash.Add(1, 100);
49 hash.Add(2, 101);
50
51 hash.DelByKey(1);
52 Test.AssertEquals(hash.Count, 2);
53 }
54}
55} // namespace TestSuite
diff --git a/src/tests/efl_mono/meson.build b/src/tests/efl_mono/meson.build
index 445c823caa..8dedc3e543 100644
--- a/src/tests/efl_mono/meson.build
+++ b/src/tests/efl_mono/meson.build
@@ -81,6 +81,7 @@ efl_mono_src = [
81 'Value.cs', 81 'Value.cs',
82 'ValueEolian.cs', 82 'ValueEolian.cs',
83 'Inheritance.cs', 83 'Inheritance.cs',
84 'Hash.cs'
84] 85]
85 86
86efl_mono_suite = executable('efl-mono-suite', 87efl_mono_suite = executable('efl-mono-suite',