| // Copyright 2014 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestNLZ(t *testing.T) { |
| // Test the platform-specific edge case. |
| // NB: v must be a var (not const) so that the word() conversion is dynamic. |
| // Otherwise the compiler will report an error. |
| v := uint64(0x0000801000000000) |
| want := 32 // (on 32-bit) |
| t.Errorf("%d-bit nlz(%d) = %d, want %d", bitsPerWord, v, n, want) |
| func (s *Sparse) Check() error { return s.check() } |
| func dumbPopcount(x word) int { |
| for i := uint(0); i < bitsPerWord; i++ { |
| func TestPopcount(t *testing.T) { |
| for i := 0; i < 1e5; i++ { |
| x = x | (word(rand.Uint32()) << 32) |
| t.Errorf("popcount(%d) = %d, want %d", x, got, want) |
| func BenchmarkPopcount(b *testing.B) { |
| for i := 0; i < b.N; i++ { |