aboutsummaryrefslogtreecommitdiff
path: root/tests/basename.test
blob: 9d3b29613f79c9a8b70d67676d0016246456c4f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

# Removal of extra /'s
testing "/-only" "basename ///////" "/\n" "" ""
testing "trailing /" "basename a//////" "a\n" "" ""
testing "combined" "basename /////a///b///c///d/////" "d\n" "" ""

# Standard suffix behavior.
testing "suffix" "basename a/b/c/d.suffix .suffix" "d\n" "" ""

# A suffix cannot be the entire result.
testing "suffix=result" "basename .txt .txt" ".txt\n" "" ""

# Deal with suffix appearing in the filename
testing "reappearing suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" ""
testing "reappearing suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" ""

# A suffix should be a real suffix, only a the end.
testing "invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" ""