mirror of
https://github.com/duanhf2012/origin.git
synced 2026-05-21 00:37:31 +08:00
优化代码
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package blueprint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -16,11 +17,33 @@ func (em *Entrance_IntParam) Exec() (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
type Output struct {
|
||||
BaseExecNode
|
||||
}
|
||||
|
||||
func (em *Output) GetName() string {
|
||||
return "Output"
|
||||
}
|
||||
func (em *Output) Exec() (int, error) {
|
||||
val, ok := em.GetInPortInt(0)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("Output Exec inParam not found")
|
||||
}
|
||||
|
||||
fmt.Printf("Output Exec inParam %d", val)
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func OnRegister(bm *ExecPool) error {
|
||||
bm.Register(&Entrance_IntParam{})
|
||||
bm.Register(&Output{})
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
EntranceID_IntParam = 3
|
||||
)
|
||||
|
||||
func TestExecMgr(t *testing.T) {
|
||||
//
|
||||
var bp Blueprint
|
||||
@@ -28,4 +51,13 @@ func TestExecMgr(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("init failed,err:%v", err)
|
||||
}
|
||||
|
||||
graph := bp.Create("test1")
|
||||
|
||||
err = graph.Do(EntranceID_IntParam, 1, 2, 3)
|
||||
if err != nil {
|
||||
t.Fatalf("do failed,err:%v", err)
|
||||
}
|
||||
|
||||
graph.Release()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user