From: Rico Tzschichholz Date: Sat, 13 Apr 2019 15:46:23 +0000 (+0200) Subject: tests: Extend "foreach" tests to increase coverage X-Git-Tag: 0.36.20~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=638cf3cd64e38d03bebbf30e1a2c1a189f314424;p=thirdparty%2Fvala.git tests: Extend "foreach" tests to increase coverage --- 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 (); }