// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !race
+
package maphash
import (
// https://code.google.com/p/smhasher/
// This code is a port of some of the Smhasher tests to Go.
+// Note: due to the long running time of these tests, they are
+// currently disabled in -race mode.
+
var fixedSeed = MakeSeed()
// Sanity checks.
import (
"fmt"
+ "internal/race"
"math"
"math/rand"
. "runtime"
// All 0-3 byte strings have distinct hashes.
func TestSmhasherSmallKeys(t *testing.T) {
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
h := newHashSet()
var b [3]byte
for i := 0; i < 256; i++ {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
h := newHashSet()
for n := 2; n <= 16; n++ {
twoNonZero(h, n)
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
r := rand.New(rand.NewSource(1234))
const REPEAT = 8
const N = 1000000
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
permutation(t, []uint32{0, 1}, 20)
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
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) {
+ if race.Enabled {
+ t.Skip("Too long for race mode")
+ }
t.Logf("32 bit keys")
windowed(t, &Int32Key{})
t.Logf("64 bit keys")