basename.test 992 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. [ -f testing.sh ] && . testing.sh
  3. #testing "name" "command" "result" "infile" "stdin"
  4. # Removal of extra /'s
  5. testcmd "/-only" "///////" "/\n" "" ""
  6. testcmd "trailing /" "a//////" "a\n" "" ""
  7. testcmd "combined" "/////a///b///c///d/////" "d\n" "" ""
  8. # Standard suffix behavior.
  9. testcmd "suffix" "a/b/c/d.suffix .suffix" "d\n" "" ""
  10. # A suffix cannot be the entire result.
  11. testcmd "suffix=result" ".txt .txt" ".txt\n" "" ""
  12. # Deal with suffix appearing in the filename
  13. testcmd "reappearing suffix 1" "a.txt.txt .txt" "a.txt\n" "" ""
  14. testcmd "reappearing suffix 2" "a.txt.old .txt" "a.txt.old\n" "" ""
  15. # A suffix should be a real suffix, only a the end.
  16. testcmd "invalid suffix" "isthisasuffix? suffix" "isthisasuffix?\n" "" ""
  17. # Zero-length suffix
  18. testcmd "zero-length suffix" "a/b/c ''" "c\n" "" ""
  19. # -s.
  20. testcmd "-s" "-s .txt /a/b/c.txt" "c\n" "" ""
  21. testcmd "-s implies -a" "-s .txt /a/b/c.txt /a/b/d.txt" "c\nd\n" "" ""
  22. testcmd "-a" "-a /a/b/f1 /c/d/f2" "f1\nf2\n" "" ""