summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Cavalcante de Sousa <lucas@expertisesolutions.com.br>2020-02-07 19:53:39 +0000
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2020-02-13 15:26:50 -0300
commit4f3b3a33f5b8b93cfbfb0740318087d277639ea4 (patch)
tree74ce8d0fbf5f701706953a52018f2910e3991e82
parent93d4ffc9404cc2305c5690417fa0fc287afdf3a5 (diff)
efl_mono: Create insert list/array c# wrapper for eina_value.
Implements Insert() method to eina.Value containers (array/list). The Insert() (src/bindings/mono/eina_mono/eina_value.cs) method wraps native functions implemented with c (src/lib/eina/eina_inline_value.x). Resolves T7402 Differential Revision: https://phab.enlightenment.org/D11298
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs144
-rw-r--r--src/lib/efl_mono/efl_custom_exports_mono.c25
-rw-r--r--src/tests/efl_mono/Value.cs504
3 files changed, 673 insertions, 0 deletions
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
index 46d1ff0..538374f 100644
--- a/src/bindings/mono/eina_mono/eina_value.cs
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -260,6 +260,58 @@ static internal class UnsafeNativeMethods
260 260
261 [DllImport(efl.Libs.CustomExports)] 261 [DllImport(efl.Libs.CustomExports)]
262 [return: MarshalAsAttribute(UnmanagedType.U1)] 262 [return: MarshalAsAttribute(UnmanagedType.U1)]
263 internal static extern bool eina_value_container_insert_wrapper_string(IntPtr handle, uint p, string data);
264
265 [DllImport(efl.Libs.CustomExports)]
266 [return: MarshalAsAttribute(UnmanagedType.U1)]
267 internal static extern bool eina_value_container_insert_wrapper_ptr(IntPtr handle, uint p, IntPtr data);
268
269 [DllImport(efl.Libs.CustomExports)]
270 [return: MarshalAsAttribute(UnmanagedType.U1)]
271 internal static extern bool eina_value_container_insert_wrapper_char(IntPtr handle, uint p, sbyte data);
272
273 [DllImport(efl.Libs.CustomExports)]
274 [return: MarshalAsAttribute(UnmanagedType.U1)]
275 internal static extern bool eina_value_container_insert_wrapper_uchar(IntPtr handle, uint p, byte data);
276
277 [DllImport(efl.Libs.CustomExports)]
278 [return: MarshalAsAttribute(UnmanagedType.U1)]
279 internal static extern bool eina_value_container_insert_wrapper_short(IntPtr handle, uint p, short data);
280
281 [DllImport(efl.Libs.CustomExports)]
282 [return: MarshalAsAttribute(UnmanagedType.U1)]
283 internal static extern bool eina_value_container_insert_wrapper_ushort(IntPtr handle, uint p, ushort data);
284
285 [DllImport(efl.Libs.CustomExports)]
286 [return: MarshalAsAttribute(UnmanagedType.U1)]
287 internal static extern bool eina_value_container_insert_wrapper_int(IntPtr handle, uint p, int data);
288
289 [DllImport(efl.Libs.CustomExports)]
290 [return: MarshalAsAttribute(UnmanagedType.U1)]
291 internal static extern bool eina_value_container_insert_wrapper_uint(IntPtr handle, uint p, uint data);
292
293 [DllImport(efl.Libs.CustomExports)]
294 [return: MarshalAsAttribute(UnmanagedType.U1)]
295 internal static extern bool eina_value_container_insert_wrapper_long(IntPtr handle, uint p, long data);
296
297 [DllImport(efl.Libs.CustomExports)]
298 [return: MarshalAsAttribute(UnmanagedType.U1)]
299 internal static extern bool eina_value_container_insert_wrapper_ulong(IntPtr handle, uint p, ulong data);
300
301 [DllImport(efl.Libs.CustomExports)]
302 [return: MarshalAsAttribute(UnmanagedType.U1)]
303 internal static extern bool eina_value_container_insert_wrapper_float(IntPtr handle, uint p, float data);
304
305 [DllImport(efl.Libs.CustomExports)]
306 [return: MarshalAsAttribute(UnmanagedType.U1)]
307 internal static extern bool eina_value_container_insert_wrapper_double(IntPtr handle, uint p, double data);
308
309 [DllImport(efl.Libs.CustomExports)]
310 [return: MarshalAsAttribute(UnmanagedType.U1)]
311 internal static extern bool eina_value_list_insert_wrapper(IntPtr handle, uint p, IntPtr data);
312
313 [DllImport(efl.Libs.CustomExports)]
314 [return: MarshalAsAttribute(UnmanagedType.U1)]
263 internal static extern bool eina_value_container_get_wrapper(IntPtr handle, int index, out IntPtr output); 315 internal static extern bool eina_value_container_get_wrapper(IntPtr handle, int index, out IntPtr output);
264 316
265 [DllImport(efl.Libs.CustomExports)] 317 [DllImport(efl.Libs.CustomExports)]
@@ -3425,6 +3477,98 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
3425 return false; 3477 return false;
3426 } 3478 }
3427 3479
3480 /// <summary>Insert new values to this container at a given position.
3481 ///
3482 /// <para>Since EFL 1.23.</para>
3483 /// </summary>
3484 /// <param name="o">The new value to be inserted.</param>
3485 /// <param name="p">The position to insert the new value.</param>
3486 /// <returns><c>true</c> if the value was successfully insert.</returns>
3487 public bool Insert(object o, uint p)
3488 {
3489 Contract.Requires(o != null, nameof(o));
3490 ContainerSanityChecks();
3491
3492 switch (GetValueSubType())
3493 {
3494 case ValueType.SByte:
3495 {
3496 sbyte b = Convert.ToSByte(o, CultureInfo.CurrentCulture);
3497 return eina_value_container_insert_wrapper_char(this.Handle, p, b);
3498 }
3499
3500 case ValueType.Byte:
3501 {
3502 byte b = Convert.ToByte(o, CultureInfo.CurrentCulture);
3503 return eina_value_container_insert_wrapper_uchar(this.Handle, p, b);
3504 }
3505
3506 case ValueType.Short:
3507 {
3508 short b = Convert.ToInt16(o, CultureInfo.CurrentCulture);
3509 return eina_value_container_insert_wrapper_short(this.Handle, p, b);
3510 }
3511
3512 case ValueType.UShort:
3513 {
3514 ushort b = Convert.ToUInt16(o, CultureInfo.CurrentCulture);
3515 return eina_value_container_insert_wrapper_ushort(this.Handle, p, b);
3516 }
3517
3518 case ValueType.Int32:
3519 {
3520 int x = Convert.ToInt32(o, CultureInfo.CurrentCulture);
3521 return eina_value_container_insert_wrapper_int(this.Handle, p, x);
3522 }
3523
3524 case ValueType.UInt32:
3525 {
3526 uint x = Convert.ToUInt32(o, CultureInfo.CurrentCulture);
3527 return eina_value_container_insert_wrapper_uint(this.Handle, p, x);
3528 }
3529
3530 case ValueType.Long:
3531 case ValueType.Int64:
3532 {
3533 long x = Convert.ToInt64(o, CultureInfo.CurrentCulture);
3534 return eina_value_container_insert_wrapper_long(this.Handle, p, x);
3535 }
3536
3537 case ValueType.ULong:
3538 case ValueType.UInt64:
3539 {
3540 ulong x = Convert.ToUInt64(o, CultureInfo.CurrentCulture);
3541 return eina_value_container_insert_wrapper_ulong(this.Handle, p, x);
3542 }
3543
3544 case ValueType.Float:
3545 {
3546 float x = Convert.ToSingle(o, CultureInfo.CurrentCulture);
3547 return eina_value_container_insert_wrapper_float(this.Handle, p, x);
3548 }
3549
3550 case ValueType.Double:
3551 {
3552 double x = Convert.ToDouble(o, CultureInfo.CurrentCulture);
3553 return eina_value_container_insert_wrapper_double(this.Handle, p, x);
3554 }
3555
3556 case ValueType.String:
3557 {
3558 string x = Convert.ToString(o, CultureInfo.CurrentCulture);
3559 return eina_value_container_insert_wrapper_string(this.Handle, p, x);
3560 }
3561 case ValueType.Object:
3562 {
3563 var x = (Efl.Object) o;
3564 return eina_value_container_insert_wrapper_ptr(this.Handle, p, x.NativeHandle);
3565 }
3566 }
3567
3568 return false;
3569 }
3570
3571
3428 /// <summary>Indexer for this container. 3572 /// <summary>Indexer for this container.
3429 /// 3573 ///
3430 /// <para>Since EFL 1.23.</para> 3574 /// <para>Since EFL 1.23.</para>
diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c
index 93cfc54..7b10c79 100644
--- a/src/lib/efl_mono/efl_custom_exports_mono.c
+++ b/src/lib/efl_mono/efl_custom_exports_mono.c
@@ -543,6 +543,31 @@ EINA_CONTAINER_APPEND_WRAPPER(double, double)
543EINA_CONTAINER_APPEND_WRAPPER(string, const char *) 543EINA_CONTAINER_APPEND_WRAPPER(string, const char *)
544EINA_CONTAINER_APPEND_WRAPPER(ptr, void *) 544EINA_CONTAINER_APPEND_WRAPPER(ptr, void *)
545 545
546#define EINA_CONTAINER_INSERT_WRAPPER(N, T) EAPI Eina_Bool eina_value_container_insert_wrapper_##N(Eina_Value *value, unsigned int position, T new_value) \
547{ \
548 const Eina_Value_Type *tp = eina_value_type_get(value); \
549 if (tp == EINA_VALUE_TYPE_ARRAY) \
550 return eina_value_array_insert(value, position, new_value); \
551 else if (tp == EINA_VALUE_TYPE_LIST) \
552 return eina_value_list_insert(value, position, new_value); \
553 else \
554 return EINA_FALSE; \
555}
556
557EINA_CONTAINER_INSERT_WRAPPER(char, char)
558EINA_CONTAINER_INSERT_WRAPPER(uchar, unsigned char)
559EINA_CONTAINER_INSERT_WRAPPER(short, short)
560EINA_CONTAINER_INSERT_WRAPPER(ushort, unsigned short)
561EINA_CONTAINER_INSERT_WRAPPER(int, int)
562EINA_CONTAINER_INSERT_WRAPPER(uint, unsigned int)
563EINA_CONTAINER_INSERT_WRAPPER(long, long)
564EINA_CONTAINER_INSERT_WRAPPER(ulong, unsigned long)
565EINA_CONTAINER_INSERT_WRAPPER(float, float)
566EINA_CONTAINER_INSERT_WRAPPER(double, double)
567EINA_CONTAINER_INSERT_WRAPPER(string, const char *)
568EINA_CONTAINER_INSERT_WRAPPER(ptr, void *)
569
570
546EAPI void eina_value_container_get_wrapper(const Eina_Value *value, int i, void *output) 571EAPI void eina_value_container_get_wrapper(const Eina_Value *value, int i, void *output)
547{ 572{
548 const Eina_Value_Type *tp = eina_value_type_get(value); 573 const Eina_Value_Type *tp = eina_value_type_get(value);
diff --git a/src/tests/efl_mono/Value.cs b/src/tests/efl_mono/Value.cs
index 29856d4..a828939 100644
--- a/src/tests/efl_mono/Value.cs
+++ b/src/tests/efl_mono/Value.cs
@@ -877,6 +877,510 @@ public static class TestEinaValue {
877 } 877 }
878 } 878 }
879 879
880 public static void TestInsertValueArrayOfSByte()
881 {
882 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.SByte)) {
883 Test.AssertEquals(0, array.Count());
884 Test.Assert(!array.Insert(0, 3));
885 Test.Assert(!array.Insert(0, 1));
886 Test.Assert(!array.Insert(-123, 12));
887 Test.AssertEquals(0, array.Count());
888
889 Test.Assert(array.Insert(0, 0));
890 Test.AssertEquals(1, array.Count());
891 Test.Assert(array.Insert(6, 1));
892 Test.AssertEquals(2, array.Count());
893 Test.Assert(array.Insert(-122, 0));
894 Test.AssertEquals(3, array.Count());
895 Test.Assert(array.Insert(30, 1));
896 Test.AssertEquals(4, array.Count());
897
898 Test.AssertEquals((sbyte)array[0], (sbyte)-122);
899 Test.AssertEquals((sbyte)array[1], (sbyte)30);
900 Test.AssertEquals((sbyte)array[2], (sbyte)0);
901 Test.AssertEquals((sbyte)array[3], (sbyte)6);
902
903 array[0] = 120;
904 array[1] = -42;
905 Test.AssertEquals(4, array.Count());
906
907 Test.AssertEquals((sbyte)array[0], (sbyte)120);
908 Test.AssertEquals((sbyte)array[1], (sbyte)-42);
909 Test.AssertEquals((sbyte)array[2], (sbyte)0);
910 Test.AssertEquals((sbyte)array[3], (sbyte)6);
911
912 Test.AssertEquals("[120, -42, 0, 6]", array.ToString());
913 }
914 }
915
916 public static void TestInsertValueArrayOfByte()
917 {
918 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Byte)) {
919 Test.AssertEquals(0, array.Count());
920 Test.Assert(!array.Insert(0, 3));
921 Test.Assert(!array.Insert(0, 1));
922 Test.Assert(!array.Insert(123, 12));
923 Test.AssertEquals(0, array.Count());
924
925 Test.Assert(array.Insert(0, 0));
926 Test.AssertEquals(1, array.Count());
927 Test.Assert(array.Insert(6, 1));
928 Test.AssertEquals(2, array.Count());
929 Test.Assert(array.Insert(122, 0));
930 Test.AssertEquals(3, array.Count());
931 Test.Assert(array.Insert(30, 1));
932 Test.AssertEquals(4, array.Count());
933
934 Test.AssertEquals((byte)array[0], (byte)122);
935 Test.AssertEquals((byte)array[1], (byte)30);
936 Test.AssertEquals((byte)array[2], (byte)0);
937 Test.AssertEquals((byte)array[3], (byte)6);
938
939 array[0] = 120;
940 array[1] = 42;
941 Test.AssertEquals(4, array.Count());
942
943 Test.AssertEquals((byte)array[0], (byte)120);
944 Test.AssertEquals((byte)array[1], (byte)42);
945 Test.AssertEquals((byte)array[2], (byte)0);
946 Test.AssertEquals((byte)array[3], (byte)6);
947
948 Test.AssertEquals("[120, 42, 0, 6]", array.ToString());
949 }
950 }
951
952 public static void TestInsertValueArrayOfInts()
953 {
954 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) {
955 Test.AssertEquals(0, array.Count());
956 Test.Assert(!array.Insert(0, 3));
957 Test.Assert(!array.Insert(0, 1));
958 Test.Assert(!array.Insert(123, 12));
959 Test.AssertEquals(0, array.Count());
960
961 Test.Assert(array.Insert(0, 0));
962 Test.AssertEquals(1, array.Count());
963 Test.Assert(array.Insert(1, 1));
964 Test.AssertEquals(2, array.Count());
965 Test.Assert(array.Insert(5, 0));
966 Test.AssertEquals(3, array.Count());
967 Test.Assert(array.Insert(42, 1));
968 Test.AssertEquals(4, array.Count());
969
970 Test.AssertEquals((int)array[0], (int)5);
971 Test.AssertEquals((int)array[1], (int)42);
972 Test.AssertEquals((int)array[2], (int)0);
973 Test.AssertEquals((int)array[3], (int)1);
974
975 array[0] = 1984;
976 array[1] = -42;
977 Test.AssertEquals(4, array.Count());
978
979 Test.AssertEquals((int)array[0], (int)1984);
980 Test.AssertEquals((int)array[1], (int)-42);
981 Test.AssertEquals((int)array[2], (int)0);
982 Test.AssertEquals((int)array[3], (int)1);
983
984 Test.AssertEquals("[1984, -42, 0, 1]", array.ToString());
985 }
986 }
987
988 public static void TestInsertValueArrayOfInt64s()
989 {
990 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int64)) {
991 Test.AssertEquals(0, array.Count());
992 Test.Assert(!array.Insert(0, 3));
993 Test.Assert(!array.Insert(0, 1));
994 Test.Assert(!array.Insert(123, 12));
995 Test.AssertEquals(0, array.Count());
996
997 Test.Assert(array.Insert(0,0));
998 Test.AssertEquals(1, array.Count());
999 Test.Assert(array.Insert(10000000000,1));
1000 Test.AssertEquals(2, array.Count());
1001 Test.Assert(array.Insert(5,0));
1002 Test.AssertEquals(3, array.Count());
1003 Test.Assert(array.Insert(42,1));
1004 Test.AssertEquals(4, array.Count());
1005
1006 Test.AssertEquals((long)array[0], (long)5);
1007 Test.AssertEquals((long)array[1], (long)42);
1008 Test.AssertEquals((long)array[2], (long)0);
1009 Test.AssertEquals((long)array[3], (long)10000000000);
1010
1011 array[0] = 1984;
1012 array[1] = -42;
1013 Test.AssertEquals(4, array.Count());
1014
1015 Test.AssertEquals((long)array[0], (long)1984);
1016 Test.AssertEquals((long)array[1], (long)-42);
1017 Test.AssertEquals((long)array[2], (long)0);
1018 Test.AssertEquals((long)array[3], (long)10000000000);
1019
1020 Test.AssertEquals("[1984, -42, 0, 10000000000]", array.ToString());
1021 }
1022 }
1023
1024 public static void TestInsertValueArrayOfUInts()
1025 {
1026
1027 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.UInt32)) {
1028 Test.AssertEquals(0, array.Count());
1029 Test.Assert(!array.Insert(0, 3));
1030 Test.Assert(!array.Insert(0, 1));
1031 Test.Assert(!array.Insert(123, 12));
1032 Test.AssertEquals(0, array.Count());
1033
1034 Test.Assert(array.Insert(0,0));
1035 Test.AssertEquals(1, array.Count());
1036 Test.Assert(array.Insert(7,1));
1037 Test.AssertEquals(2, array.Count());
1038 Test.Assert(array.Insert(5,0));
1039 Test.AssertEquals(3, array.Count());
1040 Test.Assert(array.Insert(42,1));
1041 Test.AssertEquals(4, array.Count());
1042
1043 Test.AssertEquals((uint)array[0], (uint)5);
1044 Test.AssertEquals((uint)array[1], (uint)42);
1045 Test.AssertEquals((uint)array[2], (uint)0);
1046 Test.AssertEquals((uint)array[3], (uint)7);
1047
1048 array[0] = 1984;
1049 array[1] = 100;
1050 Test.AssertEquals(4, array.Count());
1051
1052 Test.AssertEquals((uint)array[0], (uint)1984);
1053 Test.AssertEquals((uint)array[1], (uint)100);
1054 Test.AssertEquals((uint)array[2], (uint)0);
1055 Test.AssertEquals((uint)array[3], (uint)7);
1056
1057 Test.AssertEquals("[1984, 100, 0, 7]", array.ToString());
1058 }
1059 }
1060
1061 public static void TestInsertValueArrayOfStrings()
1062 {
1063
1064 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.String)) {
1065
1066 Test.AssertEquals(0, array.Count());
1067 Test.Assert(!array.Insert("hello",3));
1068 Test.Assert(!array.Insert("world",12));
1069 Test.AssertEquals(0, array.Count());
1070
1071 Test.Assert(array.Insert("hello",0));
1072 Test.Assert(array.Insert("world",1));
1073 Test.Assert(array.Insert("first",0));
1074 Test.Assert(array.Insert("sec",1));
1075
1076 Test.AssertEquals((string)array[0], (string)"first");
1077 Test.AssertEquals((string)array[1], (string)"sec");
1078 Test.AssertEquals((string)array[2], (string)"hello");
1079 Test.AssertEquals((string)array[3], (string)"world");
1080
1081 array[0] = "efl";
1082 array[1] = "rocks";
1083 Test.AssertEquals(4, array.Count());
1084
1085 Test.AssertEquals((string)array[0], (string)"efl");
1086 Test.AssertEquals((string)array[1], (string)"rocks");
1087 Test.AssertEquals((string)array[2], (string)"hello");
1088 Test.AssertEquals((string)array[3], (string)"world");
1089 }
1090 }
1091
1092 public static void TestInsertValueArrayOfObjects()
1093 {
1094
1095 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Object)) {
1096
1097 var a = new Dummy.TestObject();
1098 var b = new Dummy.TestObject();
1099 var c = new Dummy.TestObject();
1100 var d = new Dummy.TestObject();
1101
1102 Test.AssertEquals(0, array.Count());
1103 Test.Assert(!array.Insert(a,12));
1104 Test.Assert(!array.Insert(b,3));
1105 Test.AssertEquals(0, array.Count());
1106
1107 Test.Assert(array.Insert(a,0));
1108 Test.Assert(array.Insert(b,1));
1109 Test.Assert(array.Insert(c,0));
1110 Test.Assert(array.Insert(d,1));
1111
1112 Test.AssertEquals((Efl.Object)array[0], c);
1113 Test.AssertEquals((Efl.Object)array[1], d);
1114 Test.AssertEquals((Efl.Object)array[2], a);
1115 Test.AssertEquals((Efl.Object)array[3], b);
1116
1117 array[0] = a;
1118 array[1] = b;
1119
1120 Test.AssertEquals((Efl.Object)array[0], a);
1121 Test.AssertEquals((Efl.Object)array[1], b);
1122 Test.AssertEquals((Efl.Object)array[2], a);
1123 Test.AssertEquals((Efl.Object)array[3], b);
1124
1125 d.Dispose();
1126 c.Dispose();
1127 b.Dispose();
1128 a.Dispose();
1129 }
1130 }
1131
1132 public static void TestInsertValueListOfSByte()
1133 {
1134 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.SByte)) {
1135 Test.AssertEquals(0, list.Count());
1136 Test.Assert(!list.Insert(0, 3));
1137 Test.Assert(!list.Insert(0, 1));
1138 Test.Assert(!list.Insert(-123, 12));
1139 Test.AssertEquals(0, list.Count());
1140
1141 Test.Assert(list.Insert(0, 0));
1142 Test.AssertEquals(1, list.Count());
1143 Test.Assert(list.Insert(6, 1));
1144 Test.AssertEquals(2, list.Count());
1145 Test.Assert(list.Insert(-122, 0));
1146 Test.AssertEquals(3, list.Count());
1147 Test.Assert(list.Insert(30, 1));
1148 Test.AssertEquals(4, list.Count());
1149
1150 Test.AssertEquals((sbyte)list[0], (sbyte)-122);
1151 Test.AssertEquals((sbyte)list[1], (sbyte)30);
1152 Test.AssertEquals((sbyte)list[2], (sbyte)0);
1153 Test.AssertEquals((sbyte)list[3], (sbyte)6);
1154
1155 list[0] = 120;
1156 list[1] = -42;
1157 Test.AssertEquals(4, list.Count());
1158
1159 Test.AssertEquals((sbyte)list[0], (sbyte)120);
1160 Test.AssertEquals((sbyte)list[1], (sbyte)-42);
1161 Test.AssertEquals((sbyte)list[2], (sbyte)0);
1162 Test.AssertEquals((sbyte)list[3], (sbyte)6);
1163
1164 Test.AssertEquals("[120, -42, 0, 6]", list.ToString());
1165 }
1166 }
1167
1168 public static void TestInsertValueListOfByte()
1169 {
1170 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Byte)) {
1171 Test.AssertEquals(0, list.Count());
1172 Test.Assert(!list.Insert(0, 3));
1173 Test.Assert(!list.Insert(0, 1));
1174 Test.Assert(!list.Insert(123, 12));
1175 Test.AssertEquals(0, list.Count());
1176
1177 Test.Assert(list.Insert(0, 0));
1178 Test.AssertEquals(1, list.Count());
1179 Test.Assert(list.Insert(6, 1));
1180 Test.AssertEquals(2, list.Count());
1181 Test.Assert(list.Insert(122, 0));
1182 Test.AssertEquals(3, list.Count());
1183 Test.Assert(list.Insert(30, 1));
1184 Test.AssertEquals(4, list.Count());
1185
1186 Test.AssertEquals((byte)list[0], (byte)122);
1187 Test.AssertEquals((byte)list[1], (byte)30);
1188 Test.AssertEquals((byte)list[2], (byte)0);
1189 Test.AssertEquals((byte)list[3], (byte)6);
1190
1191 list[0] = 120;
1192 list[1] = 42;
1193 Test.AssertEquals(4, list.Count());
1194
1195 Test.AssertEquals((byte)list[0], (byte)120);
1196 Test.AssertEquals((byte)list[1], (byte)42);
1197 Test.AssertEquals((byte)list[2], (byte)0);
1198 Test.AssertEquals((byte)list[3], (byte)6);
1199
1200 Test.AssertEquals("[120, 42, 0, 6]", list.ToString());
1201 }
1202 }
1203
1204 public static void TestInsertValueListOfInts()
1205 {
1206 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) {
1207 Test.AssertEquals(0, list.Count());
1208 Test.Assert(!list.Insert(0, 3));
1209 Test.Assert(!list.Insert(0, 1));
1210 Test.Assert(!list.Insert(123, 12));
1211 Test.AssertEquals(0, list.Count());
1212
1213 Test.Assert(list.Insert(0, 0));
1214 Test.AssertEquals(1, list.Count());
1215 Test.Assert(list.Insert(1, 1));
1216 Test.AssertEquals(2, list.Count());
1217 Test.Assert(list.Insert(5, 0));
1218 Test.AssertEquals(3, list.Count());
1219 Test.Assert(list.Insert(42, 1));
1220 Test.AssertEquals(4, list.Count());
1221
1222 Test.AssertEquals((int)list[0], (int)5);
1223 Test.AssertEquals((int)list[1], (int)42);
1224 Test.AssertEquals((int)list[2], (int)0);
1225 Test.AssertEquals((int)list[3], (int)1);
1226
1227 list[0] = 1984;
1228 list[1] = -42;
1229 Test.AssertEquals(4, list.Count());
1230
1231 Test.AssertEquals((int)list[0], (int)1984);
1232 Test.AssertEquals((int)list[1], (int)-42);
1233 Test.AssertEquals((int)list[2], (int)0);
1234 Test.AssertEquals((int)list[3], (int)1);
1235
1236 Test.AssertEquals("[1984, -42, 0, 1]", list.ToString());
1237 }
1238 }
1239
1240 public static void TestInsertValueListOfInt64s()
1241 {
1242 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int64)) {
1243 Test.AssertEquals(0, list.Count());
1244 Test.Assert(!list.Insert(0, 3));
1245 Test.Assert(!list.Insert(0, 1));
1246 Test.Assert(!list.Insert(123, 12));
1247 Test.AssertEquals(0, list.Count());
1248
1249 Test.Assert(list.Insert(0,0));
1250 Test.AssertEquals(1, list.Count());
1251 Test.Assert(list.Insert(10000000000,1));
1252 Test.AssertEquals(2, list.Count());
1253 Test.Assert(list.Insert(5,0));
1254 Test.AssertEquals(3, list.Count());
1255 Test.Assert(list.Insert(42,1));
1256 Test.AssertEquals(4, list.Count());
1257
1258 Test.AssertEquals((long)list[0], (long)5);
1259 Test.AssertEquals((long)list[1], (long)42);
1260 Test.AssertEquals((long)list[2], (long)0);
1261 Test.AssertEquals((long)list[3], (long)10000000000);
1262
1263 list[0] = 1984;
1264 list[1] = -42;
1265 Test.AssertEquals(4, list.Count());
1266
1267 Test.AssertEquals((long)list[0], (long)1984);
1268 Test.AssertEquals((long)list[1], (long)-42);
1269 Test.AssertEquals((long)list[2], (long)0);
1270 Test.AssertEquals((long)list[3], (long)10000000000);
1271
1272 Test.AssertEquals("[1984, -42, 0, 10000000000]", list.ToString());
1273 }
1274 }
1275
1276 public static void TestInsertValueListOfUInts()
1277 {
1278
1279 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.UInt32)) {
1280 Test.AssertEquals(0, list.Count());
1281 Test.Assert(!list.Insert(0, 3));
1282 Test.Assert(!list.Insert(0, 1));
1283 Test.Assert(!list.Insert(123, 12));
1284 Test.AssertEquals(0, list.Count());
1285
1286 Test.Assert(list.Insert(0,0));
1287 Test.AssertEquals(1, list.Count());
1288 Test.Assert(list.Insert(7,1));
1289 Test.AssertEquals(2, list.Count());
1290 Test.Assert(list.Insert(5,0));
1291 Test.AssertEquals(3, list.Count());
1292 Test.Assert(list.Insert(42,1));
1293 Test.AssertEquals(4, list.Count());
1294
1295 Test.AssertEquals((uint)list[0], (uint)5);
1296 Test.AssertEquals((uint)list[1], (uint)42);
1297 Test.AssertEquals((uint)list[2], (uint)0);
1298 Test.AssertEquals((uint)list[3], (uint)7);
1299
1300 list[0] = 1984;
1301 list[1] = 100;
1302 Test.AssertEquals(4, list.Count());
1303
1304 Test.AssertEquals((uint)list[0], (uint)1984);
1305 Test.AssertEquals((uint)list[1], (uint)100);
1306 Test.AssertEquals((uint)list[2], (uint)0);
1307 Test.AssertEquals((uint)list[3], (uint)7);
1308
1309 Test.AssertEquals("[1984, 100, 0, 7]", list.ToString());
1310 }
1311 }
1312
1313 public static void TestInsertValueListOfStrings()
1314 {
1315
1316 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.String)) {
1317
1318 Test.AssertEquals(0, list.Count());
1319 Test.Assert(!list.Insert("Nice",2));
1320 Test.Assert(!list.Insert("efl",5));
1321 Test.AssertEquals(0, list.Count());
1322
1323 Test.Assert(list.Insert("hello",0));
1324 Test.Assert(list.Insert("world",1));
1325 Test.Assert(list.Insert("first",0));
1326 Test.Assert(list.Insert("sec",1));
1327
1328 Test.AssertEquals((string)list[0], (string)"first");
1329 Test.AssertEquals((string)list[1], (string)"sec");
1330 Test.AssertEquals((string)list[2], (string)"hello");
1331 Test.AssertEquals((string)list[3], (string)"world");
1332
1333 list[0] = "efl";
1334 list[1] = "rocks";
1335 Test.AssertEquals(4, list.Count());
1336
1337 Test.AssertEquals((string)list[0], (string)"efl");
1338 Test.AssertEquals((string)list[1], (string)"rocks");
1339 Test.AssertEquals((string)list[2], (string)"hello");
1340 Test.AssertEquals((string)list[3], (string)"world");
1341 }
1342 }
1343
1344 public static void TestInsertValueListOfObjects()
1345 {
1346
1347 using (Eina.Value list = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Object)) {
1348
1349 var a = new Dummy.TestObject();
1350 var b = new Dummy.TestObject();
1351 var c = new Dummy.TestObject();
1352 var d = new Dummy.TestObject();
1353
1354 Test.AssertEquals(0, list.Count());
1355 Test.Assert(!list.Insert(a,6));
1356 Test.Assert(!list.Insert(b,1));
1357 Test.Assert(!list.Insert(c,7));
1358 Test.AssertEquals(0, list.Count());
1359
1360 Test.Assert(list.Insert(a,0));
1361 Test.Assert(list.Insert(b,1));
1362 Test.Assert(list.Insert(c,0));
1363 Test.Assert(list.Insert(d,1));
1364
1365 Test.AssertEquals((Efl.Object)list[0], c);
1366 Test.AssertEquals((Efl.Object)list[1], d);
1367 Test.AssertEquals((Efl.Object)list[2], a);
1368 Test.AssertEquals((Efl.Object)list[3], b);
1369
1370 list[0] = a;
1371 list[1] = b;
1372
1373 Test.AssertEquals((Efl.Object)list[0], a);
1374 Test.AssertEquals((Efl.Object)list[1], b);
1375 Test.AssertEquals((Efl.Object)list[2], a);
1376 Test.AssertEquals((Efl.Object)list[3], b);
1377
1378 d.Dispose();
1379 c.Dispose();
1380 b.Dispose();
1381 a.Dispose();
1382 }
1383 }
880 1384
881 public static void TestArrayOutOfBounds() { 1385 public static void TestArrayOutOfBounds() {
882 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) { 1386 using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32)) {