aboutsummaryrefslogtreecommitdiff
path: root/cpe
diff options
context:
space:
mode:
Diffstat (limited to 'cpe')
-rw-r--r--cpe/v23binding_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cpe/v23binding_test.go b/cpe/v23binding_test.go
index 4fa46bb..3030fbe 100644
--- a/cpe/v23binding_test.go
+++ b/cpe/v23binding_test.go
@@ -86,12 +86,19 @@ func TestV23BindingUnmarshalJSON(t *testing.T) {
}, {
val: `"o:intel:ethernet_controller_e810_firmware:*:*:*:*:*:*:*:*"`,
exp: "missing CPE 2.3 prefix",
+ }, {
+ val: `x`,
+ exp: "invalid character 'x' looking for beginning of value",
}}
for _, test := range(failTests) {
t.Run(test.val, func(t *testing.T) {
var got V23Binding
- if err := json.Unmarshal([]byte(test.val), &got); err == nil {
+
+ // NOTE: we use got.UnmarshalJSON() instead of json.Unmarshal(),
+ // because if we use the latter with invalid json it fails before
+ // testing the underlying method.
+ if err := got.UnmarshalJSON([]byte(test.val)); err == nil {
t.Errorf("got %v, exp error", got)
} else if err.Error() != test.exp {
t.Errorf("got \"%s\", exp \"%s\"", err.Error(), test.exp)