blob: ca25f0dd59d2a17e87e30f64356d1b7370f6b276 [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package bitops
import (
"testing"
)
func TestFfs(t *testing.T) {
// Defined in common_test.go. Creates a new random number generator.
r := setUp(t)
for i := 0; i < 100; i++ {
x := uint64(r.Int63())
if x == 0 {
// Just skip zeroes.
continue
}
expected := ffs(x)
if actual := FFS(x); actual != expected {
t.Errorf("FFS(%#x) = %v; want %v\n", x, actual, expected)
}
}
}
func TestClz(t *testing.T) {
// Defined in common_test.go. Creates a new random number generator.
r := setUp(t)
for i := 0; i < 100; i++ {
x := uint64(r.Int63())
if x == 0 {
// Just skip zeroes.
continue
}
expected := clz(x)
if actual := CLZ(x); actual != expected {
t.Errorf("CLZ(%#x) = %v; want %v\n", x, actual, expected)
}
}
}