mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-25 15:50:27 +00:00
vis/unvis: pull in exact implementation from FreeBSD
Perhaps this is not completely ideal, because it brings in cgo. And with the flags, it can have tailored experience. I've added a basic test to ensure that the cases we're interested in are covered. This does not yet integrate the usage of Vis()/Unviz() into the manifest create and compare. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
cc939615c7
commit
a63f83d94d
6 changed files with 649 additions and 0 deletions
35
vis_test.go
Normal file
35
vis_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package mtree
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestVis(t *testing.T) {
|
||||
testset := []struct {
|
||||
Src, Dest string
|
||||
}{
|
||||
{"[", "\\133"},
|
||||
{" ", "\\040"},
|
||||
{" ", "\\011"},
|
||||
}
|
||||
|
||||
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)
|
||||
continue
|
||||
}
|
||||
|
||||
got, err = Unvis(got)
|
||||
if err != nil {
|
||||
t.Errorf("working with %q: %s", testset[i].Src, err)
|
||||
continue
|
||||
}
|
||||
if got != testset[i].Src {
|
||||
t.Errorf("expected %#v; got %#v", testset[i].Src, got)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue