Skip to content

Commit

Permalink
fixed github issue 3821 for string shannon entropy test (#3824)
Browse files Browse the repository at this point in the history
* fixed github issue 3821 for string shannon entropy test

* ahrav is legend
  • Loading branch information
kashifkhan0771 authored Dec 31, 2024
1 parent e98dfa5 commit 15b8ed6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/detectors/falsepositives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ func TestStringShannonEntropy(t *testing.T) {
args: args{
input: "aaaaaaaaaaaaaaaaaaaaaaaaaaab",
},
want: 0.22228483068568816,
want: 0.22,
},
{
name: "entropy 3",
args: args{
input: "aaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaab",
},
want: 0.22228483068568816,
want: 0.22,
},
{
name: "empty",
Expand All @@ -173,8 +173,11 @@ func TestStringShannonEntropy(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := StringShannonEntropy(tt.args.input); got != tt.want {
t.Errorf("StringShannonEntropy() = %v, want %v", got, tt.want)
got := StringShannonEntropy(tt.args.input)
if len(tt.args.input) > 0 && tt.want != 0 {
assert.InEpsilon(t, tt.want, got, 0.1)
} else {
assert.Equal(t, tt.want, got)
}
})
}
Expand Down

0 comments on commit 15b8ed6

Please sign in to comment.