~sircmpwn/ctools

ref: cc69324393fda9bcbc73d30d1bda022263f012a8 ctools/test/dirname -rw-r--r-- 974 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
tool="dirname"
. "$HARNESS"

should_handle_null_string() (
	dn="$(dirname '')"
	[ "$dn" = "." ]
)

should_handle_single_slash() (
	dn="$(dirname '/')"
	[ "$dn" = "/" ]
)

should_handle_double_slash() (
	dn="$(dirname '//')"
	[ "$dn" = "/" ] || [ "$dn" = "//" ]
)

should_handle_trailing_slash() (
	dn="$(dirname 'foo/')"
	[ "$dn" = "." ]
)

should_handle_no_slash() (
	dn="$(dirname 'foo')"
	[ "$dn" = "." ]
)

should_handle_double_slashes() (
	dn="$(dirname '//foo//bar//')"
	[ "$dn" = "//foo" ]
)

should_handle_leading_slash() (
	dn="$(dirname '/foo')"
	[ "$dn" = "/" ]
)

should_handle_dirname() (
	dn="$(dirname 'foo/bar/baz')"
	[ "$dn" = "foo/bar" ]
)

should_handle_ddash dirname foo/bar/

runtests \
	should_handle_ddash \
	should_handle_null_string \
	should_handle_single_slash \
	should_handle_double_slash \
	should_handle_trailing_slash \
	should_handle_no_slash \
	should_handle_double_slashes \
	should_handle_leading_slash \
	should_handle_dirname