]> 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 11:49:04 +0000 (13:49 +0200)
tests/Makefile.am
tests/gir/constant.test [new file with mode: 0644]
tests/gir/union.test [new file with mode: 0644]

index e1bfc0625b2a0f045fbfd00e013dd4d8361093b0..c2505dcbace54aef3b9a9b009e4e662639997457 100644 (file)
@@ -647,6 +647,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 \
@@ -659,6 +660,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;
+}