aboutsummaryrefslogtreecommitdiff
path: root/cvss/score_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cvss/score_test.go')
-rw-r--r--cvss/score_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/cvss/score_test.go b/cvss/score_test.go
index d35c4c8..5bff327 100644
--- a/cvss/score_test.go
+++ b/cvss/score_test.go
@@ -90,3 +90,51 @@ func TestScoreFloat(t *testing.T) {
})
}
}
+
+func TestScoreSeverity(t *testing.T) {
+ passTests := []struct {
+ val float64
+ exp Severity
+ } {
+ { 0.0, None },
+ { 0.1, Low },
+ { 3.9, Low },
+ { 4.0, Medium },
+ { 6.9, Medium },
+ { 7.0, High },
+ { 8.9, High },
+ { 9.0, Critical },
+ { 10.0, Critical },
+ }
+
+ for _, test := range(passTests) {
+ t.Run(strconv.FormatFloat(test.val, 'f', 2, 64), func(t *testing.T) {
+ s, err := NewScore(test.val)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ got := s.Severity()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+
+ failTests := []struct {
+ val Score
+ exp Severity
+ } {
+ { Score(uint8(110)), Unknown },
+ }
+
+ for _, test := range(failTests) {
+ t.Run(test.val.String(), func(t *testing.T) {
+ got := test.val.Severity()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+}