mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
33 lines
488 B
Go
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)
|
|
}
|
|
}
|
|
}
|