diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2015-12-19 15:38:28 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2015-12-19 15:38:28 +0100 |
commit | 7a5a52f468618f960c1d77ff14aa2d83621cbcf9 (patch) | |
tree | 77dd7264928bceaf32ff14f67e9ef578ebb91b30 /hugolib/pageCache_test.go | |
parent | f24ffc9c3df30c991b5df6fa0c973d77679bfee5 (diff) |
Clean up the loop counter variables confusion in TestPageCache
See #1601
Diffstat (limited to 'hugolib/pageCache_test.go')
-rw-r--r-- | hugolib/pageCache_test.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/hugolib/pageCache_test.go b/hugolib/pageCache_test.go index 74714d7eb..c760b03ed 100644 --- a/hugolib/pageCache_test.go +++ b/hugolib/pageCache_test.go @@ -37,20 +37,18 @@ func TestPageCache(t *testing.T) { var testPageSets []Pages - var i, j int - - for j = 0; j < 50; j++ { - testPageSets = append(testPageSets, createSortTestPages(j+1)) + for i := 0; i < 50; i++ { + testPageSets = append(testPageSets, createSortTestPages(i+1)) } - for i = 0; i < 100; i++ { + for j := 0; j < 100; j++ { wg.Add(1) - go func(i1, i2 int) { + go func() { defer wg.Done() - for j, pages := range testPageSets { + for k, pages := range testPageSets { l1.Lock() p, c := c1.get("k1", pages, nil) - assert.Equal(t, !atomic.CompareAndSwapUint64(&o1, uint64(j), uint64(j+1)), c) + assert.Equal(t, !atomic.CompareAndSwapUint64(&o1, uint64(k), uint64(k+1)), c) l1.Unlock() p2, c2 := c1.get("k1", p, nil) assert.True(t, c2) @@ -60,14 +58,12 @@ func TestPageCache(t *testing.T) { l2.Lock() p3, c3 := c1.get("k2", pages, changeFirst) - assert.Equal(t, !atomic.CompareAndSwapUint64(&o2, uint64(j), uint64(j+1)), c3) + assert.Equal(t, !atomic.CompareAndSwapUint64(&o2, uint64(k), uint64(k+1)), c3) l2.Unlock() assert.NotNil(t, p3) assert.Equal(t, p3[0].Description, "changed") } - }(i, j) + }() } - wg.Wait() - } |