-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
45 lines (30 loc) · 1.22 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
#!/bin/bash
set -e -o pipefail
xsh log info 'xsh list /'
xsh list /
xsh log info "/array/first"
# shellcheck disable=SC2034
[[ $(arr=([3]="III" [4]="IV"); xsh /array/first arr) == III ]]
xsh log info "/file/mask"
[[ $(xsh /file/mask -f2 -c1-4 <<< "username password") == "username ****word" ]]
xsh log info "/date/adjust"
[[ $(xsh /date/adjust +30M +30S "2008-10-10 00:00:00") == "2008-10-10 00:30:30" ]]
xsh log info "/date/convert"
[[ $(TZ=UTC xsh /date/convert "2008-10-10 00:30:30" "+%a %b %d %T %Z %Y") == "Fri Oct 10 00:30:30 UTC 2008" ]]
xsh log info "/math/dec2hex"
[[ $(xsh /math/dec2hex 255) == FF ]]
xsh log info "/math/infix2rpn"
[[ $(xsh /math/infix2rpn "2*3+(4-5)") == "2 3 * 4 5 - + " ]]
xsh log info "/int/op-comparator"
[[ $(xsh /int/op-comparator "*" +) == 1 ]]
xsh log info "/int/set/rpncalc"
[[ $(xsh /int/set/rpncalc "1 2 3" "3 4 5" \&) == 3 ]]
xsh log info "/json/parser"
[[ $(xsh /json/parser get '{"foo": ["bar", "baz"]}' "foo.[0].upper()") == BAR ]]
xsh log info "/json/parser"
[[ $(xsh /string/repeat Foo 3) == FooFooFoo ]]
xsh log info "/uri/parser"
[[ $(xsh /uri/parser -s https://github.com) == https ]]
# TODO: Use the utilities's document (the section `Example`) to generate the
# test cases.
exit