diff options
author | Corentin Noël <corentin@elementary.io> | 2020-11-09 15:17:37 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-11-10 18:14:55 +0100 |
commit | 3a695246fed3eed1966d37fbeffbc1c48cd6c773 (patch) | |
tree | f01cb5260539472fe868f3dc617066d42fdcc4bf /tests/control-flow/foreach.vala | |
parent | 21028c0f59b72e4538c33a7b9618e71474a665db (diff) | |
download | vala-wip/foreach.tar.gz |
tests: Add "GenericArray foreach" tests to increase coveragewip/foreach
Diffstat (limited to 'tests/control-flow/foreach.vala')
-rw-r--r-- | tests/control-flow/foreach.vala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/control-flow/foreach.vala b/tests/control-flow/foreach.vala index 6a36453fd..052e03d3c 100644 --- a/tests/control-flow/foreach.vala +++ b/tests/control-flow/foreach.vala @@ -33,6 +33,41 @@ void test_foreach_gvaluearray () { test_unowned (array); } +void test_generic_array_owned (GenericArray<Value?> array) { + uint i = 0; + + foreach (Value? item in array) { + i++; + } + + assert (i == 3); +} + +void test_generic_array_unowned (GenericArray<Value?> array) { + uint i = 0; + + foreach (unowned Value? item in array) { + i++; + } + + assert (i == 3); +} + +void test_foreach_genericarray () { + Value value; + var array = new GenericArray<Value?> (); + + value = 1; + array.add (value); + value = 2.0; + array.add (value); + value = "three"; + array.add (value); + + test_generic_array_owned (array); + test_generic_array_unowned (array); +} + void test_foreach_multidim_array () { int[,] foo = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; string result = ""; @@ -70,6 +105,7 @@ void test_foreach_slice_array () { void main () { test_foreach_gvaluearray (); + test_foreach_genericarray (); test_foreach_const_array (); test_foreach_multidim_array (); test_foreach_slice_array (); |