~sircmpwn/ctools

ref: 0e9f63c42367ef836a3dbe9369cb987558b0d9e3 ctools/test/basename -rwxr-xr-x 665 bytes
0e9f63c4 — Christopher Vittal Add dirname 1 year, 7 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
#!/bin/sh
. "$HARNESS" basename

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