first simple test for positive aspects
This commit is contained in:
76
matrix_test.go
Normal file
76
matrix_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package goodcalc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func emptyMatrix() *Matrix {
|
||||
m := Matrix{
|
||||
MaxPoints: 1000,
|
||||
MaxValuationPoints: 10,
|
||||
MaxNegValuationPoints: -200,
|
||||
NegPointsFactor: 50,
|
||||
Stakeholders: []*Stakeholder{},
|
||||
Calculation: &MatrixCalc{
|
||||
SumCalcWeight: 0,
|
||||
WeightFactor: 0,
|
||||
},
|
||||
}
|
||||
|
||||
stakeholderDefault := []Stakeholder{
|
||||
{"A", 1.5, []*Theme{}},
|
||||
{"B", 0.5, []*Theme{}},
|
||||
{"C", 0.5, []*Theme{}},
|
||||
{"D", 1, []*Theme{}},
|
||||
{"E", 1, []*Theme{}},
|
||||
}
|
||||
|
||||
themeDefault := []string{"1", "2", "3", "4"}
|
||||
for _, st := range stakeholderDefault {
|
||||
s := st
|
||||
for _, th := range themeDefault {
|
||||
t := Theme{
|
||||
No: st.No + th,
|
||||
Weight: 1,
|
||||
Aspects: []Aspect{},
|
||||
NegativeAspects: []NegativeAspect{},
|
||||
NegPointsFactor: 0,
|
||||
Calc: &ThemeCalc{},
|
||||
}
|
||||
for i := 1; i <= 2; i++ {
|
||||
a := Aspect{
|
||||
No: fmt.Sprintf("%s.%d", t.No, i),
|
||||
Weight: 1,
|
||||
ValuationPoints: 5,
|
||||
}
|
||||
t.Aspects = append(t.Aspects, a)
|
||||
}
|
||||
s.Themes = append(s.Themes, &t)
|
||||
}
|
||||
m.Stakeholders = append(m.Stakeholders, &s)
|
||||
}
|
||||
return &m
|
||||
}
|
||||
|
||||
func TestMatrix_BalancePoints(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
m *Matrix
|
||||
want int
|
||||
}{
|
||||
{
|
||||
"",
|
||||
emptyMatrix(),
|
||||
500,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.m.BalancePoints(); got != tt.want {
|
||||
t.Errorf("Matrix.BalancePoints() = %v, want %v", got, tt.want)
|
||||
}
|
||||
//fmt.Printf("%s", tt.m)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user