(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func 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 | |
| 76 | func TestHas(t *testing.T) { |
| 77 | slm := NewShardLockMaps() |
nothing calls this directly
no test coverage detected