go-mtree/vis_test.go
Vincent Batts a63f83d94d 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>
2016-07-25 15:36:29 -04:00

35 lines
644 B
Go

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
}
}
}