File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ func TestMapCreation(t *testing.T) {
19
19
if m .Len () != 0 {
20
20
t .Errorf ("new map should be empty but has %d items." , m .Len ())
21
21
}
22
+
23
+ t .Run ("default size is used when zero is provided" , func (t * testing.T ) {
24
+ m := New [int , int ](0 )
25
+ index := m .metadata .Load ().index
26
+ if len (index ) != defaultSize {
27
+ t .Error ("map index size is not as expected" )
28
+ }
29
+ })
22
30
}
23
31
24
32
func TestOverwrite (t * testing.T ) {
Original file line number Diff line number Diff line change 64
64
func New [K hashable , V any ](size ... uintptr ) * Map [K , V ] {
65
65
m := & Map [K , V ]{listHead : newListHead [K , V ]()}
66
66
m .numItems .Store (0 )
67
- if len (size ) > 0 {
67
+ if len (size ) > 0 && size [ 0 ] != 0 {
68
68
m .allocate (size [0 ])
69
69
} else {
70
70
m .allocate (defaultSize )
You can’t perform that action at this time.
0 commit comments