summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2017-06-29 17:58:24 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 18:34:56 -0300
commitaf0d66a2d888309c5e9efa5372e4f736d9dcd9c1 (patch)
tree32b00cda8400d5dff5ee9d0b3439460579e92e78
parentc7147ebf8dafe6efde45be641e31d47845de0244 (diff)
eina_mono: custom iterators for Inlist and Hash, and more tests
-rw-r--r--src/bindings/mono/eina_mono/eina_container_common.cs21
-rw-r--r--src/bindings/mono/eina_mono/eina_hash.cs9
-rw-r--r--src/bindings/mono/eina_mono/eina_inlist.cs5
-rw-r--r--src/lib/efl_mono/efl_custom_exports_mono.c89
-rw-r--r--src/tests/efl_mono/Eina.cs406
5 files changed, 491 insertions, 39 deletions
diff --git a/src/bindings/mono/eina_mono/eina_container_common.cs b/src/bindings/mono/eina_mono/eina_container_common.cs
index 0f78d7adb0..e798fd11a1 100644
--- a/src/bindings/mono/eina_mono/eina_container_common.cs
+++ b/src/bindings/mono/eina_mono/eina_container_common.cs
@@ -83,6 +83,7 @@ public interface IBaseElementTraits<T>
83 IntPtr EinaFreeCb(); 83 IntPtr EinaFreeCb();
84 IntPtr EinaHashNew(); 84 IntPtr EinaHashNew();
85 IntPtr EinaInarrayNew(uint step); 85 IntPtr EinaInarrayNew(uint step);
86 IntPtr EinaHashIteratorKeyNew(IntPtr hash);
86} 87}
87 88
88public class StringElementTraits<T> : IBaseElementTraits<T> 89public class StringElementTraits<T> : IBaseElementTraits<T>
@@ -208,6 +209,11 @@ public class StringElementTraits<T> : IBaseElementTraits<T>
208 { 209 {
209 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step); 210 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
210 } 211 }
212
213 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
214 {
215 return eina_hash_iterator_key_new(hash);
216 }
211} 217}
212 218
213public class EflObjectElementTraits<T> : IBaseElementTraits<T> 219public class EflObjectElementTraits<T> : IBaseElementTraits<T>
@@ -343,6 +349,11 @@ public class EflObjectElementTraits<T> : IBaseElementTraits<T>
343 { 349 {
344 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step); 350 return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
345 } 351 }
352
353 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
354 {
355 return eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(hash);
356 }
346} 357}
347 358
348public abstract class PrimitiveElementTraits<T> 359public abstract class PrimitiveElementTraits<T>
@@ -454,6 +465,11 @@ public abstract class PrimitiveElementTraits<T>
454 { 465 {
455 return eina_inarray_new((uint)Marshal.SizeOf<T>(), step); 466 return eina_inarray_new((uint)Marshal.SizeOf<T>(), step);
456 } 467 }
468
469 public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
470 {
471 return eina_hash_iterator_key_new(hash);
472 }
457} 473}
458 474
459public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T> 475public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T>
@@ -680,6 +696,11 @@ public static class TraitFunctions
680 { 696 {
681 return GetTypeTraits<T>().EinaInarrayNew(step); 697 return GetTypeTraits<T>().EinaInarrayNew(step);
682 } 698 }
699
700 public static IntPtr EinaHashIteratorKeyNew<T>(IntPtr hash)
701 {
702 return GetTypeTraits<T>().EinaHashIteratorKeyNew(hash);
703 }
683} 704}
684 705
685} 706}
diff --git a/src/bindings/mono/eina_mono/eina_hash.cs b/src/bindings/mono/eina_mono/eina_hash.cs
index e63a89df24..1b4711f78d 100644
--- a/src/bindings/mono/eina_mono/eina_hash.cs
+++ b/src/bindings/mono/eina_mono/eina_hash.cs
@@ -123,6 +123,9 @@ public static class HashNativeFunctions
123 123
124 [DllImport("eina")] public static extern int 124 [DllImport("eina")] public static extern int
125 eina_hash_superfast(string key, int len); 125 eina_hash_superfast(string key, int len);
126
127 [DllImport("eflcustomexportsmono")] public static extern IntPtr
128 eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(IntPtr hash);
126} 129}
127 130
128public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable 131public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable
@@ -360,12 +363,12 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDi
360 return eina_hash_population(Handle); 363 return eina_hash_population(Handle);
361 } 364 }
362 365
363 public eina.Iterator<TKey> GetKeyIterator() 366 public eina.Iterator<TKey> Keys()
364 { 367 {
365 return new eina.Iterator<TKey>(eina_hash_iterator_key_new(Handle), true, false); 368 return new eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false);
366 } 369 }
367 370
368 public eina.Iterator<TValue> GetValueIterator() 371 public eina.Iterator<TValue> Values()
369 { 372 {
370 return new eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false); 373 return new eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false);
371 } 374 }
diff --git a/src/bindings/mono/eina_mono/eina_inlist.cs b/src/bindings/mono/eina_mono/eina_inlist.cs
index ab5468e903..10feba23fc 100644
--- a/src/bindings/mono/eina_mono/eina_inlist.cs
+++ b/src/bindings/mono/eina_mono/eina_inlist.cs
@@ -72,6 +72,9 @@ public static class InlistNativeFunctions
72 eina_inlist_next_custom_export_mono(IntPtr list); 72 eina_inlist_next_custom_export_mono(IntPtr list);
73 [DllImport("eflcustomexportsmono")] public static extern IntPtr 73 [DllImport("eflcustomexportsmono")] public static extern IntPtr
74 eina_inlist_prev_custom_export_mono(IntPtr list); 74 eina_inlist_prev_custom_export_mono(IntPtr list);
75
76 [DllImport("eflcustomexportsmono")] public static extern IntPtr
77 eina_inlist_iterator_wrapper_new_custom_export_mono(IntPtr in_list);
75} 78}
76 79
77public class Inlist<T> : IEnumerable<T>, IDisposable 80public class Inlist<T> : IEnumerable<T>, IDisposable
@@ -293,7 +296,7 @@ public class Inlist<T> : IEnumerable<T>, IDisposable
293 296
294 public eina.Iterator<T> GetIterator() 297 public eina.Iterator<T> GetIterator()
295 { 298 {
296 return new eina.Iterator<T>(eina_inlist_iterator_new(Handle), true, false); 299 return new eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true, false);
297 } 300 }
298 301
299 public IEnumerator<T> GetEnumerator() 302 public IEnumerator<T> GetEnumerator()
diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c
index cd48721daf..d6110317b9 100644
--- a/src/lib/efl_mono/efl_custom_exports_mono.c
+++ b/src/lib/efl_mono/efl_custom_exports_mono.c
@@ -79,6 +79,50 @@ EAPI Eina_Free_Cb efl_mono_native_efl_unref_addr_get()
79 return (Eina_Free_Cb)efl_unref; 79 return (Eina_Free_Cb)efl_unref;
80} 80}
81 81
82// Iterator Wrapper //
83
84typedef struct _Eina_Iterator_Wrapper_Mono
85{
86 Eina_Iterator iterator; // Must be the first
87 Eina_Iterator *internal;
88} Eina_Iterator_Wrapper_Mono;
89
90static void *eina_iterator_wrapper_get_container_mono(Eina_Iterator_Wrapper_Mono *it)
91{
92 return eina_iterator_container_get(it->internal);
93}
94
95static void eina_iterator_wrapper_free_mono(Eina_Iterator_Wrapper_Mono *it)
96{
97 eina_iterator_free(it->internal);
98 free(it);
99}
100
101
102static Eina_Iterator *eina_iterator_wrapper_new_mono(Eina_Iterator *internal, Eina_Iterator_Next_Callback next_cb)
103{
104 if (!internal) return NULL;
105
106 Eina_Iterator_Wrapper_Mono *it = calloc(1, sizeof(Eina_Iterator_Wrapper_Mono));
107 if (!it)
108 {
109 eina_iterator_free(internal);
110 return NULL;
111 }
112
113 it->internal = internal;
114
115 it->iterator.next = next_cb;
116
117 it->iterator.version = EINA_ITERATOR_VERSION;
118 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_iterator_wrapper_get_container_mono);
119 it->iterator.free = FUNC_ITERATOR_FREE(eina_iterator_wrapper_free_mono);
120
121 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
122
123 return &it->iterator;
124}
125
82// Array // 126// Array //
83 127
84EAPI void eina_array_free_generic_custom_export_mono(Eina_Array *array) EINA_ARG_NONNULL(1) 128EAPI void eina_array_free_generic_custom_export_mono(Eina_Array *array) EINA_ARG_NONNULL(1)
@@ -182,6 +226,30 @@ EAPI void *eina_list_last_data_get_custom_export_mono(const Eina_List *list)
182 226
183// Inlist // 227// Inlist //
184 228
229typedef struct _Inlist_Node_Mono
230{
231 EINA_INLIST;
232 char mem_start;
233} Inlist_Node_Mono;
234
235static Eina_Bool eina_inlist_iterator_wrapper_next_mono(Eina_Iterator_Wrapper_Mono *it, void **data)
236{
237 Inlist_Node_Mono *node = NULL;
238
239 if (!eina_iterator_next(it->internal, (void**)&node))
240 return EINA_FALSE;
241
242 if (data)
243 *data = &node->mem_start;
244
245 return EINA_TRUE;
246}
247
248EAPI Eina_Iterator *eina_inlist_iterator_wrapper_new_custom_export_mono(const Eina_Inlist *in_list)
249{
250 return eina_iterator_wrapper_new_mono(eina_inlist_iterator_new(in_list), FUNC_ITERATOR_NEXT(eina_inlist_iterator_wrapper_next_mono));
251}
252
185EAPI Eina_Inlist *eina_inlist_first_custom_export_mono(const Eina_Inlist *list) 253EAPI Eina_Inlist *eina_inlist_first_custom_export_mono(const Eina_Inlist *list)
186{ 254{
187 return eina_inlist_first(list); 255 return eina_inlist_first(list);
@@ -205,3 +273,24 @@ EAPI Eina_Inlist *eina_inlist_prev_custom_export_mono(const Eina_Inlist *list)
205 return list->prev; 273 return list->prev;
206 return NULL; 274 return NULL;
207} 275}
276
277// Hash //
278
279static Eina_Bool eina_hash_iterator_ptr_key_wrapper_next_mono(Eina_Iterator_Wrapper_Mono *it, void **data)
280{
281 void **ptr = NULL;
282
283 if (!eina_iterator_next(it->internal, (void**)&ptr))
284 return EINA_FALSE;
285
286 if (data)
287 *data = *ptr;
288
289 return EINA_TRUE;
290}
291
292EAPI Eina_Iterator *eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(const Eina_Hash *hash)
293{
294 return eina_iterator_wrapper_new_mono(eina_hash_iterator_key_new(hash), FUNC_ITERATOR_NEXT(eina_hash_iterator_ptr_key_wrapper_next_mono));
295}
296
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 2a0b972f56..2039475a4d 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -3300,12 +3300,12 @@ class TestEinaIterator
3300 { 3300 {
3301 var arr = new eina.Array<int>(); 3301 var arr = new eina.Array<int>();
3302 var itr = arr.GetIterator(); 3302 var itr = arr.GetIterator();
3303 bool entered = false; 3303 int idx = 0;
3304 foreach (int e in itr) 3304 foreach (int e in itr)
3305 { 3305 {
3306 entered = true; 3306 ++idx;
3307 } 3307 }
3308 Test.Assert(!entered); 3308 Test.AssertEquals(idx, 0);
3309 } 3309 }
3310 3310
3311 public static void eina_array_int_filled_iterator() 3311 public static void eina_array_int_filled_iterator()
@@ -3313,27 +3313,25 @@ class TestEinaIterator
3313 var arr = new eina.Array<int>(); 3313 var arr = new eina.Array<int>();
3314 arr.Append(base_seq_int); 3314 arr.Append(base_seq_int);
3315 var itr = arr.GetIterator(); 3315 var itr = arr.GetIterator();
3316 bool entered = false; 3316 int idx = 0;
3317 var i = 0;
3318 foreach (int e in itr) 3317 foreach (int e in itr)
3319 { 3318 {
3320 entered = true; 3319 Test.Assert(e == base_seq_int[idx]);
3321 Test.Assert(e == base_seq_int[i]); 3320 ++idx;
3322 ++i;
3323 } 3321 }
3324 Test.Assert(entered); 3322 Test.AssertEquals(idx, base_seq_int.Length);
3325 } 3323 }
3326 3324
3327 public static void eina_array_str_empty_iterator() 3325 public static void eina_array_str_empty_iterator()
3328 { 3326 {
3329 var arr = new eina.Array<string>(); 3327 var arr = new eina.Array<string>();
3330 var itr = arr.GetIterator(); 3328 var itr = arr.GetIterator();
3331 bool entered = false; 3329 int idx = 0;
3332 foreach (string e in itr) 3330 foreach (string e in itr)
3333 { 3331 {
3334 entered = true; 3332 ++idx;
3335 } 3333 }
3336 Test.Assert(!entered); 3334 Test.AssertEquals(idx, 0);
3337 } 3335 }
3338 3336
3339 public static void eina_array_str_filled_iterator() 3337 public static void eina_array_str_filled_iterator()
@@ -3341,27 +3339,25 @@ class TestEinaIterator
3341 var arr = new eina.Array<string>(); 3339 var arr = new eina.Array<string>();
3342 arr.Append(base_seq_str); 3340 arr.Append(base_seq_str);
3343 var itr = arr.GetIterator(); 3341 var itr = arr.GetIterator();
3344 bool entered = false; 3342 int idx = 0;
3345 var i = 0;
3346 foreach (string e in itr) 3343 foreach (string e in itr)
3347 { 3344 {
3348 entered = true; 3345 Test.Assert(e == base_seq_str[idx]);
3349 Test.Assert(e == base_seq_str[i]); 3346 ++idx;
3350 ++i;
3351 } 3347 }
3352 Test.Assert(entered); 3348 Test.AssertEquals(idx, base_seq_str.Length);
3353 } 3349 }
3354 3350
3355 public static void eina_array_obj_empty_iterator() 3351 public static void eina_array_obj_empty_iterator()
3356 { 3352 {
3357 var arr = new eina.Array<test.Numberwrapper>(); 3353 var arr = new eina.Array<test.Numberwrapper>();
3358 var itr = arr.GetIterator(); 3354 var itr = arr.GetIterator();
3359 bool entered = false; 3355 int idx = 0;
3360 foreach (test.Numberwrapper e in itr) 3356 foreach (test.Numberwrapper e in itr)
3361 { 3357 {
3362 entered = true; 3358 ++idx;
3363 } 3359 }
3364 Test.Assert(!entered); 3360 Test.AssertEquals(idx, 0);
3365 } 3361 }
3366 3362
3367 public static void eina_array_obj_filled_iterator() 3363 public static void eina_array_obj_filled_iterator()
@@ -3370,16 +3366,14 @@ class TestEinaIterator
3370 var base_objs = BaseSeqObj(); 3366 var base_objs = BaseSeqObj();
3371 arr.Append(base_objs); 3367 arr.Append(base_objs);
3372 var itr = arr.GetIterator(); 3368 var itr = arr.GetIterator();
3373 bool entered = false; 3369 int idx = 0;
3374 var i = 0;
3375 foreach (test.Numberwrapper e in itr) 3370 foreach (test.Numberwrapper e in itr)
3376 { 3371 {
3377 entered = true; 3372 Test.Assert(e.raw_handle == base_objs[idx].raw_handle);
3378 Test.Assert(e.raw_handle == base_objs[i].raw_handle); 3373 Test.Assert(e.number_get() == base_objs[idx].number_get());
3379 Test.Assert(e.number_get() == base_objs[i].number_get()); 3374 ++idx;
3380 ++i;
3381 } 3375 }
3382 Test.Assert(entered); 3376 Test.AssertEquals(idx, base_objs.Length);
3383 } 3377 }
3384 3378
3385 // Inarray 3379 // Inarray
@@ -3388,12 +3382,12 @@ class TestEinaIterator
3388 { 3382 {
3389 var arr = new eina.Inarray<int>(); 3383 var arr = new eina.Inarray<int>();
3390 var itr = arr.GetIterator(); 3384 var itr = arr.GetIterator();
3391 bool entered = false; 3385 int idx = 0;
3392 foreach (int e in itr) 3386 foreach (int e in itr)
3393 { 3387 {
3394 entered = true; 3388 ++idx;
3395 } 3389 }
3396 Test.Assert(!entered); 3390 Test.AssertEquals(idx, 0);
3397 } 3391 }
3398 3392
3399 public static void eina_inarray_int_filled_iterator() 3393 public static void eina_inarray_int_filled_iterator()
@@ -3401,15 +3395,357 @@ class TestEinaIterator
3401 var arr = new eina.Inarray<int>(); 3395 var arr = new eina.Inarray<int>();
3402 arr.Append(base_seq_int); 3396 arr.Append(base_seq_int);
3403 var itr = arr.GetIterator(); 3397 var itr = arr.GetIterator();
3398 int idx = 0;
3399 foreach (int e in itr)
3400 {
3401 Test.Assert(e == base_seq_int[idx]);
3402 ++idx;
3403 }
3404 Test.AssertEquals(idx, base_seq_int.Length);
3405 }
3406
3407 // List //
3408
3409 public static void eina_list_int_empty_iterator()
3410 {
3411 var lst = new eina.List<int>();
3412 var itr = lst.GetIterator();
3413 int idx = 0;
3414 foreach (int e in itr)
3415 {
3416 ++idx;
3417 }
3418 Test.AssertEquals(idx, 0);
3419 }
3420
3421 public static void eina_list_int_filled_iterator()
3422 {
3423 var lst = new eina.List<int>();
3424 lst.AppendArray(base_seq_int);
3425 var itr = lst.GetIterator();
3426 int idx = 0;
3427 foreach (int e in itr)
3428 {
3429 Test.Assert(e == base_seq_int[idx]);
3430 ++idx;
3431 }
3432 Test.AssertEquals(idx, base_seq_int.Length);
3433 }
3434
3435 public static void eina_list_str_empty_iterator()
3436 {
3437 var lst = new eina.List<string>();
3438 var itr = lst.GetIterator();
3439 int idx = 0;
3440 foreach (string e in itr)
3441 {
3442 ++idx;
3443 }
3444 Test.AssertEquals(idx, 0);
3445 }
3446
3447 public static void eina_list_str_filled_iterator()
3448 {
3449 var lst = new eina.List<string>();
3450 lst.AppendArray(base_seq_str);
3451 var itr = lst.GetIterator();
3452 int idx = 0;
3453 foreach (string e in itr)
3454 {
3455 Test.Assert(e == base_seq_str[idx]);
3456 ++idx;
3457 }
3458 Test.AssertEquals(idx, base_seq_str.Length);
3459 }
3460
3461 public static void eina_list_obj_empty_iterator()
3462 {
3463 var lst = new eina.List<test.Numberwrapper>();
3464 var itr = lst.GetIterator();
3465 int idx = 0;
3466 foreach (test.Numberwrapper e in itr)
3467 {
3468 ++idx;
3469 }
3470 Test.AssertEquals(idx, 0);
3471 }
3472
3473 public static void eina_list_obj_filled_iterator()
3474 {
3475 var lst = new eina.List<test.Numberwrapper>();
3476 var base_objs = BaseSeqObj();
3477 lst.AppendArray(base_objs);
3478 var itr = lst.GetIterator();
3479 int idx = 0;
3480 foreach (test.Numberwrapper e in itr)
3481 {
3482 Test.Assert(e.raw_handle == base_objs[idx].raw_handle);
3483 Test.Assert(e.number_get() == base_objs[idx].number_get());
3484 ++idx;
3485 }
3486 Test.AssertEquals(idx, base_objs.Length);
3487 }
3488
3489 // Inlist //
3490
3491 public static void eina_inlist_int_empty_iterator()
3492 {
3493 var lst = new eina.Inlist<int>();
3494 var itr = lst.GetIterator();
3495 int idx = 0;
3496 foreach (int e in itr)
3497 {
3498 ++idx;
3499 }
3500 Test.AssertEquals(idx, 0);
3501 }
3502
3503 public static void eina_inlist_int_filled_iterator()
3504 {
3505 var lst = new eina.Inlist<int>();
3506 lst.AppendArray(base_seq_int);
3507 var itr = lst.GetIterator();
3508 int idx = 0;
3509 foreach (int e in itr)
3510 {
3511 Test.Assert(e == base_seq_int[idx]);
3512 ++idx;
3513 }
3514 Test.AssertEquals(idx, base_seq_int.Length);
3515 }
3516
3517 // Hash //
3518
3519 public static void eina_hash_keys_int_empty_iterator()
3520 {
3521 var hsh = new eina.Hash<int, int>();
3522 var itr = hsh.Keys();
3404 bool entered = false; 3523 bool entered = false;
3405 var i = 0;
3406 foreach (int e in itr) 3524 foreach (int e in itr)
3407 { 3525 {
3408 entered = true; 3526 entered = true;
3409 Test.Assert(e == base_seq_int[i]);
3410 ++i;
3411 } 3527 }
3412 Test.Assert(entered); 3528 Test.Assert(!entered);
3529 }
3530
3531 public static void eina_hash_values_int_empty_iterator()
3532 {
3533 var hsh = new eina.Hash<int, int>();
3534 var itr = hsh.Values();
3535 bool entered = false;
3536 foreach (int e in itr)
3537 {
3538 entered = true;
3539 }
3540 Test.Assert(!entered);
3541 }
3542
3543 public static void eina_hash_keys_int_filled_iterator()
3544 {
3545 var hsh = new eina.Hash<int, int>();
3546 var dct = new Dictionary<int, bool>();
3547 hsh[22] = 222;
3548 hsh[44] = 444;
3549 hsh[88] = 888;
3550 dct[22] = true;
3551 dct[44] = true;
3552 dct[88] = true;
3553
3554 var itr = hsh.Keys();
3555
3556 int idx = 0;
3557 foreach (int e in itr)
3558 {
3559 Test.Assert(dct[e]);
3560 dct.Remove(e);
3561 ++idx;
3562 }
3563 Test.AssertEquals(dct.Count, 0);
3564 Test.AssertEquals(idx, 3);
3565 }
3566
3567 public static void eina_hash_values_int_filled_iterator()
3568 {
3569 var hsh = new eina.Hash<int, int>();
3570 var dct = new Dictionary<int, bool>();
3571 hsh[22] = 222;
3572 hsh[44] = 444;
3573 hsh[88] = 888;
3574 dct[222] = true;
3575 dct[444] = true;
3576 dct[888] = true;
3577
3578 var itr = hsh.Values();
3579
3580 int idx = 0;
3581 foreach (int e in itr)
3582 {
3583 Test.Assert(dct[e]);
3584 dct.Remove(e);
3585 ++idx;
3586 }
3587 Test.AssertEquals(dct.Count, 0);
3588 Test.AssertEquals(idx, 3);
3589 }
3590
3591 public static void eina_hash_keys_str_empty_iterator()
3592 {
3593 var hsh = new eina.Hash<string, string>();
3594 var itr = hsh.Keys();
3595 bool entered = false;
3596 foreach (string e in itr)
3597 {
3598 entered = true;
3599 }
3600 Test.Assert(!entered);
3601 }
3602
3603 public static void eina_hash_values_str_empty_iterator()
3604 {
3605 var hsh = new eina.Hash<string, string>();
3606 var itr = hsh.Values();
3607 bool entered = false;
3608 foreach (string e in itr)
3609 {
3610 entered = true;
3611 }
3612 Test.Assert(!entered);
3613 }
3614
3615 public static void eina_hash_keys_str_filled_iterator()
3616 {
3617 var hsh = new eina.Hash<string, string>();
3618 var dct = new Dictionary<string, bool>();
3619 hsh["aa"] = "aaa";
3620 hsh["bb"] = "bbb";
3621 hsh["cc"] = "ccc";
3622 dct["aa"] = true;
3623 dct["bb"] = true;
3624 dct["cc"] = true;
3625
3626 var itr = hsh.Keys();
3627
3628 int idx = 0;
3629 foreach (string e in itr)
3630 {
3631 Test.Assert(dct[e]);
3632 dct.Remove(e);
3633 ++idx;
3634 }
3635 Test.AssertEquals(dct.Count, 0);
3636 Test.AssertEquals(idx, 3);
3637 }
3638
3639 public static void eina_hash_values_str_filled_iterator()
3640 {
3641 var hsh = new eina.Hash<string, string>();
3642 var dct = new Dictionary<string, bool>();
3643 hsh["aa"] = "aaa";
3644 hsh["bb"] = "bbb";
3645 hsh["cc"] = "ccc";
3646 dct["aaa"] = true;
3647 dct["bbb"] = true;
3648 dct["ccc"] = true;
3649
3650 var itr = hsh.Values();
3651
3652 int idx = 0;
3653 foreach (string e in itr)
3654 {
3655 Test.Assert(dct[e]);
3656 dct.Remove(e);
3657 ++idx;
3658 }
3659 Test.AssertEquals(dct.Count, 0);
3660 Test.AssertEquals(idx, 3);
3661 }
3662
3663 public static void eina_hash_keys_obj_empty_iterator()
3664 {
3665 var hsh = new eina.Hash<test.Numberwrapper, test.Numberwrapper>();
3666 var itr = hsh.Keys();
3667 bool entered = false;
3668 foreach (test.Numberwrapper e in itr)
3669 {
3670 entered = true;
3671 }
3672 Test.Assert(!entered);
3673 }
3674
3675 public static void eina_hash_values_obj_empty_iterator()
3676 {
3677 var hsh = new eina.Hash<test.Numberwrapper, test.Numberwrapper>();
3678 var itr = hsh.Values();
3679 bool entered = false;
3680 foreach (test.Numberwrapper e in itr)
3681 {
3682 entered = true;
3683 }
3684 Test.Assert(!entered);
3685 }
3686
3687 public static void eina_hash_keys_obj_filled_iterator()
3688 {
3689 var hsh = new eina.Hash<test.Numberwrapper, test.Numberwrapper>();
3690 var dct = new eina.Hash<int, test.Numberwrapper>();
3691 var a = NW(22);
3692 var b = NW(44);
3693 var c = NW(88);
3694 var aa = NW(222);
3695 var bb = NW(444);
3696 var cc = NW(888);
3697 hsh[a] = aa;
3698 hsh[b] = bb;
3699 hsh[c] = cc;
3700 dct[a.number_get()] = a;
3701 dct[b.number_get()] = b;
3702 dct[c.number_get()] = c;
3703
3704 var itr = hsh.Keys();
3705
3706 int idx = 0;
3707 foreach (test.Numberwrapper e in itr)
3708 {
3709 Test.Assert(dct[e.number_get()] != null);
3710 Test.Assert(dct[e.number_get()].raw_handle == e.raw_handle);
3711 Test.Assert(dct[e.number_get()].number_get() == e.number_get());
3712 dct.Remove(e.number_get());
3713 ++idx;
3714 }
3715 Test.AssertEquals(dct.Count, 0);
3716 Test.AssertEquals(idx, 3);
3717 }
3718
3719 public static void eina_hash_values_obj_filled_iterator()
3720 {
3721 var hsh = new eina.Hash<test.Numberwrapper, test.Numberwrapper>();
3722 var dct = new eina.Hash<int, test.Numberwrapper>();
3723 var a = NW(22);
3724 var b = NW(44);
3725 var c = NW(88);
3726 var aa = NW(222);
3727 var bb = NW(444);
3728 var cc = NW(888);
3729 hsh[a] = aa;
3730 hsh[b] = bb;
3731 hsh[c] = cc;
3732 dct[aa.number_get()] = aa;
3733 dct[bb.number_get()] = bb;
3734 dct[cc.number_get()] = cc;
3735
3736 var itr = hsh.Values();
3737
3738 int idx = 0;
3739 foreach (test.Numberwrapper e in itr)
3740 {
3741 Test.Assert(dct[e.number_get()] != null);
3742 Test.Assert(dct[e.number_get()].raw_handle == e.raw_handle);
3743 Test.Assert(dct[e.number_get()].number_get() == e.number_get());
3744 dct.Remove(e.number_get());
3745 ++idx;
3746 }
3747 Test.AssertEquals(dct.Count, 0);
3748 Test.AssertEquals(idx, 3);
3413 } 3749 }
3414 3750
3415// // // 3751// // //