(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func 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 | |
| 41 | func TestLocate(t *testing.T) { |
| 42 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected
searching dependent graphs…