-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync_test.go
More file actions
47 lines (39 loc) · 928 Bytes
/
Copy pathsync_test.go
File metadata and controls
47 lines (39 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2021-2025, Roman Atachiants
package intmap
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRangeRandomSync(t *testing.T) {
for _, size := range []int{100, 10000, 1000000} {
count := 0
m := sequentialSyncMap(size)
m.Range(func(key, value uint32) bool {
count++
return true
})
assert.Equal(t, m.Count(), count)
}
}
func TestLoadOrStoreLoaded(t *testing.T) {
m := sequentialSyncMap(10)
v, loaded := m.LoadOrStore(1, func() uint32 {
return 1
})
assert.Equal(t, uint32(1), v)
assert.True(t, loaded)
}
func TestLoadOrStoreMissed(t *testing.T) {
m := sequentialSyncMap(10)
v, loaded := m.LoadOrStore(20, func() uint32 {
return 20
})
assert.Equal(t, uint32(20), v)
assert.False(t, loaded)
}
func TestSyncDelete(t *testing.T) {
m := sequentialSyncMap(10)
m.Delete(1)
_, ok := m.Load(1)
assert.False(t, ok)
}