Example #1
0
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)
}
Example #2
0
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)
}