1// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package sys_test
6
7import (
8	"runtime/internal/sys"
9	"testing"
10)
11
12func TestTrailingZeros64(t *testing.T) {
13	for i := 0; i <= 64; i++ {
14		x := uint64(5) << uint(i)
15		if got := sys.TrailingZeros64(x); got != i {
16			t.Errorf("TrailingZeros64(%d)=%d, want %d", x, got, i)
17		}
18	}
19}
20func TestTrailingZeros32(t *testing.T) {
21	for i := 0; i <= 32; i++ {
22		x := uint32(5) << uint(i)
23		if got := sys.TrailingZeros32(x); got != i {
24			t.Errorf("TrailingZeros32(%d)=%d, want %d", x, got, i)
25		}
26	}
27}
28
29func TestBswap64(t *testing.T) {
30	x := uint64(0x1122334455667788)
31	y := sys.Bswap64(x)
32	if y != 0x8877665544332211 {
33		t.Errorf("Bswap(%x)=%x, want 0x8877665544332211", x, y)
34	}
35}
36func TestBswap32(t *testing.T) {
37	x := uint32(0x11223344)
38	y := sys.Bswap32(x)
39	if y != 0x44332211 {
40		t.Errorf("Bswap(%x)=%x, want 0x44332211", x, y)
41	}
42}
43