]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "constant and union" gir test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 10 Aug 2020 09:56:47 +0000 (11:56 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 10 Aug 2020 12:03:59 +0000 (14:03 +0200)
tests/Makefile.am
tests/gir/constant.test [new file with mode: 0644]
tests/gir/union.test [new file with mode: 0644]

index 6f2ec7b9b1698844a8da54258a4fea2daaf73561..1f9a5ea30146b2c18e3d9dc523fec21227719462 100644 (file)
@@ -559,6 +559,7 @@ TESTS = \
        gir/async-result-pos.test \
        gir/async-sync-out.test \
        gir/class.test \
+       gir/constant.test \
        gir/delegate-alias-without-target.test \
        gir/delegate-array-length-type.test \
        gir/delegate-closure-destroy-index-conflict.test \
@@ -569,6 +570,7 @@ TESTS = \
        gir/parameter-nullable-out-simple-type.test \
        gir/property-non-readable.test \
        gir/symbol-type-csuffix.test \
+       gir/union.test \
        annotations/deprecated.vala \
        annotations/description.vala \
        annotations/noaccessormethod.test \
diff --git a/tests/gir/constant.test b/tests/gir/constant.test
new file mode 100644 (file)
index 0000000..196ae75
--- /dev/null
@@ -0,0 +1,22 @@
+GIR
+
+Input:
+
+<constant name="FOO_CONSTANT"
+          value="foo-constant-string-value"
+          c:type="TEST_FOO_CONSTANT">
+  <type name="utf8" c:type="gchar*"/>
+</constant>
+<constant name="FOO_CONSTANT_ARRAY"
+          c:type="TEST_FOO_CONSTANT_ARRAY">
+  <array c:type="const gchar**">
+    <type name="utf8" c:type="const gchar*"/>
+  </array>
+</constant>
+
+Output:
+
+[CCode (cheader_filename = "test.h", cname = "TEST_FOO_CONSTANT")]
+public const string FOO_CONSTANT;
+[CCode (array_length = false, array_null_terminated = true, cheader_filename = "test.h", cname = "TEST_FOO_CONSTANT_ARRAY")]
+public const string[] FOO_CONSTANT_ARRAY;
diff --git a/tests/gir/union.test b/tests/gir/union.test
new file mode 100644 (file)
index 0000000..51f118a
--- /dev/null
@@ -0,0 +1,20 @@
+GIR
+
+Input:
+
+<union name="Foo" c:type="TestFoo">
+  <field name="bar" writable="1">
+    <type name="guint" c:type="guint"/>
+  </field>
+  <field name="manam" writable="1">
+    <type name="gint" c:type="gint"/>
+  </field>
+</union>
+
+Output:
+
+[CCode (cheader_filename = "test.h")]
+public struct Foo {
+       public uint bar;
+       public int manam;
+}