mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-25 15:50:27 +00:00
vis: refactored code to reflect using vis/unvis for file names
Added some more test cases for `vis`ing and `unvis`ing strings, and a test case that walks/checks a directory with filenames that require encoding. Had to change Path() to account for possible errors Unvis() could return. Refactored Vis()/Unvis() into go-mtree tar functionality as well. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
a63f83d94d
commit
773763fb87
12 changed files with 177 additions and 41 deletions
16
vis_test.go
16
vis_test.go
|
@ -9,13 +9,17 @@ func TestVis(t *testing.T) {
|
|||
{"[", "\\133"},
|
||||
{" ", "\\040"},
|
||||
{" ", "\\011"},
|
||||
{"dir with space", "dir\\040with\\040space"},
|
||||
{"consec spaces", "consec\\040\\040\\040spaces"},
|
||||
{"trailingsymbol[", "trailingsymbol\\133"},
|
||||
{" [ leadingsymbols", "\\040\\133\\040leadingsymbols"},
|
||||
{"no_need_for_encoding", "no_need_for_encoding"},
|
||||
}
|
||||
|
||||
for i := range testset {
|
||||
got, err := Vis(testset[i].Src)
|
||||
if err != nil {
|
||||
t.Errorf("working with %q: %s", testset[i].Src, err)
|
||||
continue
|
||||
}
|
||||
if got != testset[i].Dest {
|
||||
t.Errorf("expected %#v; got %#v", testset[i].Dest, got)
|
||||
|
@ -33,3 +37,13 @@ func TestVis(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The resulting string of Vis output could potentially be four times longer than
|
||||
// the original. Vis must handle this possibility.
|
||||
func TestVisLength(t *testing.T) {
|
||||
testString := "All work and no play makes Jack a dull boy\n"
|
||||
for i := 0; i < 20; i++ {
|
||||
Vis(testString)
|
||||
testString = testString + testString
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue