summaryrefslogtreecommitdiff
path: root/tests/arrays/struct-field-initializer.vala
blob: 9534c8490ed99b5ba3962ca56ba05d9e079da15e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[CCode (has_type_id = false)]
struct Foo {
	public unowned string[] array;
	public int i;
}

[CCode (has_type_id = false)]
public struct Bar {
	public unowned string[] array;
	public int i;
}

const string[] SARRAY = { "foo", "bar" };

const Foo FOO = { SARRAY, 23 };
const Bar BAR = { SARRAY, 42 };

void main () {
	{
		assert (FOO.array.length == 2);
		assert (FOO.i == 23);
		assert (BAR.array.length == 2);
		assert (BAR.i == 42);
	}
	{
		const Foo foo = { SARRAY, 23 };
		const Bar bar = { SARRAY, 42 };
		assert (foo.array.length == 2);
		assert (foo.i == 23);
		assert (bar.array.length == 2);
		assert (bar.i == 42);
	}
}