1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00
go-cqhttp/internal/msg/element_test.go
wdvxdr debc1ed1ae coolq: unified string/array message conversion
change to 2 step:
(1): parse to []internal/msg.Element, use msg.ParseObject/msg.ParseString
(2): transform to []IMessageElement, can share functions
2023-02-16 14:51:23 +08:00

30 lines
440 B
Go

package msg
import (
"encoding/json"
"testing"
)
func jsonMarshal(s string) string {
b, err := json.Marshal(s)
if err != nil {
panic(err)
}
return string(b)
}
func TestQuoteJSON(t *testing.T) {
testcase := []string{
"\u0005", // issue 1773
"\v",
}
for _, input := range testcase {
got := QuoteJSON(input)
expected := jsonMarshal(input)
if got != expected {
t.Errorf("want %v but got %v", expected, got)
}
}
}