Skip to content

Commit

Permalink
core/bloom: use normal checks instead of require lib
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed Dec 20, 2022
1 parent d238a75 commit d2ae63c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
20 changes: 12 additions & 8 deletions core/bloom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package core

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestIsBitSet(t *testing.T) {
Expand All @@ -28,10 +26,12 @@ func TestIsBitSet(t *testing.T) {

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
t.Parallel()
actual := isBitSet(buf, tc.index)
require.Equal(t, actual, tc.expected, tc.name)
if actual != tc.expected {
t.Errorf("error in %s for case: %s - expected %t, got %t", t.Name(), tc.name, tc.expected, actual)
}
})
}
}
Expand All @@ -58,15 +58,19 @@ func TestSetBit(t *testing.T) {

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
// Set bit first and then try to read it
setBit(buf, tc.index)
actual := isBitSet(buf, tc.index)
require.Equal(t, actual, tc.expected, tc.name)
if actual != tc.expected {
t.Errorf("error in %s for case: %s - expected %t, got %t", t.Name(), tc.name, tc.expected, actual)
}
})
}

// The final values are 10111011 (=187)
require.Equal(t, int(buf[0]), 187, "Expect buffer to have updated value")
require.Equal(t, int(buf[1]), 187, "Expect buffer to have updated value")
expected1, expected2 := 187, 187
if int(buf[0]) != expected1 || int(buf[1]) != expected2 {
t.Errorf("error in %s while comparing final buffer values - expected [%d, %d], got [%d, %d]", t.Name(), expected1, expected2, int(buf[0]), int(buf[1]))
}
}
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ module github.com/dicedb/dice

go 1.17

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.1 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
require github.com/twmb/murmur3 v1.1.6
16 changes: 0 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit d2ae63c

Please sign in to comment.