Exemplo n.º 1
0
func TestAddIncl(t *testing.T) {
	n := fs.NewDir("")
	sources := []string{
		"a/\n\tb/\n\t\tc\n",
		"a/\n\tb/\n\t\td\n",
		"a/\n\te/\n\t\tf\n",
	}
	expect := fs.NewDir("",
		fs.NewDir("a",
			fs.NewDir("b",
				fs.NewFile("c"),
				fs.NewFile("d"),
			),
			fs.NewDir("e",
				fs.NewFile("f"),
			),
		),
	)

	for _, source := range sources {
		if err := addIncl(n, strings.NewReader(source)); err != nil {
			t.Errorf("Failed: %v", err)
		}
	}

	if !equal(n, expect) {
		t.Errorf("Expected:\n%s\nGot:\n%s", expect.String(), n.String())
	}
}
Exemplo n.º 2
0
type inclTest struct {
	source   string
	expected *fs.Node
}

var (
	inclTests = []inclTest{
		{"",
			fs.NewDir(""),
		},

		{"" +
			"a",
			fs.NewDir("",
				fs.NewFile("a"),
			),
		},

		{"" +
			"a\n",
			fs.NewDir("",
				fs.NewFile("a"),
			),
		},

		{"" +
			"a/\n" +
			"\tb",
			fs.NewDir("",
				fs.NewDir("a",