|
@@ -133,55 +133,6 @@ func TestParseMountSpec(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func TestSplitN(t *testing.T) {
|
|
|
- for _, x := range []struct {
|
|
|
- input string
|
|
|
- n int
|
|
|
- expected []string
|
|
|
- }{
|
|
|
- {`C:\foo:d:`, -1, []string{`C:\foo`, `d:`}},
|
|
|
- {`:C:\foo:d:`, -1, nil},
|
|
|
- {`/foo:/bar:ro`, 3, []string{`/foo`, `/bar`, `ro`}},
|
|
|
- {`/foo:/bar:ro`, 2, []string{`/foo`, `/bar:ro`}},
|
|
|
- {`C:\foo\:/foo`, -1, []string{`C:\foo\`, `/foo`}},
|
|
|
-
|
|
|
- {`d:\`, -1, []string{`d:\`}},
|
|
|
- {`d:`, -1, []string{`d:`}},
|
|
|
- {`d:\path`, -1, []string{`d:\path`}},
|
|
|
- {`d:\path with space`, -1, []string{`d:\path with space`}},
|
|
|
- {`d:\pathandmode:rw`, -1, []string{`d:\pathandmode`, `rw`}},
|
|
|
- {`c:\:d:\`, -1, []string{`c:\`, `d:\`}},
|
|
|
- {`c:\windows\:d:`, -1, []string{`c:\windows\`, `d:`}},
|
|
|
- {`c:\windows:d:\s p a c e`, -1, []string{`c:\windows`, `d:\s p a c e`}},
|
|
|
- {`c:\windows:d:\s p a c e:RW`, -1, []string{`c:\windows`, `d:\s p a c e`, `RW`}},
|
|
|
- {`c:\program files:d:\s p a c e i n h o s t d i r`, -1, []string{`c:\program files`, `d:\s p a c e i n h o s t d i r`}},
|
|
|
- {`0123456789name:d:`, -1, []string{`0123456789name`, `d:`}},
|
|
|
- {`MiXeDcAsEnAmE:d:`, -1, []string{`MiXeDcAsEnAmE`, `d:`}},
|
|
|
- {`name:D:`, -1, []string{`name`, `D:`}},
|
|
|
- {`name:D::rW`, -1, []string{`name`, `D:`, `rW`}},
|
|
|
- {`name:D::RW`, -1, []string{`name`, `D:`, `RW`}},
|
|
|
- {`c:/:d:/forward/slashes/are/good/too`, -1, []string{`c:/`, `d:/forward/slashes/are/good/too`}},
|
|
|
- {`c:\Windows`, -1, []string{`c:\Windows`}},
|
|
|
- {`c:\Program Files (x86)`, -1, []string{`c:\Program Files (x86)`}},
|
|
|
-
|
|
|
- {``, -1, nil},
|
|
|
- {`.`, -1, []string{`.`}},
|
|
|
- {`..\`, -1, []string{`..\`}},
|
|
|
- {`c:\:..\`, -1, []string{`c:\`, `..\`}},
|
|
|
- {`c:\:d:\:xyzzy`, -1, []string{`c:\`, `d:\`, `xyzzy`}},
|
|
|
- } {
|
|
|
- res := SplitN(x.input, x.n)
|
|
|
- if len(res) < len(x.expected) {
|
|
|
- t.Fatalf("input: %v, expected: %v, got: %v", x.input, x.expected, res)
|
|
|
- }
|
|
|
- for i, e := range res {
|
|
|
- if e != x.expected[i] {
|
|
|
- t.Fatalf("input: %v, expected: %v, got: %v", x.input, x.expected, res)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// testParseMountSpec is a structure used by TestParseMountSpecSplit for
|
|
|
// specifying test cases for the ParseMountSpec() function.
|
|
|
type testParseMountSpec struct {
|