/usr/share/gocode/src/github.com/dgryski/go-bits/bits_test.go is in golang-github-dgryski-go-bits-dev 0.0~git20151205.0.86c69b3-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 40 41 42 43 44 45 46 47 48 49 50 | package bits
import (
"testing"
"testing/quick"
)
func testQuick(t *testing.T, which string, ffast, fslow func(x uint64) uint64) {
f := func(x uint64) bool {
return ffast(x) == fslow(x)
}
if err := quick.Check(f, nil); err != nil {
t.Errorf("fast%v != slow%v: %v: ", which, which, err)
}
}
func ctzSlow(x uint64) uint64 {
var n uint64
for x&1 == 0 {
n++
x >>= 1
}
return n
}
func TestQuickCtz(t *testing.T) { testQuick(t, "ctz", Ctz, ctzSlow) }
func clzSlow(x uint64) uint64 {
var n uint64
for x&0x8000000000000000 == 0 {
n++
x <<= 1
}
return n
}
func TestQuickClz(t *testing.T) { testQuick(t, "clz", Clz, clzSlow) }
func popcntSlow(x uint64) uint64 {
var n uint64
for x != 0 {
if x&1 == 1 {
n++
}
x >>= 1
}
return n
}
func TestQuickPopcnt(t *testing.T) { testQuick(t, "popcnt", Popcnt, popcntSlow) }
|