-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsharded_cache_utils_test.go
39 lines (32 loc) · 1007 Bytes
/
sharded_cache_utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cache
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDjb33(t *testing.T) {
t.Run("Hash function is consistent", func(t *testing.T) {
result1 := djb33(0, "test")
result2 := djb33(0, "test")
assert.Equal(t, result1, result2)
})
t.Run("Hash function with different seeds", func(t *testing.T) {
result1 := djb33(1, "test")
result2 := djb33(2, "test")
assert.NotEqual(t, result1, result2)
})
t.Run("Hash function with different strings", func(t *testing.T) {
result1 := djb33(0, "test")
result2 := djb33(0, "another_test")
assert.NotEqual(t, result1, result2)
})
t.Run("Hash function with same strings and different seeds", func(t *testing.T) {
result1 := djb33(1, "same_string")
result2 := djb33(2, "same_string")
assert.NotEqual(t, result1, result2)
})
t.Run("Hash function is different for different inputs", func(t *testing.T) {
result1 := djb33(0, "input1")
result2 := djb33(0, "input2")
assert.NotEqual(t, result1, result2)
})
}