D-Bus: Fix signals with string array parameters in dynamic clients
[vala-lang.git] / tests / basic-types / arrays.vala
blobea88c17052a1c329da953e5a937831a5b0f8f345
1 void test_integer_array () {
2 // declaration and initialization
3 int[] a = { 42 };
4 assert (a.length == 1);
5 assert (a[0] == 42);
7 // assignment
8 a = { 42, 23 };
9 assert (a.length == 2);
10 assert (a[0] == 42);
11 assert (a[1] == 23);
13 // access
14 int[] b = a;
15 assert (b.length == 2);
16 assert (b[0] == 42);
17 assert (b[1] == 23);
19 // +
20 a += 11;
21 assert (a.length == 3);
22 assert (a[0] == 42);
23 assert (a[1] == 23);
24 assert (a[2] == 11);
25 assert (b.length == 2);
26 assert (b[0] == 42);
27 assert (b[1] == 23);
30 void test_string_array () {
31 // declaration and initialization
32 string[] a = { "hello" };
33 assert (a.length == 1);
34 assert (a[0] == "hello");
36 // assignment
37 a = { "hello", "world" };
38 assert (a.length == 2);
39 assert (a[0] == "hello");
40 assert (a[1] == "world");
42 // access
43 string[] b = a;
44 assert (b.length == 2);
45 assert (b[0] == "hello");
46 assert (b[1] == "world");
49 int[] pass_helper (int[] a, out int[] b) {
50 b = a;
51 return { 42, 23 };
54 void test_array_pass () {
55 int[] a, b;
56 a = pass_helper ({ 42 }, out b);
57 assert (a.length == 2);
58 assert (a[0] == 42);
59 assert (a[1] == 23);
60 assert (b.length == 1);
61 assert (b[0] == 42);
64 void main () {
65 test_integer_array ();
66 test_string_array ();
67 test_array_pass ();