(t *testing.T)
| 134 | } |
| 135 | |
| 136 | func TestLen(t *testing.T) { |
| 137 | t.Run("EmptyMapIsZeroLen", func(t *testing.T) { |
| 138 | m := orderedmap.NewOrderedMap() |
| 139 | assert.Equal(t, 0, m.Len()) |
| 140 | }) |
| 141 | |
| 142 | t.Run("SingleElementIsLenOne", func(t *testing.T) { |
| 143 | m := orderedmap.NewOrderedMap() |
| 144 | m.Set(123, true) |
| 145 | assert.Equal(t, 1, m.Len()) |
| 146 | }) |
| 147 | |
| 148 | t.Run("ThreeElements", func(t *testing.T) { |
| 149 | m := orderedmap.NewOrderedMap() |
| 150 | m.Set(1, true) |
| 151 | m.Set(2, true) |
| 152 | m.Set(3, true) |
| 153 | assert.Equal(t, 3, m.Len()) |
| 154 | }) |
| 155 | |
| 156 | t.Run("Performance", func(t *testing.T) { |
| 157 | if testing.Short() { |
| 158 | t.Skip("performance test skipped in short mode") |
| 159 | } |
| 160 | |
| 161 | res1 := testing.Benchmark(benchmarkOrderedMap_Len(100)) |
| 162 | res4 := testing.Benchmark(benchmarkOrderedMap_Len(400)) |
| 163 | |
| 164 | // O(1) would mean that res4 should take about the same time as res1, |
| 165 | // because we are accessing the same amount of elements, just on |
| 166 | // different sized maps. |
| 167 | |
| 168 | assert.InDelta(t, |
| 169 | res1.NsPerOp(), res4.NsPerOp(), |
| 170 | 0.5*float64(res1.NsPerOp())) |
| 171 | }) |
| 172 | } |
| 173 | |
| 174 | func TestKeys(t *testing.T) { |
| 175 | t.Run("EmptyMap", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…