Андрей Иванов 5693923d03
All checks were successful
continuous-integration/drone/push Build is passing
Добавил базовые методы и модели для тестирования нарезки дерева
2024-10-03 17:42:55 +03:00

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)
}
})
}
}