企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ 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") } } ~~~