1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00
go-cqhttp/coolq/cqcode/all_test.go
wdvxdr f3da083be9 coolq/cqcode: add a testcase for quote
May report an empty json message.
2023-01-31 23:10:30 +08:00

33 lines
488 B
Go

package cqcode
import (
"bytes"
"encoding/json"
"testing"
)
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)
}
}
}