mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
all: clean unnecessary casts for test files
This is a follow up of CL 528696.
Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5
GitHub-Last-Rev: acaf3ac11c
GitHub-Pull-Request: golang/go#62713
Reviewed-on: https://go-review.googlesource.com/c/go/+/529197
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
bf5d8c02ba
commit
9b883484a8
|
@ -1186,7 +1186,7 @@ func TestIssue12449(t *testing.T) {
|
|||
0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
}
|
||||
// Read in the archive.
|
||||
_, err := NewReader(bytes.NewReader([]byte(data)), int64(len(data)))
|
||||
_, err := NewReader(bytes.NewReader(data), int64(len(data)))
|
||||
if err != nil {
|
||||
t.Errorf("Error reading the archive: %v", err)
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ func TestCVE202127919(t *testing.T) {
|
|||
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x39, 0x00,
|
||||
0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
}
|
||||
r, err := NewReader(bytes.NewReader([]byte(data)), int64(len(data)))
|
||||
r, err := NewReader(bytes.NewReader(data), int64(len(data)))
|
||||
if err != ErrInsecurePath {
|
||||
t.Fatalf("Error reading the archive: %v", err)
|
||||
}
|
||||
|
@ -1559,7 +1559,7 @@ func TestCVE202141772(t *testing.T) {
|
|||
0x00, 0x04, 0x00, 0x04, 0x00, 0x31, 0x01, 0x00,
|
||||
0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
}
|
||||
r, err := NewReader(bytes.NewReader([]byte(data)), int64(len(data)))
|
||||
r, err := NewReader(bytes.NewReader(data), int64(len(data)))
|
||||
if err != ErrInsecurePath {
|
||||
t.Fatalf("Error reading the archive: %v", err)
|
||||
}
|
||||
|
|
|
@ -590,7 +590,7 @@ func testZip64(t testing.TB, size int64) *rleBuffer {
|
|||
}
|
||||
|
||||
// read back zip file and check that we get to the end of it
|
||||
r, err := NewReader(buf, int64(buf.Size()))
|
||||
r, err := NewReader(buf, buf.Size())
|
||||
if err != nil {
|
||||
t.Fatal("reader:", err)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func TestScanRune(t *testing.T) {
|
|||
var i, runeCount int
|
||||
var expect rune
|
||||
// Use a string range loop to validate the sequence of runes.
|
||||
for i, expect = range string(test) {
|
||||
for i, expect = range test {
|
||||
if !s.Scan() {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ func TestReadFile(t *testing.T) {
|
|||
t.Fatalf("unexpected success; want error containing %q", tc.wantErr)
|
||||
}
|
||||
got := info.String()
|
||||
if clean := cleanOutputForComparison(string(got)); got != tc.want && clean != tc.want {
|
||||
if clean := cleanOutputForComparison(got); got != tc.want && clean != tc.want {
|
||||
t.Fatalf("got:\n%s\nwant:\n%s", got, tc.want)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1339,7 +1339,7 @@ func TestLargeNumberOfSections(t *testing.T) {
|
|||
binary.Write(&buf, binary.LittleEndian, Section32{
|
||||
Name: 0x1B,
|
||||
Type: uint32(SHT_PROGBITS),
|
||||
Flags: uint32(uint32(SHF_ALLOC | SHF_EXECINSTR)),
|
||||
Flags: uint32(SHF_ALLOC | SHF_EXECINSTR),
|
||||
Off: 0x34,
|
||||
Addralign: 0x01,
|
||||
})
|
||||
|
|
|
@ -38,7 +38,7 @@ var compareTests = [][]reflect.Value{
|
|||
ct(reflect.TypeOf(chans[0]), chans[0], chans[1], chans[2]),
|
||||
ct(reflect.TypeOf(toy{}), toy{0, 1}, toy{0, 2}, toy{1, -1}, toy{1, 1}),
|
||||
ct(reflect.TypeOf([2]int{}), [2]int{1, 1}, [2]int{1, 2}, [2]int{2, 0}),
|
||||
ct(reflect.TypeOf(any(any(0))), iFace, 1, 2, 3),
|
||||
ct(reflect.TypeOf(any(0)), iFace, 1, 2, 3),
|
||||
}
|
||||
|
||||
var iFace any
|
||||
|
|
|
@ -80,7 +80,7 @@ func TypeLinks() []string {
|
|||
for i, offs := range offset {
|
||||
rodata := sections[i]
|
||||
for _, off := range offs {
|
||||
typ := (*rtype)(resolveTypeOff(unsafe.Pointer(rodata), off))
|
||||
typ := (*rtype)(resolveTypeOff(rodata, off))
|
||||
r = append(r, typ.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func LFStackPush(head *uint64, node *LFNode) {
|
|||
}
|
||||
|
||||
func LFStackPop(head *uint64) *LFNode {
|
||||
return (*LFNode)(unsafe.Pointer((*lfstack)(head).pop()))
|
||||
return (*LFNode)((*lfstack)(head).pop())
|
||||
}
|
||||
func LFNodeValidate(node *LFNode) {
|
||||
lfnodeValidate((*lfnode)(unsafe.Pointer(node)))
|
||||
|
@ -371,7 +371,7 @@ var ReadUnaligned64 = readUnaligned64
|
|||
func CountPagesInUse() (pagesInUse, counted uintptr) {
|
||||
stopTheWorld(stwForTestCountPagesInUse)
|
||||
|
||||
pagesInUse = uintptr(mheap_.pagesInUse.Load())
|
||||
pagesInUse = mheap_.pagesInUse.Load()
|
||||
|
||||
for _, s := range mheap_.allspans {
|
||||
if s.state.get() == mSpanInUse {
|
||||
|
@ -404,7 +404,7 @@ const (
|
|||
)
|
||||
|
||||
func (p *ProfBuf) Read(mode profBufReadMode) ([]uint64, []unsafe.Pointer, bool) {
|
||||
return (*profBuf)(p).read(profBufReadMode(mode))
|
||||
return (*profBuf)(p).read(mode)
|
||||
}
|
||||
|
||||
func (p *ProfBuf) Close() {
|
||||
|
@ -486,15 +486,15 @@ func ReadMemStatsSlow() (base, slow MemStats) {
|
|||
// Collect per-sizeclass free stats.
|
||||
var smallFree uint64
|
||||
for i := 0; i < _NumSizeClasses; i++ {
|
||||
slow.Frees += uint64(m.smallFreeCount[i])
|
||||
bySize[i].Frees += uint64(m.smallFreeCount[i])
|
||||
bySize[i].Mallocs += uint64(m.smallFreeCount[i])
|
||||
smallFree += uint64(m.smallFreeCount[i]) * uint64(class_to_size[i])
|
||||
slow.Frees += m.smallFreeCount[i]
|
||||
bySize[i].Frees += m.smallFreeCount[i]
|
||||
bySize[i].Mallocs += m.smallFreeCount[i]
|
||||
smallFree += m.smallFreeCount[i] * uint64(class_to_size[i])
|
||||
}
|
||||
slow.Frees += uint64(m.tinyAllocCount) + uint64(m.largeFreeCount)
|
||||
slow.Frees += m.tinyAllocCount + m.largeFreeCount
|
||||
slow.Mallocs += slow.Frees
|
||||
|
||||
slow.TotalAlloc = slow.Alloc + uint64(m.largeFree) + smallFree
|
||||
slow.TotalAlloc = slow.Alloc + m.largeFree + smallFree
|
||||
|
||||
for i := range slow.BySize {
|
||||
slow.BySize[i].Mallocs = bySize[i].Mallocs
|
||||
|
|
|
@ -82,7 +82,7 @@ func TestDirent(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("names[%d] is non-integer %q: %v", i, names[i], err)
|
||||
}
|
||||
if expected := string(strings.Repeat(name[:1], filenameMinSize+ord)); name != expected {
|
||||
if expected := strings.Repeat(name[:1], filenameMinSize+ord); name != expected {
|
||||
t.Errorf("names[%d] is %q (len %d); expected %q (len %d)", i, name, len(name), expected, len(expected))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ func TestCloneTimeNamespace(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
parentTimeNS := string(timens)
|
||||
parentTimeNS := timens
|
||||
childTimeNS := string(out)
|
||||
if childTimeNS == parentTimeNS {
|
||||
t.Fatalf("expected child time namespace to be different from parent time namespace: %s", parentTimeNS)
|
||||
|
@ -717,12 +717,12 @@ func testAmbientCaps(t *testing.T, userns bool) {
|
|||
gid := os.Getgid()
|
||||
cmd.SysProcAttr.UidMappings = []syscall.SysProcIDMap{{
|
||||
ContainerID: int(nobody),
|
||||
HostID: int(uid),
|
||||
HostID: uid,
|
||||
Size: int(1),
|
||||
}}
|
||||
cmd.SysProcAttr.GidMappings = []syscall.SysProcIDMap{{
|
||||
ContainerID: int(nobody),
|
||||
HostID: int(gid),
|
||||
HostID: gid,
|
||||
Size: int(1),
|
||||
}}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ func TestTruncateRound(t *testing.T) {
|
|||
testOne := func(ti, tns, di int64) bool {
|
||||
t.Helper()
|
||||
|
||||
t0 := Unix(ti, int64(tns)).UTC()
|
||||
t0 := Unix(ti, tns).UTC()
|
||||
d := Duration(di)
|
||||
if d < 0 {
|
||||
d = -d
|
||||
|
@ -321,7 +321,7 @@ func TestTruncateRound(t *testing.T) {
|
|||
// The commented out code would round half to even instead of up,
|
||||
// but that makes it time-zone dependent, which is a bit strange.
|
||||
if r > int64(d)/2 || r+r == int64(d) /*&& bq.Bit(0) == 1*/ {
|
||||
t1 = t1.Add(Duration(d))
|
||||
t1 = t1.Add(d)
|
||||
}
|
||||
|
||||
// Check that time.Round works.
|
||||
|
@ -1106,14 +1106,14 @@ var subTests = []struct {
|
|||
{Date(2009, 11, 23, 0, 0, 0, 0, UTC), Date(2009, 11, 24, 0, 0, 0, 0, UTC), -24 * Hour},
|
||||
{Date(2009, 11, 24, 0, 0, 0, 0, UTC), Date(2009, 11, 23, 0, 0, 0, 0, UTC), 24 * Hour},
|
||||
{Date(-2009, 11, 24, 0, 0, 0, 0, UTC), Date(-2009, 11, 23, 0, 0, 0, 0, UTC), 24 * Hour},
|
||||
{Time{}, Date(2109, 11, 23, 0, 0, 0, 0, UTC), Duration(minDuration)},
|
||||
{Date(2109, 11, 23, 0, 0, 0, 0, UTC), Time{}, Duration(maxDuration)},
|
||||
{Time{}, Date(-2109, 11, 23, 0, 0, 0, 0, UTC), Duration(maxDuration)},
|
||||
{Date(-2109, 11, 23, 0, 0, 0, 0, UTC), Time{}, Duration(minDuration)},
|
||||
{Time{}, Date(2109, 11, 23, 0, 0, 0, 0, UTC), minDuration},
|
||||
{Date(2109, 11, 23, 0, 0, 0, 0, UTC), Time{}, maxDuration},
|
||||
{Time{}, Date(-2109, 11, 23, 0, 0, 0, 0, UTC), maxDuration},
|
||||
{Date(-2109, 11, 23, 0, 0, 0, 0, UTC), Time{}, minDuration},
|
||||
{Date(2290, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), 290*365*24*Hour + 71*24*Hour},
|
||||
{Date(2300, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), Duration(maxDuration)},
|
||||
{Date(2300, 1, 1, 0, 0, 0, 0, UTC), Date(2000, 1, 1, 0, 0, 0, 0, UTC), maxDuration},
|
||||
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2290, 1, 1, 0, 0, 0, 0, UTC), -290*365*24*Hour - 71*24*Hour},
|
||||
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2300, 1, 1, 0, 0, 0, 0, UTC), Duration(minDuration)},
|
||||
{Date(2000, 1, 1, 0, 0, 0, 0, UTC), Date(2300, 1, 1, 0, 0, 0, 0, UTC), minDuration},
|
||||
{Date(2311, 11, 26, 02, 16, 47, 63535996, UTC), Date(2019, 8, 16, 2, 29, 30, 268436582, UTC), 9223372036795099414},
|
||||
{MinMonoTime, MaxMonoTime, minDuration},
|
||||
{MaxMonoTime, MinMonoTime, maxDuration},
|
||||
|
@ -1640,7 +1640,7 @@ func TestZeroMonthString(t *testing.T) {
|
|||
|
||||
// Issue 24692: Out of range weekday panics
|
||||
func TestWeekdayString(t *testing.T) {
|
||||
if got, want := Weekday(Tuesday).String(), "Tuesday"; got != want {
|
||||
if got, want := Tuesday.String(), "Tuesday"; got != want {
|
||||
t.Errorf("Tuesday weekday = %q; want %q", got, want)
|
||||
}
|
||||
if got, want := Weekday(14).String(), "%!Weekday(14)"; got != want {
|
||||
|
|
Loading…
Reference in a new issue