more tests
This commit is contained in:
parent
feb3c3f07c
commit
11f8cffec6
3 changed files with 62 additions and 0 deletions
16
test/last_test.sh
Normal file
16
test/last_test.sh
Normal file
|
@ -0,0 +1,16 @@
|
|||
#! /bin/bash
|
||||
|
||||
testLastFromList() {
|
||||
assertEquals 10 $(list {1..10} | last)
|
||||
assertEquals 7 $(list 5 6 7 | last)
|
||||
}
|
||||
|
||||
testLastFromOneElementList() {
|
||||
assertEquals 1 $(list 1 | last)
|
||||
}
|
||||
|
||||
testLastFromEmptyList() {
|
||||
assertEquals "" "$(list | last)"
|
||||
}
|
||||
|
||||
. ./shunit2-init.sh
|
25
test/list_test.sh
Normal file
25
test/list_test.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#! /bin/bash
|
||||
|
||||
testListFromOneElement() {
|
||||
assertEquals 1 $(list 1)
|
||||
}
|
||||
|
||||
testListFromEmpty() {
|
||||
assertEquals "" "$(list)"
|
||||
}
|
||||
|
||||
testListUnlist() {
|
||||
assertEquals "1 3 6" "$(list 1 3 6 | unlist)"
|
||||
}
|
||||
|
||||
testList() {
|
||||
list=$(cat <<EOF
|
||||
1
|
||||
3
|
||||
6
|
||||
EOF
|
||||
)
|
||||
assertEquals "$list" "$(list 1 3 6)"
|
||||
}
|
||||
|
||||
. ./shunit2-init.sh
|
21
test/unlist_test.sh
Normal file
21
test/unlist_test.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#! /bin/bash
|
||||
|
||||
testUnlistFromList() {
|
||||
list=$(cat <<EOF
|
||||
1
|
||||
2
|
||||
6
|
||||
EOF
|
||||
)
|
||||
assertEquals "1 2 6" "$(echo $list | unlist)"
|
||||
}
|
||||
|
||||
testUnlistFromEmptyList() {
|
||||
assertEquals "" "$(echo | unlist)"
|
||||
}
|
||||
|
||||
testUnlistFromOneElementList() {
|
||||
assertEquals "1" "$(echo 1 | unlist)"
|
||||
}
|
||||
|
||||
. ./shunit2-init.sh
|
Loading…
Reference in a new issue