(t *testing.T, s string)
| 24 | } |
| 25 | |
| 26 | func testAppendJSONString(t *testing.T, s string) { |
| 27 | expectedResult, err := json.Marshal(s) |
| 28 | if err != nil { |
| 29 | t.Fatalf("unexpected error when encoding string %q: %s", s, err) |
| 30 | } |
| 31 | expectedResult = expectedResult[1 : len(expectedResult)-1] |
| 32 | |
| 33 | bb := AcquireByteBuffer() |
| 34 | bb.B = AppendJSONString(bb.B[:0], s, false) |
| 35 | result := string(bb.B) |
| 36 | ReleaseByteBuffer(bb) |
| 37 | |
| 38 | if strings.Contains(result, "'") { |
| 39 | t.Fatalf("json string shouldn't contain single quote: %q, src %q", result, s) |
| 40 | } |
| 41 | result = strings.Replace(result, `\u0027`, "'", -1) |
| 42 | result = strings.Replace(result, ">", `\u003e`, -1) |
| 43 | if result != string(expectedResult) { |
| 44 | t.Fatalf("unexpected result %q. Expecting %q. original string %q", result, expectedResult, s) |
| 45 | } |
| 46 | } |
no test coverage detected
searching dependent graphs…