[vala/0.50] tests: Extend "GArray" tests to increase coverage



commit a8b914280ee0894a3a9c5fb65f232e1108b0bcc8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 11 20:45:59 2021 +0200

    tests: Extend "GArray" tests to increase coverage

 tests/basic-types/garray.vala | 19 ++++++++++++++-----
 1 file 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;


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