Ejemplo n.º 1
0
func TestFormat(t *testing.T) {
	tt := testing2.Wrap(t)
	code := `package main

        func TestExport(t *testing.T) {
            tt := testing2.Wrap(t)
        tt.True(IsExported("Name"))
                tt.True(ToSameExported("Abcd", "abc") == "Abc")
tt.True(ToSameExported("dbcd", "Abc") == "abc");tt.True(ToExported("aaa") == "Aaa")
    tt.True(ToExported("") == "")
    tt.True(ToUnexported("Aaa") == "aaa")
    tt.True(ToUnexported("") == "")
}
    `
	out := bytes.NewBuffer(make([]byte, 0, 1024))
	tt.True(Format("test", strings.NewReader(code), out) == nil)

	tt.Eq(strings2.RemoveSpace(`package main

func TestExport(t *testing.T) {
        tt := testing2.Wrap(t)
        tt.True(IsExported("Name"))
        tt.True(ToSameExported("Abcd", "abc") == "Abc")
        tt.True(ToSameExported("dbcd", "Abc") == "abc")
        tt.True(ToExported("aaa") == "Aaa")
        tt.True(ToExported("") == "")
        tt.True(ToUnexported("Aaa") == "aaa")
        tt.True(ToUnexported("") == "")
}
`), strings2.RemoveSpace(out.String()))
}
Ejemplo n.º 2
0
func TestCaller(t *testing.T) {
	if p := strings2.RemoveSpace(Caller(0)); p != "runtime_test.go:runtime2.TestCaller:10" {
		t.Fatalf("Error: expect runtime_test.go: runtime2.TestCaller: 10, but get %s", p)
	}
}
Ejemplo n.º 3
0
func TestCaller(t *testing.T) {
	exp := "github.com/cosiner/gohper/runtime2.TestCaller:runtime_test.go:11"
	if p := strings2.RemoveSpace(Caller(0)); p != exp {
		t.Fatalf("Error: expect %s, but get %s", exp, p)
	}
}
Ejemplo n.º 4
0
func TestCaller(t *testing.T) {
	exp := "runtime_test.go:11"
	if p := strings2.RemoveSpace(Caller(0)); p != exp {
		t.Fatalf("Error: expect %s, but get %s", exp, p)
	}
}