合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
~~~ package factorymethod import ( "testing" ) func TestFactoryMethod(t *testing.T) { var tmp *OperationAdd = nil if val, ok := tmp.Result(); ok == true { t.Error(val) } cAdd := COperationAdd{} var of OperationFunc = cAdd.createoperation("+") of.SetNumA(10) of.SetNumB(110) if val, ok := of.Result(); ok == true && val != 120 { t.Error("Add Error") } cSub := COperationSub{} of = cSub.createoperation("-") of.SetNumA(10) of.SetNumB(110) if val, ok := of.Result(); ok == true && val != -100 { t.Error("Sub Error") } } ~~~