Skip to content

Commit 52f664c

Browse files
authored
internal/dirent: fix tests on s390x (#65)
This commit fixes tests on s390x (big-endian) by removing TestReadInt, which really only existed for code coverage. Fixes #61
1 parent c9ad02f commit 52f664c

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

internal/dirent/dirent_test.go

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,7 @@
22

33
package dirent
44

5-
import (
6-
"encoding/binary"
7-
"fmt"
8-
"math"
9-
"math/rand"
10-
"testing"
11-
)
12-
13-
func TestReadInt(t *testing.T) {
14-
for _, sz := range []int{1, 2, 4, 8} {
15-
rr := rand.New(rand.NewSource(1))
16-
t.Run(fmt.Sprintf("%d", sz), func(t *testing.T) {
17-
var fn func() uint64
18-
switch sz {
19-
case 1:
20-
fn = func() uint64 { return uint64(rr.Int63n(256)) }
21-
case 2:
22-
fn = func() uint64 { return uint64(rr.Int63n(math.MaxUint16)) }
23-
case 4:
24-
fn = func() uint64 { return uint64(rr.Int63n(math.MaxUint32)) }
25-
case 8:
26-
fn = func() uint64 { return uint64(rr.Uint64()) }
27-
default:
28-
t.Fatal("invalid size:", sz)
29-
}
30-
buf := make([]byte, 8)
31-
fails := 0
32-
for i := 0; i < 100; i++ {
33-
want := fn()
34-
binary.NativeEndian.PutUint64(buf[:], want)
35-
got, ok := readInt(buf, 0, uintptr(sz))
36-
if got != want || !ok {
37-
fails++
38-
t.Errorf("readInt(%q, 0, %d) = %d, %t; want: %d, %t", buf, sz, got, ok, want, true)
39-
}
40-
if fails >= 10 {
41-
t.Fatal("too many errors:", fails)
42-
}
43-
}
44-
})
45-
}
46-
if i, ok := readInt(nil, 1, 1); i != 0 || ok {
47-
t.Errorf("readInt(nil, 1, 1) = %d, %t; want: %d, %t", i, ok, 0, false)
48-
}
49-
}
5+
import "testing"
506

517
func TestReadIntSize(t *testing.T) {
528
if i, ok := readInt(nil, 1, 1); i != 0 || ok {

0 commit comments

Comments
 (0)