summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Strings.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/efl_mono/Strings.cs')
-rw-r--r--src/tests/efl_mono/Strings.cs46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/tests/efl_mono/Strings.cs b/src/tests/efl_mono/Strings.cs
index bb20833..afbf282 100644
--- a/src/tests/efl_mono/Strings.cs
+++ b/src/tests/efl_mono/Strings.cs
@@ -1,4 +1,20 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
17using System.Globalization;
2 18
3namespace TestSuite { 19namespace TestSuite {
4 20
@@ -12,6 +28,7 @@ class TestStrings
12 String sent = "in_string"; 28 String sent = "in_string";
13 String returned = obj.InString(sent); 29 String returned = obj.InString(sent);
14 Test.AssertEquals(sent, returned); 30 Test.AssertEquals(sent, returned);
31 obj.Dispose();
15 } 32 }
16 System.GC.Collect(); 33 System.GC.Collect();
17 } 34 }
@@ -25,6 +42,7 @@ class TestStrings
25 String sent = "in_own_string"; 42 String sent = "in_own_string";
26 String returned = obj.InOwnString(sent); 43 String returned = obj.InOwnString(sent);
27 Test.AssertEquals(sent, returned); 44 Test.AssertEquals(sent, returned);
45 obj.Dispose();
28 } 46 }
29 System.GC.Collect(); 47 System.GC.Collect();
30 } 48 }
@@ -35,6 +53,7 @@ class TestStrings
35 { 53 {
36 var obj = new Dummy.TestObject(); 54 var obj = new Dummy.TestObject();
37 Test.AssertEquals("string", obj.ReturnString()); 55 Test.AssertEquals("string", obj.ReturnString());
56 obj.Dispose();
38 } 57 }
39 System.GC.Collect(); 58 System.GC.Collect();
40 } 59 }
@@ -45,6 +64,7 @@ class TestStrings
45 { 64 {
46 var obj = new Dummy.TestObject(); 65 var obj = new Dummy.TestObject();
47 Test.AssertEquals("own_string", obj.ReturnOwnString()); 66 Test.AssertEquals("own_string", obj.ReturnOwnString());
67 obj.Dispose();
48 } 68 }
49 System.GC.Collect(); 69 System.GC.Collect();
50 } 70 }
@@ -57,6 +77,7 @@ class TestStrings
57 var obj = new Dummy.TestObject(); 77 var obj = new Dummy.TestObject();
58 obj.OutString(out str); 78 obj.OutString(out str);
59 Test.AssertEquals("out_string", str); 79 Test.AssertEquals("out_string", str);
80 obj.Dispose();
60 } 81 }
61 System.GC.Collect(); 82 System.GC.Collect();
62 } 83 }
@@ -68,7 +89,9 @@ class TestStrings
68 String str = String.Empty; 89 String str = String.Empty;
69 var obj = new Dummy.TestObject(); 90 var obj = new Dummy.TestObject();
70 obj.OutOwnString(out str); 91 obj.OutOwnString(out str);
71 Test.AssertEquals(str.ToString(), "out_own_string"); 92 Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
93 "out_own_string");
94 obj.Dispose();
72 } 95 }
73 System.GC.Collect(); 96 System.GC.Collect();
74 } 97 }
@@ -126,6 +149,7 @@ class TestStrings
126 Test.AssertEquals(sent, obj.received_in); 149 Test.AssertEquals(sent, obj.received_in);
127 /* } */ 150 /* } */
128 System.GC.Collect(); 151 System.GC.Collect();
152 obj.Dispose();
129 } 153 }
130 154
131 /* The managed wrapper should take ownership of the in parameter */ 155 /* The managed wrapper should take ownership of the in parameter */
@@ -138,6 +162,7 @@ class TestStrings
138 Test.AssertEquals(sent, obj.received_in_own); 162 Test.AssertEquals(sent, obj.received_in_own);
139 /* } */ 163 /* } */
140 System.GC.Collect(); 164 System.GC.Collect();
165 obj.Dispose();
141 } 166 }
142 167
143 /* The managed wrapper still owns the returned C string. We need to cache it until 168 /* The managed wrapper still owns the returned C string. We need to cache it until
@@ -148,6 +173,7 @@ class TestStrings
148 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ 173 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
149 Test.AssertEquals("inherited", obj.CallReturnString()); 174 Test.AssertEquals("inherited", obj.CallReturnString());
150 System.GC.Collect(); 175 System.GC.Collect();
176 obj.Dispose();
151 } 177 }
152 178
153 /* The managed wrapper must surrender the ownership to the C after the virtual call. */ 179 /* The managed wrapper must surrender the ownership to the C after the virtual call. */
@@ -157,6 +183,7 @@ class TestStrings
157 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ 183 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
158 Test.AssertEquals("own_inherited", obj.CallReturnOwnString()); 184 Test.AssertEquals("own_inherited", obj.CallReturnOwnString());
159 System.GC.Collect(); 185 System.GC.Collect();
186 obj.Dispose();
160 } 187 }
161 188
162 /* The managed wrapper still owns the C string after the call. Like return without own, we may 189 /* The managed wrapper still owns the C string after the call. Like return without own, we may
@@ -167,6 +194,7 @@ class TestStrings
167 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ 194 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
168 Test.AssertEquals("out_inherited", obj.CallOutString()); 195 Test.AssertEquals("out_inherited", obj.CallOutString());
169 System.GC.Collect(); 196 System.GC.Collect();
197 obj.Dispose();
170 } 198 }
171 199
172 /* The managed wrapper gives C the ownership of the filled out parameter */ 200 /* The managed wrapper gives C the ownership of the filled out parameter */
@@ -176,6 +204,7 @@ class TestStrings
176 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */ 204 /* for (int i = 0; i < 10000; i ++) // Uncomment this to check for memory leaks. */
177 Test.AssertEquals("out_own_inherited", obj.CallOutOwnString()); 205 Test.AssertEquals("out_own_inherited", obj.CallOutOwnString());
178 System.GC.Collect(); 206 System.GC.Collect();
207 obj.Dispose();
179 } 208 }
180 209
181} 210}
@@ -189,6 +218,7 @@ class TestStringshare
189 String sent = "in_stringshare"; 218 String sent = "in_stringshare";
190 String returned = obj.InStringshare(sent); 219 String returned = obj.InStringshare(sent);
191 Test.AssertEquals(sent, returned); 220 Test.AssertEquals(sent, returned);
221 obj.Dispose();
192 } 222 }
193 System.GC.Collect(); 223 System.GC.Collect();
194 } 224 }
@@ -200,6 +230,7 @@ class TestStringshare
200 String sent = "in_own_stringshare"; 230 String sent = "in_own_stringshare";
201 String returned = obj.InOwnStringshare(sent); 231 String returned = obj.InOwnStringshare(sent);
202 Test.AssertEquals(sent, returned); 232 Test.AssertEquals(sent, returned);
233 obj.Dispose();
203 } 234 }
204 System.GC.Collect(); 235 System.GC.Collect();
205 } 236 }
@@ -209,6 +240,7 @@ class TestStringshare
209 { 240 {
210 var obj = new Dummy.TestObject(); 241 var obj = new Dummy.TestObject();
211 Test.AssertEquals("stringshare", obj.ReturnStringshare()); 242 Test.AssertEquals("stringshare", obj.ReturnStringshare());
243 obj.Dispose();
212 } 244 }
213 System.GC.Collect(); 245 System.GC.Collect();
214 } 246 }
@@ -218,6 +250,7 @@ class TestStringshare
218 { 250 {
219 var obj = new Dummy.TestObject(); 251 var obj = new Dummy.TestObject();
220 Test.AssertEquals("own_stringshare", obj.ReturnOwnStringshare()); 252 Test.AssertEquals("own_stringshare", obj.ReturnOwnStringshare());
253 obj.Dispose();
221 } 254 }
222 System.GC.Collect(); 255 System.GC.Collect();
223 } 256 }
@@ -229,6 +262,7 @@ class TestStringshare
229 var obj = new Dummy.TestObject(); 262 var obj = new Dummy.TestObject();
230 obj.OutStringshare(out str); 263 obj.OutStringshare(out str);
231 Test.AssertEquals("out_stringshare", str); 264 Test.AssertEquals("out_stringshare", str);
265 obj.Dispose();
232 } 266 }
233 System.GC.Collect(); 267 System.GC.Collect();
234 } 268 }
@@ -239,7 +273,9 @@ class TestStringshare
239 String str = String.Empty; 273 String str = String.Empty;
240 var obj = new Dummy.TestObject(); 274 var obj = new Dummy.TestObject();
241 obj.OutOwnStringshare(out str); 275 obj.OutOwnStringshare(out str);
242 Test.AssertEquals(str.ToString(), "out_own_stringshare"); 276 Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
277 "out_own_stringshare");
278 obj.Dispose();
243 } 279 }
244 System.GC.Collect(); 280 System.GC.Collect();
245 } 281 }
@@ -292,6 +328,7 @@ class TestStringshare
292 String sent = "in_inherited"; 328 String sent = "in_inherited";
293 obj.CallInStringshare(sent); 329 obj.CallInStringshare(sent);
294 Test.AssertEquals(sent, obj.received_in); 330 Test.AssertEquals(sent, obj.received_in);
331 obj.Dispose();
295 } 332 }
296 333
297 public static void in_own_stringshare_from_virtual() 334 public static void in_own_stringshare_from_virtual()
@@ -300,6 +337,7 @@ class TestStringshare
300 String sent = "in_own_inherited"; 337 String sent = "in_own_inherited";
301 obj.CallInOwnStringshare(sent); 338 obj.CallInOwnStringshare(sent);
302 Test.AssertEquals(sent, obj.received_in_own); 339 Test.AssertEquals(sent, obj.received_in_own);
340 obj.Dispose();
303 } 341 }
304 342
305 public static void return_stringshare_from_virtual() 343 public static void return_stringshare_from_virtual()
@@ -307,6 +345,7 @@ class TestStringshare
307 var obj = new StringshareReturner(); 345 var obj = new StringshareReturner();
308 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. 346 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
309 Test.AssertEquals("inherited", obj.CallReturnStringshare()); 347 Test.AssertEquals("inherited", obj.CallReturnStringshare());
348 obj.Dispose();
310 } 349 }
311 350
312 public static void return_own_stringshare_from_virtual() 351 public static void return_own_stringshare_from_virtual()
@@ -314,6 +353,7 @@ class TestStringshare
314 var obj = new StringshareReturner(); 353 var obj = new StringshareReturner();
315 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. 354 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
316 Test.AssertEquals("own_inherited", obj.CallReturnOwnStringshare()); 355 Test.AssertEquals("own_inherited", obj.CallReturnOwnStringshare());
356 obj.Dispose();
317 } 357 }
318 358
319 public static void out_stringshare_from_virtual() 359 public static void out_stringshare_from_virtual()
@@ -321,6 +361,7 @@ class TestStringshare
321 var obj = new StringshareReturner(); 361 var obj = new StringshareReturner();
322 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. 362 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
323 Test.AssertEquals("out_inherited", obj.CallOutStringshare()); 363 Test.AssertEquals("out_inherited", obj.CallOutStringshare());
364 obj.Dispose();
324 } 365 }
325 366
326 public static void out_own_stringshare_from_virtual() 367 public static void out_own_stringshare_from_virtual()
@@ -328,6 +369,7 @@ class TestStringshare
328 var obj = new StringshareReturner(); 369 var obj = new StringshareReturner();
329 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks. 370 // for (int i = 0; i < 1000000; i ++) // Uncomment this to check for memory leaks.
330 Test.AssertEquals("out_own_inherited", obj.CallOutOwnStringshare()); 371 Test.AssertEquals("out_own_inherited", obj.CallOutOwnStringshare());
372 obj.Dispose();
331 } 373 }
332} 374}
333 375