MCPcopy
hub / github.com/tinylib/msgp / TestRemove

Function TestRemove

msgp/edit_test.go:9–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestRemove(t *testing.T) {
10 var buf bytes.Buffer
11 w := NewWriter(&buf)
12 w.WriteMapHeader(3)
13 w.WriteString("first")
14 w.WriteFloat64(-3.1)
15 w.WriteString("second")
16 w.WriteString("DELETE ME!!!")
17 w.WriteString("third")
18 w.WriteBytes([]byte("blah"))
19 w.Flush()
20
21 raw := Remove("second", buf.Bytes())
22
23 m, _, err := ReadMapStrIntfBytes(raw, nil)
24 if err != nil {
25 t.Fatal(err)
26 }
27 if len(m) != 2 {
28 t.Errorf("expected %d fields; found %d", 2, len(m))
29 }
30 if _, ok := m["first"]; !ok {
31 t.Errorf("field %q not found", "first")
32 }
33 if _, ok := m["third"]; !ok {
34 t.Errorf("field %q not found", "third")
35 }
36 if _, ok := m["second"]; ok {
37 t.Errorf("field %q (deleted field) still present", "second")
38 }
39}
40
41func TestLocate(t *testing.T) {
42 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 8

WriteMapHeaderMethod · 0.95
WriteStringMethod · 0.95
WriteFloat64Method · 0.95
WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
RemoveFunction · 0.85
ReadMapStrIntfBytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…