[vala/0.48] tests: Add more "array field initializer" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] tests: Add more "array field initializer" tests to increase coverage
- Date: Sun, 3 Jan 2021 11:31:49 +0000 (UTC)
commit 1ba1761f3a32e6686e362d066a2ef8ad1e4930fa
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Jan 1 17:56:16 2021 +0100
tests: Add more "array field initializer" tests to increase coverage
tests/Makefile.am | 1 +
tests/arrays/class-field-initializer.vala | 36 +++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef807fb7c..db2636452 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -98,6 +98,7 @@ TESTS = \
constants/strings.vala \
namespace/unique.vala \
arrays/cast-silent-invalid.test \
+ arrays/class-field-initializer.vala \
arrays/class-field-length-cname.vala \
arrays/constant-element-access.vala \
arrays/empty-length-0.vala \
diff --git a/tests/arrays/class-field-initializer.vala b/tests/arrays/class-field-initializer.vala
new file mode 100644
index 000000000..30595f4ce
--- /dev/null
+++ b/tests/arrays/class-field-initializer.vala
@@ -0,0 +1,36 @@
+[CCode (array_length = false, array_null_terminated = true)]
+string[] manam;
+
+class Foo {
+ public string[] f = manam;
+ public string[] i = { "baz", "foo", "bar" };
+ public static string[] sf = manam;
+ public static string[] si = { "baz", "foo", "bar" };
+}
+
+[CCode (array_length = false)]
+string[] minim;
+
+class Bar {
+ public string[] f = minim;
+ public static string[] sf = minim;
+}
+
+void main () {
+ {
+ manam = { "manam", "foo", "bar" };
+ assert (manam.length == 3);
+ var foo = new Foo ();
+ assert (foo.f.length == 3);
+ assert (Foo.sf.length == 3);
+ assert (foo.i.length == 3);
+ assert (Foo.si.length == 3);
+ }
+ {
+ minim = { "minim", "foo", "bar" };
+ assert (minim.length == -1);
+ var bar = new Bar ();
+ assert (bar.f.length == -1);
+ assert (Bar.sf.length == -1);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]