package cvss import "testing" func TestCalc(t *testing.T) { tests := []struct { val string exp bool } { { "foo", false }, { "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:N", true }, } for _, test := range(tests) { t.Run(test.val, func(t *testing.T) { got := Calc([]string { test.val }) if len(got) != 1 { t.Errorf("invalid len(got): %d != 1", len(got)) return } if test.exp && got[0].Error != "" { t.Errorf("got %s, exp success", got[0].Error) } else if !test.exp && got[0].Error == "" { t.Errorf("got %v, exp error", got[0]) } }) } }