~sircmpwn/ctools

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

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