示例#1
0
func drawsOk(t *testing.T, msg string, n tree.Node, s string) {
	got := strings.Trim(n.Draw(), "\n")
	want := strings.Trim(trim.ReplaceAllString(s, ""), "\n")
	if got != want {
		t.Errorf("%s failed\nexpected:\n[%s]\ngot:\n[%s]\n", msg, want, got)
	}
}
示例#2
0
func pathsOk(t *testing.T, msg string, n tree.Node, want ...string) {
	got := n.Paths("/")
	if len(got) != len(want) {
		got_ := "    - " + strings.Join(got, "\n    - ") + "\n"
		want_ := "    - " + strings.Join(want, "\n    - ") + "\n"
		t.Errorf("%s failed\nexpected %d paths:\n%s\ngot %d paths:\n%s\n", msg, len(want), want_, len(got), got_)
	}

	for i := range got {
		if got[i] != want[i] {
			t.Errorf("%s failed\npaths[%d] was incorrect\nexpected: [%s]\n     got: [%s]\n", msg, i, want[i], got[i])
		}
	}
}