MCPcopy
hub / github.com/uber-go/nilaway / TestLoadStore

Function TestLoadStore

util/orderedmap/orderedmap_test.go:28–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestLoadStore(t *testing.T) {
29 t.Parallel()
30
31 // Specify expected k, v pairs.
32 pairs := [][2]int{{1, 2}, {2, 3}, {3, 4}}
33 m := orderedmap.New[int, int]()
34 for _, p := range pairs {
35 k, v := p[0], p[1]
36 m.Store(k, v)
37 loadedV, ok := m.Load(k)
38 require.True(t, ok)
39 require.Equal(t, v, loadedV)
40 require.Equal(t, v, m.Value(k))
41 }
42
43 // Test loading a non-existent key.
44 v, ok := m.Load(-1)
45 require.False(t, ok)
46 require.Empty(t, v)
47 require.Empty(t, m.Value(-1))
48
49 // Test Len.
50 require.Equal(t, len(pairs), len(m.Pairs))
51}
52
53func TestRange(t *testing.T) {
54 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
StoreMethod · 0.80
EmptyMethod · 0.80
ValueMethod · 0.65
LoadMethod · 0.45
TrueMethod · 0.45
EqualMethod · 0.45
FalseMethod · 0.45

Tested by

no test coverage detected