MCPcopy Create free account
hub / github.com/EliCDavis/polyform / TestStruct_ArrayAdd

Function TestStruct_ArrayAdd

nodes/struct_test.go:74–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestStruct_ArrayAdd(t *testing.T) {
75 var n nodes.Node = &ArrayTestStructNode{
76 Data: ArrayTestStruct{
77 Values: []nodes.Output[float64]{
78 nodes.NewValue(1.).Outputs()["Value"].(nodes.Output[float64]),
79 nodes.NewValue(2.).Outputs()["Value"].(nodes.Output[float64]),
80 nodes.NewValue(3.).Outputs()["Value"].(nodes.Output[float64]),
81 },
82 },
83 }
84
85 // ACT ====================================================================
86 output := n.Outputs()
87 namedNode, named := n.(nodes.Named)
88 pathedNode, pathed := n.(nodes.Pathed)
89
90 // ASSERT =================================================================
91 assert.Len(t, output, 1)
92
93 assert.True(t, named)
94 assert.Equal(t, "Array Test Struct", namedNode.Name())
95
96 assert.True(t, pathed)
97 assert.Equal(t, "nodes_test", pathedNode.Path())
98
99 // assert.Contains(t, "Sum", output)
100 require.Contains(t, output, "Sum")
101
102 sumOutput := output["Sum"].(nodes.Output[float64])
103 assert.Equal(t, 6., sumOutput.Value())
104 assert.Equal(t, 0, sumOutput.Version())
105 assert.Equal(t, "Sum", sumOutput.Name())
106 assert.Equal(t, n, sumOutput.Node())
107}
108
109func TestStruct_ArrayHierchyAdd(t *testing.T) {
110

Callers

nothing calls this directly

Calls 10

OutputsMethod · 0.95
NewValueFunction · 0.92
EqualMethod · 0.80
NameMethod · 0.65
PathMethod · 0.65
ValueMethod · 0.65
VersionMethod · 0.65
NodeMethod · 0.65
LenMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected