diff options
author | Kate Ward <kate.ward@forestent.com> | 2018-01-15 11:31:02 +0100 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2018-01-15 11:31:02 +0100 |
commit | a8e81fdb77b054dc28987af82e53ab9a0c107d20 (patch) | |
tree | 24cc7ecbe70d62358af67399248ebd7da5b26ad3 | |
parent | e563d4c1731683908c05782f07bfac48856f3139 (diff) | |
download | shflags-a8e81fdb77b054dc28987af82e53ab9a0c107d20.tar.gz |
Added unit test for underscoreName(), and fixed potential POSIX compliance issue.
-rw-r--r-- | shflags | 2 | ||||
-rwxr-xr-x | shflags_private_test.sh | 15 |
2 files changed, 14 insertions, 3 deletions
@@ -427,7 +427,7 @@ _flags_define() { # Output: # string: underscored name _flags_underscoreName() { - echo "$1" |tr '-' '_' + echo "$1" |tr z- z_ } # Return valid getopt options using currently defined list of long options. diff --git a/shflags_private_test.sh b/shflags_private_test.sh index 5a2b442..e6b6376 100755 --- a/shflags_private_test.sh +++ b/shflags_private_test.sh @@ -3,8 +3,7 @@ # # shFlags unit tests for the internal functions. # -# -# Copyright 2008-2017 Kate Ward. All Rights Reserved. +# Copyright 2008-2018 Kate Ward. All Rights Reserved. # Released under the Apache 2.0 license. # # Author: kate.ward@forestent.com (Kate Ward) @@ -113,6 +112,18 @@ EOF assertFalse 'empty lists should not match' $? } +testUnderscoreName() { + while read desc name want; do + got=`_flags_underscoreName "${name}"` + assertEquals "${desc}: underscoreName(${name})" "${got}" "${want}" + done <<EOF +with_dashes name-with-dashes name_with_dashes +with_underscores name_with_underscores name_with_underscores +just_alpha_numeric abc123 abc123 +empty "" "" +EOF +} + testValidBool() { # Valid values. for value in ${TH_BOOL_VALID}; do |