func TestOptionalStructDefFromNew(t *testing.T) { assert := assert.New(t) str := gen.NewOptionalStruct().SetB(true) def := str.Def() def2 := gen.OptionalStructDef{B: true} assert.Equal(def, def2) }
func TestOptionalStruct(t *testing.T) { assert := assert.New(t) str := gen.NewOptionalStruct() _, ok := str.S() assert.False(ok) _, ok = str.B() assert.False(ok) str = str.SetS("hi") s, ok := str.S() assert.True(ok) assert.Equal("hi", s) str = str.SetB(false) b, ok := str.B() assert.True(ok) assert.False(b) }