aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-11 03:30:06 -0500
committerPaul Duncan <pabs@pablotron.org>2022-03-11 03:30:06 -0500
commite3de4db85b0b537194cbfff4f469cb89e8e258b1 (patch)
treea20774cc7b010b28d33916da2e4ab8f5d62b51b1
parentcd8316a648d43d1e135de35b5ee5614a302fed29 (diff)
downloadcvez-e3de4db85b0b537194cbfff4f469cb89e8e258b1.tar.bz2
cvez-e3de4db85b0b537194cbfff4f469cb89e8e258b1.zip
add cvss/calc_test.go
-rw-r--r--cvss/calc_test.go29
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])
+ }
+ })
+ }
+}