コード例 #1
0
ファイル: expand_test.go プロジェクト: gogo/fieldpath
func TestExpandAndCollapseExtendedMessage(t *testing.T) {
	collapsed := "FieldB.Field1"
	expanded := "FieldB.Field1"
	rootPkg := "test"
	rootMsg := "MyExtendable"
	e, err := fieldpath.Expand(rootPkg, rootMsg, collapsed, test.ThetestDescription())
	if err != nil {
		panic(err)
	}
	t.Logf("Expanded to %v", e)
	if e != expanded {
		t.Fatalf("Expected Expanded %v but got %v", expanded, e)
	}
	c, err := fieldpath.Collapse(rootPkg, rootMsg, expanded, test.ThetestDescription())
	if err != nil {
		panic(err)
	}
	t.Logf("Collapsed to %v", c)
	if c != collapsed {
		t.Fatalf("Expected Collapsed %v but got %v", collapsed, c)
	}
}
コード例 #2
0
ファイル: expand_test.go プロジェクト: gogo/fieldpath
func TestExpandAndCollapseOneLevel(t *testing.T) {
	collapsed := "Field1"
	expanded := "Field1.Field1"
	rootPkg := "test"
	rootMsg := "NinEmbeddedStruct"
	e, err := fieldpath.Expand(rootPkg, rootMsg, collapsed, test.ThetestDescription())
	if err != nil {
		panic(err)
	}
	t.Logf("Expanded to %v", e)
	if e != expanded {
		t.Fatalf("Expected Expanded %v but got %v", expanded, e)
	}
	c, err := fieldpath.Collapse(rootPkg, rootMsg, expanded, test.ThetestDescription())
	if err != nil {
		panic(err)
	}
	t.Logf("Collapsed to %v", c)
	if c != collapsed {
		t.Fatalf("Expected Collapsed %v but got %v", collapsed, c)
	}
}