Skip to content

Commit

Permalink
tests: covers eq operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Feb 13, 2024
1 parent 350972b commit dc92b68
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/operators/eq_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 Juan Pablo Tosso and the OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0

package operators

import (
"testing"

"github.com/corazawaf/coraza/v3/experimental/plugins/plugintypes"
)

func TestEq(t *testing.T) {
eq, _ := newEq(plugintypes.OperatorOptions{
Arguments: "1",
})

testCases := map[string]bool{
"1": true,
"01": true,
"1.0": false,
}

for value, want := range testCases {
t.Run(value, func(t *testing.T) {
if have := eq.Evaluate(nil, value); want != have {
t.Errorf("unexpected result: want %v, have %v", want, have)
}
})
}
}

0 comments on commit dc92b68

Please sign in to comment.