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 ( import (
"bytes" "bytes"
"encoding/json"
"testing" "testing"
) )
func TestIssue1733(t *testing.T) { func jsonMarshal(s string) string {
const ( b, err := json.Marshal(s)
input = "\u0005" if err != nil {
expected = `"\u0005"` panic(err)
) }
var b bytes.Buffer return string(b)
writeQuote(&b, input) }
got := b.String()
if got != expected { func Test_quote(t *testing.T) {
t.Errorf("want %v but got %v", expected, got) 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)
}
} }
} }