import (
"fmt"
+ "internal/testenv"
"math"
"math/rand"
"runtime"
// hash should not depend on values outside key.
// hash should not depend on alignment.
func TestSmhasherSanity(t *testing.T) {
+ t.Parallel()
r := rand.New(rand.NewSource(1234))
const REP = 10
const KEYMAX = 128
// a string plus adding zeros must make distinct hashes
func TestSmhasherAppendedZeros(t *testing.T) {
+ t.Parallel()
s := "hello" + strings.Repeat("\x00", 256)
h := newHashSet()
for i := 0; i <= len(s); i++ {
// All 0-3 byte strings have distinct hashes.
func TestSmhasherSmallKeys(t *testing.T) {
+ testenv.ParallelOn64Bit(t)
h := newHashSet()
var b [3]byte
for i := 0; i < 256; i++ {
// Different length strings of all zeros have distinct hashes.
func TestSmhasherZeros(t *testing.T) {
+ t.Parallel()
N := 256 * 1024
if testing.Short() {
N = 1024
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ testenv.ParallelOn64Bit(t)
h := newHashSet()
for n := 2; n <= 16; n++ {
twoNonZero(h, n)
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
r := rand.New(rand.NewSource(1234))
const REPEAT = 8
const N = 1000000
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
h := newHashSet()
sparse(t, h, 32, 6)
sparse(t, h, 40, 6)
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ testenv.ParallelOn64Bit(t)
h := newHashSet()
permutation(t, h, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
permutation(t, h, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
avalancheTest1(t, &bytesKey{make([]byte, 2)})
avalancheTest1(t, &bytesKey{make([]byte, 4)})
avalancheTest1(t, &bytesKey{make([]byte, 8)})
// All bit rotations of a set of distinct keys
func TestSmhasherWindowed(t *testing.T) {
+ t.Parallel()
windowed(t, &bytesKey{make([]byte, 128)})
}
func windowed(t *testing.T, k key) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
h := newHashSet()
text(t, h, "Foo", "Bar")
text(t, h, "FooBar", "")
if unsafe.Sizeof(uintptr(0)) == 4 {
t.Skip("32-bit platforms don't have ideal seed-input distributions (see issue 33988)")
}
+ t.Parallel()
h := newHashSet()
const N = 100000
s := "hello"