]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add gir-test for fixed-size arrays
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 27 Nov 2016 11:06:25 +0000 (12:06 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 27 Nov 2016 11:06:25 +0000 (12:06 +0100)
tests/Makefile.am
tests/gir/array-fixed-length.test [new file with mode: 0644]

index 1e6fd84c3b5a4961d318e62265009bd2706d189e..c94096d540472cd28a9e931ff40667fb136f83d8 100644 (file)
@@ -244,6 +244,7 @@ TESTS = \
        gir/bug651773.test \
        gir/bug667751.test \
        gir/bug742012.test \
+       gir/array-fixed-length.test \
        annotations/deprecated.vala \
        annotations/description.vala \
        $(NULL)
diff --git a/tests/gir/array-fixed-length.test b/tests/gir/array-fixed-length.test
new file mode 100644 (file)
index 0000000..0d7e70e
--- /dev/null
@@ -0,0 +1,68 @@
+GIR
+
+Input:
+
+      <function name="get_array_return" c:identifier="test_get_array_return">
+        <return-value transfer-ownership="none">
+          <array zero-terminated="0" c:type="gpointer*" fixed-size="16">
+            <type name="guint8"/>
+          </array>
+        </return-value>
+      </function>
+
+      <function name="change_array" c:identifier="test_change_array">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="array"
+                     direction="inout"
+                     caller-allocates="1"
+                     transfer-ownership="full">
+            <array zero-terminated="0" c:type="gpointer*" fixed-size="2">
+              <type name="guint8"/>
+            </array>
+          </parameter>
+        </parameters>
+      </function>
+
+      <function name="get_array_out" c:identifier="test_get_array_out">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="array"
+                     direction="out"
+                     caller-allocates="1"
+                     transfer-ownership="full">
+            <array zero-terminated="0" c:type="gpointer*" fixed-size="8">
+              <type name="guint8"/>
+            </array>
+          </parameter>
+        </parameters>
+      </function>
+
+      <function name="set_array" c:identifier="test_set_array">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="array"
+                     transfer-ownership="none">
+            <array zero-terminated="0" c:type="gpointer*" fixed-size="4">
+              <type name="guint8"/>
+            </array>
+          </parameter>
+        </parameters>
+      </function>
+
+Output:
+
+[CCode (cheader_filename = "test.h")]
+public static void change_array ([CCode (array_length = false)] ref uint8 array[2]);
+[CCode (cheader_filename = "test.h")]
+public static void get_array_out ([CCode (array_length = false)] out uint8 array[8]);
+[CCode (array_length = false, cheader_filename = "test.h")]
+public static unowned uint8[] get_array_return ();
+[CCode (cheader_filename = "test.h")]
+public static void set_array ([CCode (array_length = false)] uint8 array[4]);