[gjs: 1/2] tests: Test for empty flat arrays of structs



commit b370199ea9587930f3149c2ba3afae810d148f4f
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon Nov 25 09:53:20 2019 -0800

    tests: Test for empty flat arrays of structs
    
    We should be able to pass null or [] to a parameter expecting a flat
    array of structs. This case was inadvertently broken on the stable
    branch when we prevented the crash as part of #44. Even though on the
    development branch we now support these kinds of arrays, we should still
    test passing empty ones.
    
    Closes: #289

 installed-tests/js/testIntrospection.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/installed-tests/js/testIntrospection.js b/installed-tests/js/testIntrospection.js
index 814beb27..f81751b0 100644
--- a/installed-tests/js/testIntrospection.js
+++ b/installed-tests/js/testIntrospection.js
@@ -28,6 +28,25 @@ describe('Unsafe integer marshalling', function () {
     });
 });
 
+describe('Marshalling empty flat arrays of structs', function () {
+    let widget;
+    beforeAll(function () {
+        Gtk.init(null);
+    });
+
+    beforeEach(function () {
+        widget = new Gtk.Label();
+    });
+
+    it('accepts null', function () {
+        widget.drag_dest_set(0, null, Gdk.DragAction.COPY);
+    });
+
+    it('accepts an empty array', function () {
+        widget.drag_dest_set(0, [], Gdk.DragAction.COPY);
+    });
+});
+
 describe('Constructor', function () {
     it('throws when constructor called without new', function () {
         expect(() => Gio.AppLaunchContext())


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