annotate scripts/test/basename.test @ 456:dd24f86d5ad5

Minor code cleanup and typo fix.
author Rob Landley <rob@landley.net>
date Mon, 13 Feb 2012 21:13:05 -0600
parents 6c62d5b6675a
children 786841fdb1e0
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
456
dd24f86d5ad5 Minor code cleanup and typo fix.
Rob Landley <rob@landley.net>
parents: 455
diff changeset
19 testing "basename reappearing suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" ""
dd24f86d5ad5 Minor code cleanup and typo fix.
Rob Landley <rob@landley.net>
parents: 455
diff changeset
20 testing "basename reappearing suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" ""
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
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.
456
dd24f86d5ad5 Minor code cleanup and typo fix.
Rob Landley <rob@landley.net>
parents: 455
diff changeset
23 testing "basename invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" ""