33 lines
650 B
Go
33 lines
650 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDecomposeTree(t *testing.T){
|
|
for name, tt := range map[string]struct{
|
|
inputTree map[string]*WeightedNode
|
|
inputThreshold int
|
|
outputParts []SubTree
|
|
err string
|
|
}{
|
|
"Normal":{
|
|
inputTree: smallTree.Tree,
|
|
inputThreshold: smallTree.Threshold,
|
|
outputParts: smallTree.Parts,
|
|
},
|
|
}{
|
|
t.Run(name, func(t *testing.T) {
|
|
result, err := DecomposeTree(tt.inputTree, tt.inputThreshold)
|
|
if tt.err == "" {
|
|
require.NoError(t, err)
|
|
require.ElementsMatch(t, result, tt.outputParts)
|
|
} else {
|
|
require.EqualError(t, err, tt.err)
|
|
}
|
|
})
|
|
}
|
|
}
|