~sircmpwn/ctools

ref: cc69324393fda9bcbc73d30d1bda022263f012a8 ctools/test/basename -rwxr-xr-x 672 bytes
cc693243 — Gabor Koszegi Correct tee SIGINT test 1 year, 11 months ago
                                                                                
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
#!/bin/sh
tool="basename"
. "$HARNESS"

should_handle_null_string() (
	bn="$(basename '')"
	[ "$bn" = "." ] || [ "$bn" = "" ]
)

should_handle_slashes() (
	bn="$(basename '////')"
	[ "$bn" = "/" ]
)

should_handle_trailing_slashes() (
	bn="$(basename 'bar/')"
	[ "$bn" = "bar" ]
)

should_handle_basename() (
	bn="$(basename '/foo/bar/baz')"
	[ "$bn" = "baz" ]
)

should_handle_suffix() (
	bn="$(basename '/foo/bar/baz.txt' '.txt')"
	[ "$bn" = "baz" ]
)

should_handle_ddash basename foo/bar.txt .txt

runtests \
	should_handle_ddash \
	should_handle_null_string \
	should_handle_slashes \
	should_handle_trailing_slashes \
	should_handle_basename \
	should_handle_suffix