From: Rico Tzschichholz Date: Fri, 1 Jan 2021 16:56:16 +0000 (+0100) Subject: tests: Add more "array field initializer" tests to increase coverage X-Git-Tag: 0.40.25~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c45919804d77af7fd50fde01aa831f8af458e95a;p=thirdparty%2Fvala.git tests: Add more "array field initializer" tests to increase coverage --- 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); + } +}