v2 / vlib / os / cmdline / cmdline_test.v
37 lines · 31 sloc · 814 bytes · 506c30a291fa7f7a05d2b2770dacf5c6e81677f7
Raw
1import os.cmdline
2
3fn test_options() {
4 args := ['v', '-d', 'aa', '-d', 'bb', '-d', 'cc']
5 ret := cmdline.options(args, '-d')
6 assert ret == ['aa', 'bb', 'cc']
7}
8
9fn test_option() {
10 args := ['v', '-d', 'aa']
11 ret := cmdline.option(args, '-d', '')
12 assert ret == 'aa'
13}
14
15fn test_options_before() {
16 args := ['-stat', 'test', 'aaa.v']
17 ret := cmdline.options_before(args, ['test'])
18 assert ret == ['-stat']
19}
20
21fn test_options_after() {
22 args := ['-stat', 'test', 'aaa.v']
23 ret := cmdline.options_after(args, ['test'])
24 assert ret == ['aaa.v']
25}
26
27fn test_only_non_options() {
28 args := ['-d', 'aa', '--help', 'bb']
29 ret := cmdline.only_non_options(args)
30 assert ret == ['aa', 'bb']
31}
32
33fn test_only_options() {
34 args := ['-d', 'aa', '--help', 'bb']
35 ret := cmdline.only_options(args)
36 assert ret == ['-d', '--help']
37}
38