[vala/0.40] 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.40] tests: Add more "array field initializer" tests to increase coverage
- Date: Sun, 3 Jan 2021 12:46:53 +0000 (UTC)
commit c45919804d77af7fd50fde01aa831f8af458e95a
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 d6b1bfea5..3cdf9d256 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -74,6 +74,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]