blob: 89279a24e0b94ea5fa6eb58065387e6f6a012360 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/sh
#
# $OpenBSD: basename.sh,v 1.2 2005/04/12 06:45:03 otto Exp $
# $NetBSD: basename.sh,v 1.1 2005/04/04 16:48:45 peter Exp $
test_basename()
{
echo "Testing \"$1\""
result=`basename "$1" 2>&1`
if [ "$result" != "$2" ]; then
echo "Expected \"$2\", but got \"$result\""
exit 1
fi
}
test_basename_suffix()
{
echo "Testing suffix \"$1\" \"$2\""
result=`basename "$1" "$2" 2>&1`
if [ "$result" != "$3" ]; then
echo "Expected \"$3\", but got \"$result\""
exit 1
fi
}
# Tests without suffix
test_basename "" ""
test_basename "/usr/bin" "bin"
test_basename "/usr" "usr"
test_basename "/" "/"
test_basename "///" "/"
test_basename "/usr//" "usr"
test_basename "//usr//bin" "bin"
test_basename "usr" "usr"
test_basename "usr/bin" "bin"
# Tests with suffix
test_basename_suffix "/usr/bin" "n" "bi"
test_basename_suffix "/usr/bin" "bin" "bin"
test_basename_suffix "/" "/" "/"
test_basename_suffix "/usr/bin/gcc" "cc" "g"
test_basename_suffix "/usr/bin/gcc" "xx" "gcc"
|