1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

coolq/cqcode: add a testcase for quote

May report an empty json message.
This commit is contained in:
wdvxdr 2023-01-31 23:10:30 +08:00
parent 06450c66a2
commit f3da083be9

View File

@ -2,18 +2,31 @@ package cqcode
import (
"bytes"
"encoding/json"
"testing"
)
func TestIssue1733(t *testing.T) {
const (
input = "\u0005"
expected = `"\u0005"`
)
func jsonMarshal(s string) string {
b, err := json.Marshal(s)
if err != nil {
panic(err)
}
return string(b)
}
func Test_quote(t *testing.T) {
testcase := []string{
"\u0005", // issue 1773
"\v",
}
for _, input := range testcase {
var b bytes.Buffer
writeQuote(&b, input)
got := b.String()
expected := jsonMarshal(input)
if got != expected {
t.Errorf("want %v but got %v", expected, got)
}
}
}