MCPcopy
hub / github.com/aceld/zinx / TestGet

Function TestGet

zutils/shard_lock_map_test.go:44–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestGet(t *testing.T) {
45 slm := NewShardLockMaps()
46
47 val, ok := slm.Get("user")
48
49 if ok == true {
50 t.Error("ok should be false when item is missing from map.")
51 }
52
53 if val != nil {
54 t.Error("Missing values should return as null.")
55 }
56
57 tony := TestUser{"tony"}
58 slm.Set("tony", tony)
59
60 tmp, ok := slm.Get("tony")
61 if ok == false {
62 t.Error("ok should be true for item stored within the map.")
63 }
64
65 tony, ok = tmp.(TestUser)
66 if !ok {
67 t.Error("expecting an element, not null.")
68 }
69
70 if tony.name != "tony" {
71 t.Error("item was modified.")
72 }
73
74}
75
76func TestHas(t *testing.T) {
77 slm := NewShardLockMaps()

Callers

nothing calls this directly

Calls 4

GetMethod · 0.95
SetMethod · 0.95
NewShardLockMapsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected