1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package cvss
import (
"testing"
)
func TestNewScores(t *testing.T) {
// test out of bound errors
failTests := []struct {
name string // test name
vals []float64 // invalid base, temporal, and env scores
} {{
name: "invalid base",
vals: []float64 { 11.0, 0.0, 0.0 },
}, {
name: "invalid temporal",
vals: []float64 { 0.0, 11.0, 0.0 },
}, {
name: "invalid env",
vals: []float64 { 0.0, 0.0, 11.0 },
}}
for _, test := range(failTests) {
t.Run(test.name, func(t *testing.T) {
got, err := NewScores(test.vals[0], test.vals[1], test.vals[2])
if err == nil {
t.Errorf("got %v, exp error", got)
}
})
}
}
|