v2 / vlib / v / tests / consts / const_fixed_array_test.v
33 lines · 28 sloc · 429 bytes · b2ff9d5d0858856d7003f1e88ffe995b080c4146
Raw
1module main
2
3const c_u16_size = sizeof(u16)
4const c_u32_size = sizeof(u32)
5
6pub enum DataKind as u8 {
7 u8_array
8}
9
10union U16Bytes {
11 value u16
12 bytes [c_u16_size]u8
13}
14
15union U32Bytes {
16 value u32
17 bytes [c_u32_size]u8
18}
19
20fn test_main() {
21 kind := DataKind.u8_array
22 match kind {
23 .u8_array {
24 buf_4u8 := [c_u32_size]u8{}
25 w := U32Bytes{
26 bytes: buf_4u8
27 }
28 unsafe {
29 assert w.bytes.len == c_u32_size
30 }
31 }
32 }
33}
34