Skip to content

Commit 352d833

Browse files
tklausergopherbot
authored andcommitted
cpu: add test for IsBigEndian
For golang/go#57237 Change-Id: I11d1c954f942ebd836c4deb9c710c40778dc5599 Reviewed-on: https://go-review.googlesource.com/c/sys/+/494858 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent c43fe1e commit 352d833

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cpu/endian_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2023 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+
5+
package cpu_test
6+
7+
import (
8+
"testing"
9+
"unsafe"
10+
11+
"golang.org/x/sys/cpu"
12+
)
13+
14+
func TestIsBigEndian(t *testing.T) {
15+
b := uint16(0xff00)
16+
want := *(*byte)(unsafe.Pointer(&b)) == 0xff
17+
if cpu.IsBigEndian != want {
18+
t.Errorf("IsBigEndian = %t, want %t",
19+
cpu.IsBigEndian, want)
20+
}
21+
}

0 commit comments

Comments
 (0)