mirror of
https://github.com/lloeki/apply.git
synced 2025-12-06 17:24:39 +01:00
lib: more helper functions
This commit is contained in:
parent
dafb44313c
commit
a519746560
2 changed files with 68 additions and 0 deletions
|
|
@ -67,5 +67,33 @@ testSubstituteInPlace() {
|
|||
assertEquals "hi hi hi" "$(cat "$TEST_TMPDIR/sub.txt")"
|
||||
}
|
||||
|
||||
testQuote() {
|
||||
local input expected
|
||||
|
||||
{ input="$(cat)"; } <<EOF
|
||||
foo'bar"baz'
|
||||
EOF
|
||||
|
||||
{ expected="$(cat)"; } <<EOF
|
||||
'foo'\\''bar"baz'\\'''
|
||||
EOF
|
||||
|
||||
assertEquals "$expected" "$(quote "$input")"
|
||||
}
|
||||
|
||||
testFnmatch() {
|
||||
assertTrue 'fnmatch "f??*" "foobar"'
|
||||
assertFalse 'fnmatch "f??*" "fo"'
|
||||
assertFalse 'fnmatch "f??*" "loob"'
|
||||
}
|
||||
|
||||
testEpochseconds() {
|
||||
# TODO(andrew-d): better test
|
||||
|
||||
# Assert that it's numeric by deleting all numbers and verifying that
|
||||
# there's nothing left.
|
||||
assertEquals "" "$(epochseconds | tr -d '[0-9]')"
|
||||
}
|
||||
|
||||
# Load shUnit2
|
||||
. ./shunit2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue