Skip to content

Commit

Permalink
*: use range over int where possible
Browse files Browse the repository at this point in the history
Should have been part of ce6f86d, but IDE
fooled me and did not search test files.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Aug 29, 2024
1 parent 322933b commit b322ea8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions eacl/test/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func baseBenchmarkTableBinaryComparison(b *testing.B, factor int) {
b.StopTimer()
b.ResetTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
for range b.N {
if !bytes.Equal(exp, t.Marshal()) {
b.Fail()
}
Expand All @@ -33,7 +33,7 @@ func baseBenchmarkTableEqualsComparison(b *testing.B, factor int) {
b.StopTimer()
b.ResetTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
for range b.N {
if !eacl.EqualTables(*t, t2) {
b.Fail()
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func TargetN(n int) *eacl.Target {
x.SetRole(eacl.RoleSystem)
keys := make([][]byte, n)

for i := 0; i < n; i++ {
for i := range n {
keys[i] = make([]byte, 32)
//nolint:staticcheck
rand.Read(keys[i])
Expand All @@ -85,7 +85,7 @@ func TargetN(n int) *eacl.Target {
// Record returns random eacl.Record.
func RecordN(n int) *eacl.Record {
fs := make([]eacl.Filter, n)
for i := 0; i < n; i++ {
for i := range n {
fs[i] = eacl.ConstructFilter(eacl.HeaderFromObject, "", eacl.MatchStringEqual, cidtest.ID().EncodeToString())
}

Expand All @@ -95,7 +95,7 @@ func RecordN(n int) *eacl.Record {

func TableN(n int) *eacl.Table {
rs := make([]eacl.Record, n)
for i := 0; i < n; i++ {
for i := range n {
rs[i] = *RecordN(n)
}
x := eacl.NewTableForContainer(cidtest.ID(), rs)
Expand Down
2 changes: 1 addition & 1 deletion pool/pool_aio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func testPoolInterfaceWithAIO(t *testing.T, nodeAddr string) {
})

times := int(opts.sessionExpirationDuration * 3)
for i := 0; i < times; i++ {
for range times {
epoch, err := tickNewEpoch(ctx, pool)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestOneOfTwoFailed(t *testing.T) {

time.Sleep(2 * time.Second)

for i := 0; i < 5; i++ {
for range 5 {
cp, err := pool.connection()
require.NoError(t, err)
require.True(t, assertAuthKeyForAny(cp.address(), nodes))
Expand Down Expand Up @@ -460,7 +460,7 @@ func TestStatusMonitor(t *testing.T) {
monitor.errorThreshold = 3

count := 10
for i := 0; i < count; i++ {
for range count {
monitor.incErrorRate()
}

Expand Down
2 changes: 1 addition & 1 deletion pool/sampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestSamplerStability(t *testing.T) {
for _, tc := range cases {
sampler := newSampler(tc.probabilities, rand.NewSource(0))
res := make([]int, len(tc.probabilities))
for i := 0; i < COUNT; i++ {
for range COUNT {
res[sampler.Next()]++
}

Expand Down
2 changes: 1 addition & 1 deletion stat/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestStatisticConcurrency(t *testing.T) {
go func(c *config) {
defer wg.Done()

for i := 0; i < n; i++ {
for range n {
var err error
if rand.N(2) > 0 {
err = errors.New("some err")
Expand Down

0 comments on commit b322ea8

Please sign in to comment.