MCPcopy Create free account
hub / github.com/bufbuild/buf / TestRel

Function TestRel

private/pkg/normalpath/normalpath_windows_test.go:180–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestRel(t *testing.T) {
181 t.Parallel()
182 testRel(t, ".", "", "")
183 testRel(t, ".", "", ".")
184 testRel(t, ".", ".", "")
185 testRel(t, ".", ".", ".")
186 testRel(t, ".", "foo", "foo")
187 testRel(t, "foo", ".", "foo")
188 testRel(t, "foo", ".", "./foo")
189 testRel(t, "foo/bar", ".", "foo/bar")
190 testRel(t, "bar", "c:\\foo", "c:\\foo\\bar")
191 testRel(t, "bar", "foo", "foo/bar")
192 testRel(t, "baz", "c:\\foo/./bar", "c:\\foo\\bar\\baz")
193 testRel(t, "baz", "foo/./bar", "foo/bar/baz")
194
195 // This would require querying the current directory to know what
196 // Drive `\` refers to.
197 testRelError(t, "", "\\foo\\bar", "c:\\foo\\bar")
198
199 testRelError(t, "", "..", "foo/bar")
200 testRelError(t, "", "c:\\foo", "d:\\bar")
201 testRelError(t, "", "\\\\127.0.0.1\\$c\\foo", "\\\\127.0.0.1\\$d\\foo")
202}
203
204func testRel(t *testing.T, expected string, basepath string, targpath string) {
205 rel, err := Rel(basepath, targpath)

Callers

nothing calls this directly

Calls 2

testRelFunction · 0.70
testRelErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…