implement string lower and string upper

Fixes #4080
This commit is contained in:
Kurtis Rader
2017-06-10 17:35:25 -07:00
parent 5e94650645
commit f6c9bfc0e8
4 changed files with 164 additions and 32 deletions

View File

@@ -324,4 +324,31 @@ echo '# string match -r "a*b([xy]+)" abc abxc bye aaabyz kaabxz abbxy abcx caabx
string match -r "a*b([xy]+)" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz
or echo exit 1
# Test `string lower` and `string upper`.
set x (string lower abc DEF gHi)
or echo string lower exit 1
test $x[1] = 'abc' -a $x[2] = 'def' -a $x[3] = 'ghi'
or echo strings not converted to lowercase
set x (echo abc DEF gHi | string lower)
or echo string lower exit 1
test $x[1] = 'abc def ghi'
or echo strings not converted to lowercase
string lower -q abc
and echo lowercasing a lowercase string did not fail as expected
set x (string upper abc DEF gHi)
or echo string upper exit 1
test $x[1] = 'ABC' -a $x[2] = 'DEF' -a $x[3] = 'GHI'
or echo strings not converted to uppercase
set x (echo abc DEF gHi | string upper)
or echo string upper exit 1
test $x[1] = 'ABC DEF GHI'
or echo strings not converted to uppercase
string upper -q ABC DEF
and echo uppercasing a uppercase string did not fail as expected
exit 0