diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-11 20:45:59 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-11 20:45:59 +0200 |
commit | 1cb798d305f177a5f9492e74a2cc875ceaa8ad7b (patch) | |
tree | e2f355df6d1d265047d43d03c432ab4423ceaf92 | |
parent | 5ac884082e956eef62e6a1013059f9aa65ce94ba (diff) | |
download | vala-1cb798d305f177a5f9492e74a2cc875ceaa8ad7b.tar.gz |
tests: Extend "GArray" tests to increase coverage
-rw-r--r-- | tests/basic-types/garray.vala | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/basic-types/garray.vala b/tests/basic-types/garray.vala index 2d2eb008d..9f09560a7 100644 --- a/tests/basic-types/garray.vala +++ b/tests/basic-types/garray.vala @@ -14,17 +14,22 @@ void test_garray () { array.append_val (foo); assert (foo.ref_count == 2); + assert (array.index (0) == foo); array.remove_index (0); assert (foo.ref_count == 1); array.append_val (foo); assert (foo.ref_count == 2); + assert (array.index (0) == foo); array.remove_index_fast (0); assert (foo.ref_count == 1); array.append_val (foo); - assert (foo.ref_count == 2); - array.remove_range (0, 1); + array.append_val (foo); + assert (foo.ref_count == 3); + assert (array.index (0) == foo); + assert (array.index (1) == foo); + array.remove_range (0, 2); assert (foo.ref_count == 1); } @@ -45,17 +50,21 @@ void test_int_garray () { } GLib.Array<FooStruct?> create_struct_garray () { - FooStruct foo = { "foo", new Foo () }; var array = new GLib.Array<FooStruct?> (); - array.append_val (foo); + FooStruct foo1 = { "foo", new Foo () }; + array.append_val (foo1); + FooStruct foo2 = { "bar", new Foo () }; + array.append_val (foo2); return array; } void test_struct_garray () { var array = create_struct_garray (); - assert (array.length == 1); + assert (array.length == 2); assert (array.index (0).content == "foo"); assert (array.index (0).object.ref_count == 1); + assert (array.index (1).content == "bar"); + assert (array.index (1).object.ref_count == 1); Foo f = array.index (0).object; assert (f.ref_count == 2); array = null; |