mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
change to 2 step: (1): parse to []internal/msg.Element, use msg.ParseObject/msg.ParseString (2): transform to []IMessageElement, can share functions
30 lines
440 B
Go
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)
|
|
}
|
|
}
|
|
}
|