Skip to content

Commit

Permalink
cpu: add test for IsBigEndian
Browse files Browse the repository at this point in the history
For golang/go#57237

Change-Id: I11d1c954f942ebd836c4deb9c710c40778dc5599
Reviewed-on: https://go-review.googlesource.com/c/sys/+/494858
Auto-Submit: Tobias Klauser <[email protected]>
Run-TryBot: Tobias Klauser <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
tklauser authored and gopherbot committed May 16, 2023
1 parent c43fe1e commit 352d833
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cpu/endian_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 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.

package cpu_test

import (
"testing"
"unsafe"

"golang.org/x/sys/cpu"
)

func TestIsBigEndian(t *testing.T) {
b := uint16(0xff00)
want := *(*byte)(unsafe.Pointer(&b)) == 0xff
if cpu.IsBigEndian != want {
t.Errorf("IsBigEndian = %t, want %t",
cpu.IsBigEndian, want)
}
}

0 comments on commit 352d833

Please sign in to comment.