v2 / vlib / v / tests / builtin_arrays / array_init_fixed_test.v
26 lines · 22 sloc · 388 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1module main
2
3pub const n = 7
4pub const nsq = n * n
5
6pub fn empty_board(with_init bool) [nsq]u8 {
7 if with_init {
8 a := [nsq]u8{init: 0}
9 dump(a)
10 return [nsq]u8{init: 0}
11 } else {
12 a := [nsq]u8{}
13 dump(a)
14 return [nsq]u8{}
15 }
16}
17
18fn test_with_init() {
19 a := dump(empty_board(true))
20 assert a.len == 49
21}
22
23fn test_without_init() {
24 a := dump(empty_board(false))
25 assert a.len == 49
26}
27