[vala/0.40] tests: Extend "foreach" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] tests: Extend "foreach" tests to increase coverage
- Date: Mon, 5 Aug 2019 11:37:40 +0000 (UTC)
commit fb58523e1c0cdd0d8c4eb5f161a8139e79cef1d8
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]