annotate scripts/test/basename.test @ 455:6c62d5b6675a

Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
author Elie De Brauwer <eliedebrauwer@gmail.com>
date Sun, 12 Feb 2012 14:14:58 +0100
parents
children dd24f86d5ad5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
455
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
1 #!/bin/bash
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
2
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
4
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
6
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
7 # Removal of extra /'s
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
8 testing "basename /-only" "basename ///////" "/\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
9 testing "basename trailing /" "basename a//////" "a\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
10 testing "basename combined" "basename /////a///b///c///d/////" "d\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
11
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
12 # Standard suffix behavior.
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
13 testing "basename suffix" "basename a/b/c/d.suffix .suffix" "d\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
14
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
15 # A suffix cannot be the entire result.
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
16 testing "basename suffix=result" "basename .txt .txt" ".txt\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
17
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
18 # Deal with suffix appearing in the filename
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
19 testing "basename reappering suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
20 testing "basename reappering suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" ""
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
21
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
22 # A suffix should be a real suffix, only a the end.
6c62d5b6675a Add test for basename, fix issue where suffix is wrongfully applied if it appears in the middle of the filename
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
23 testing "basename invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" ""