forked from cofyc/argparse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·63 lines (42 loc) · 1.66 KB
/
test.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
. tap-functions
plan_no_plan
is "$(./test_argparse -f --path=/path/to/file a 2>&1)" 'force: 1
path: /path/to/file
argc: 1
argv[0]: a'
is "$(./test_argparse -f -f --force --no-force 2>&1)" 'force: 2'
is "$(./test_argparse -i 2>&1)" 'error: option `-i` requires a value'
is "$(./test_argparse -i 2 2>&1)" 'int_num: 2'
is "$(./test_argparse -i2 2>&1)" 'int_num: 2'
is "$(./test_argparse -ia 2>&1)" 'error: option `-i` expects an integer value'
is "$(./test_argparse -i 0xFFFFFFFFFFFFFFFFF 2>&1)" \
'error: option `-i` Numerical result out of range'
is "$(./test_argparse -s 2.4 2>&1)" 'flt_num: 2.4'
is "$(./test_argparse -s2.4 2>&1)" 'flt_num: 2.4'
is "$(./test_argparse -sa 2>&1)" 'error: option `-s` expects a numerical value'
is "$(./test_argparse -s 1e999 2>&1)" \
'error: option `-s` Numerical result out of range'
is "$(./test_argparse -f -- do -f -h 2>&1)" 'force: 1
argc: 3
argv[0]: do
argv[1]: -f
argv[2]: -h'
is "$(./test_argparse -tf 2>&1)" 'force: 1
test: 1'
is "$(./test_argparse --read --write 2>&1)" 'perms: 3'
is "$(./test_argparse -h)" 'Usage: test_argparse [options] [[--] args]
or: test_argparse [options]
A brief description of what the program does and how it works.
-h, --help show this help message and exit
Basic options
-f, --force force to do
-t, --test test only
-p, --path=<str> path to read
-i, --int=<int> selected integer
-s, --float=<flt> selected float
Bits options
--read read perm
--write write perm
--exec exec perm
Additional description of the program after the description of the arguments.'