diff options
-rw-r--r-- | cvss/calc_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cvss/calc_test.go b/cvss/calc_test.go new file mode 100644 index 0000000..b47d9da --- /dev/null +++ b/cvss/calc_test.go @@ -0,0 +1,29 @@ +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]) + } + }) + } +} |