本文整理汇总了Golang中github.com/axel-freesp/sge/interface/behaviour.LibraryIf.Read方法的典型用法代码示例。如果您正苦于以下问题:Golang LibraryIf.Read方法的具体用法?Golang LibraryIf.Read怎么用?Golang LibraryIf.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/axel-freesp/sge/interface/behaviour.LibraryIf
的用法示例。
在下文中一共展示了LibraryIf.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLibrary
func TestLibrary(t *testing.T) {
case1 := []struct {
library string
}{
{`<library xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<signal-type name="s1" scope="" mode="" c-type="" message-id=""></signal-type>
<node-type name="Test">
<intype port="" type="s1"></intype>
<outtype port="" type="s1"></outtype>
</node-type>
</library>
`},
}
for i, c := range case1 {
freesp.Init()
var l bh.LibraryIf = LibraryNew("test.alml", nil)
buf := copyBuf(c.library)
_, err := l.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
}
}
示例2: TestGraph
func TestGraph(t *testing.T) {
case1 := []struct {
library, graph string
nodes, connections int
}{
{`<library xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<signal-type name="s1" scope="" mode="" c-type="" message-id=""></signal-type>
<node-type name="Test">
<intype port="" type="s1"></intype>
<outtype port="" type="s1"></outtype>
</node-type>
</library>
`, `<?xml version="1.0" encoding="UTF-8"?>
<signal-graph xmlns="http://www.freesp.de/xml/freeSP" version="1.0">
<nodes>
<input name="sensor">
<outtype type="s1"/>
</input>
<output name="actuator">
<intype type="s1"/>
</output>
<processing-node name="test" type="Test"></processing-node>
</nodes>
<connections>
<connect from="sensor" to="test"/>
<connect from="test" to="actuator"/>
</connections>
</signal-graph>
`, 3, 2},
}
for i, c := range case1 {
freesp.Init()
var l bh.LibraryIf = LibraryNew("test.alml", nil)
buf := copyBuf(c.library)
_, err := l.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
var sg bh.SignalGraphIf = SignalGraphNew("test.sml", nil)
buf = copyBuf(c.graph)
_, err = sg.Read(buf)
if err != nil {
t.Errorf("Testcase %d: Failed to read from buffer: %v", i, err)
return
}
var st bh.SignalGraphTypeIf = sg.ItsType()
if len(st.Nodes()) != c.nodes {
t.Errorf("Testcase %d: NodeIf count mismatch", i)
return
}
}
}