Exemplo n.º 1
0
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)
	}
}
Exemplo n.º 2
0
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)
	}
}