MCPcopy Index your code
hub / github.com/bitfield/script / TestBasenameRemovesLeadingPathComponentsFromInputLines

Function TestBasenameRemovesLeadingPathComponentsFromInputLines

script_test.go:47–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestBasenameRemovesLeadingPathComponentsFromInputLines(t *testing.T) {
48 t.Parallel()
49 tcs := []struct {
50 path string
51 want string
52 }{
53 {"\n", ".\n"},
54 {"/", "/\n"},
55 {"/root", "root\n"},
56 {"/tmp/example.php", "example.php\n"},
57 {"./src/filters", "filters\n"},
58 {"/var/tmp/example.php", "example.php\n"},
59 {"/tmp/script-21345.txt\n/tmp/script-5371253.txt", "script-21345.txt\nscript-5371253.txt\n"},
60 {"C:/Program Files", "Program Files\n"},
61 {"C:/Program Files/", "Program Files\n"},
62 }
63 for _, tc := range tcs {
64 // Expect results to use this platform's path separator
65 want := filepath.Clean(tc.want)
66 got, err := script.Echo(tc.path).Basename().String()
67 if err != nil {
68 t.Fatal(err)
69 }
70 if want != got {
71 t.Errorf("%q: want %q, got %q", tc.path, want, got)
72 }
73 }
74}
75
76func TestColumnSelects(t *testing.T) {
77 t.Parallel()

Callers

nothing calls this directly

Calls 3

EchoFunction · 0.92
StringMethod · 0.80
BasenameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…