(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestInternalMap(t *testing.T) { |
| 17 | ctx := testlogging.Context(t) |
| 18 | |
| 19 | impl, err := newInternalMap(ctx) |
| 20 | require.NoError(t, err) |
| 21 | |
| 22 | defer impl.Close(ctx) |
| 23 | |
| 24 | key1 := []byte("key1") |
| 25 | key2 := []byte("longerkey2") |
| 26 | val1 := []byte("val1") |
| 27 | val2 := []byte("val2") |
| 28 | |
| 29 | v, ok := impl.Get(nil, key1) |
| 30 | require.Nil(t, v) |
| 31 | require.False(t, ok) |
| 32 | |
| 33 | impl.PutIfAbsent(ctx, key1, val1) |
| 34 | |
| 35 | v, ok = impl.Get(nil, key1) |
| 36 | require.True(t, ok) |
| 37 | require.Equal(t, val1, v) |
| 38 | |
| 39 | v, ok = impl.Get(nil, key2) |
| 40 | require.Nil(t, v) |
| 41 | require.False(t, ok) |
| 42 | |
| 43 | impl.PutIfAbsent(ctx, key2, val2) |
| 44 | |
| 45 | v, ok = impl.Get(nil, key2) |
| 46 | require.True(t, ok) |
| 47 | require.Equal(t, val2, v) |
| 48 | |
| 49 | v, ok = impl.Get(nil, key1) |
| 50 | require.True(t, ok) |
| 51 | require.Equal(t, val1, v) |
| 52 | } |
| 53 | |
| 54 | func TestGrowingMap(t *testing.T) { |
| 55 | ctx := testlogging.Context(t) |
nothing calls this directly
no test coverage detected