aboutsummaryrefslogtreecommitdiff
path: root/src/os/path_windows_test.go
blob: 8fd515728e2662b5afa7774a534d9d257b399bd6 (plain)
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
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package os_test

import (
	"os"
	"testing"
)

func TestFixLongPath(t *testing.T) {
	for _, test := range []struct{ in, want string }{
		{`C:\foo.txt`, `\\?\C:\foo.txt`},
		{`C:/foo.txt`, `\\?\C:\foo.txt`},
		{`C:\foo\\bar\.\baz\\`, `\\?\C:\foo\bar\baz`},
		{`C:\`, `\\?\C:\`}, // drives must have a trailing slash
		{`\\unc\path`, `\\unc\path`},
		{`foo.txt`, `foo.txt`},
		{`C:foo.txt`, `C:foo.txt`},
		{`c:\foo\..\bar\baz`, `c:\foo\..\bar\baz`},
		{`\\?\c:\windows\foo.txt`, `\\?\c:\windows\foo.txt`},
		{`\\?\c:\windows/foo.txt`, `\\?\c:\windows/foo.txt`},
	} {
		if got := os.FixLongPath(test.in); got != test.want {
			t.Errorf("fixLongPath(%q) = %q; want %q", test.in, got, test.want)
		}
	}
}