v / vlib / flag / flag_to_bool_test.v
21 lines · 17 sloc · 480 bytes · 0d35f0948c2a9530edc172e4676a15e73420d165
Raw
1import flag
2
3const gnu_args_bool_flags = ['--no-parallel', '--nocache', '--stay', '--nix']
4
5struct BoolConfig {
6 mix bool
7 nix bool
8 parallel bool = true @[long: 'no-parallel']
9 cache bool @[long: nocache]
10 no_stay bool @[long: 'stay']
11}
12
13fn test_bool_flags() {
14 bf, _ := flag.to_struct[BoolConfig](gnu_args_bool_flags, style: .long)!
15
16 assert bf.mix == false
17 assert bf.nix == true
18 assert bf.parallel == false
19 assert bf.cache == true
20 assert bf.no_stay == true
21}
22