OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD
[android-x86/external-toybox.git] / tests / basename.test
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 #testing "name" "command" "result" "infile" "stdin"
6
7 # Removal of extra /'s
8 testing "/-only" "basename ///////" "/\n" "" ""
9 testing "trailing /" "basename a//////" "a\n" "" ""
10 testing "combined" "basename /////a///b///c///d/////" "d\n" "" ""
11
12 # Standard suffix behavior.
13 testing "suffix" "basename a/b/c/d.suffix .suffix" "d\n" "" ""
14
15 # A suffix cannot be the entire result.
16 testing "suffix=result" "basename .txt .txt" ".txt\n" "" ""
17
18 # Deal with suffix appearing in the filename
19 testing "reappearing suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" ""
20 testing "reappearing suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" ""
21
22 # A suffix should be a real suffix, only a the end.
23 testing "invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" ""
24
25 # Zero-length suffix
26 testing "zero-length suffix" "basename a/b/c ''" "c\n" "" ""