[vala/0.44] tests: Extend "foreach" tests to increase coverage



commit c3c7857e4e8fb3150cc32232206f7dc253f70198
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Apr 13 17:46:23 2019 +0200

    tests: Extend "foreach" tests to increase coverage

 tests/control-flow/foreach.vala | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
---
diff --git a/tests/control-flow/foreach.vala b/tests/control-flow/foreach.vala
index 396c9f19c..0646c2d9a 100644
--- a/tests/control-flow/foreach.vala
+++ b/tests/control-flow/foreach.vala
@@ -33,6 +33,37 @@ void test_foreach_gvaluearray () {
        test_unowned (array);
 }
 
+void test_foreach_multidim_array () {
+       int[,] foo = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
+       string result = "";
+       foreach (var i in foo) {
+               result += i.to_string ();
+       }
+       assert (result == "123456");
+}
+
+const int[] FOO = { 1, 2, 3, 4, 5, 6 };
+
+void test_foreach_const_array () {
+       string result = "";
+       foreach (var i in FOO) {
+               result += i.to_string ();
+       }
+       assert (result == "123456");
+}
+
+void test_foreach_slice_array () {
+       int[] foo = { 1, 2, 3, 4, 5, 6 };
+       string result = "";
+       foreach (var i in foo[1:foo.length - 1]) {
+               result += i.to_string ();
+       }
+       assert (result == "2345");
+}
+
 void main () {
        test_foreach_gvaluearray ();
+       test_foreach_const_array ();
+       test_foreach_multidim_array ();
+       test_foreach_slice_array ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]