Ejemplo n.º 1
0
func TestWithImportsDef(t *testing.T) {
	assert := assert.New(t)

	def := gen.ImportUserDef{
		ImportedStruct: gen.DDef{
			StructField: gen.SDef{S: "hi", B: true},
			EnumField:   gen.E2,
		},
		Enum: gen.LocalE1,
	}
	st := def.New()

	def2 := st.Def()
	st2 := def.New()

	assert.Equal(def, def2)
	assert.True(st.Equals(st2))

	ds := gen.NewD().SetStructField(gen.NewS().SetS("hi").SetB(true)).SetEnumField(gen.E2)
	st3 := gen.NewImportUser()
	st3 = st3.SetImportedStruct(ds).SetEnum(gen.LocalE1)
	assert.True(st.Equals(st3))
	ddef := st3.ImportedStruct().Def()
	assert.Equal("hi", ddef.StructField.S)
	assert.Equal(true, ddef.StructField.B)
	assert.Equal(gen.E2, ddef.EnumField)
}
Ejemplo n.º 2
0
func TestDepsAndPackageRefs(t *testing.T) {
	assert := assert.New(t)

	tr := gen.NewImportUser().ImportedStruct().Type()
	assert.Equal(types.UnresolvedKind, tr.Kind())
	assert.True(tr.HasPackageRef())
	p := types.LookupPackage(tr.PackageRef())
	assert.NotNil(p)
	assert.IsType(types.Package{}, *p)
}