github.com/Mrs4s/go-cqhttp@v1.2.0/internal/msg/element_test.go (about)

     1  package msg
     2  
     3  import (
     4  	"encoding/json"
     5  	"testing"
     6  )
     7  
     8  func jsonMarshal(s string) string {
     9  	b, err := json.Marshal(s)
    10  	if err != nil {
    11  		panic(err)
    12  	}
    13  	return string(b)
    14  }
    15  
    16  func TestQuoteJSON(t *testing.T) {
    17  	testcase := []string{
    18  		"\u0005", // issue 1773
    19  		"\v",
    20  	}
    21  
    22  	for _, input := range testcase {
    23  		got := QuoteJSON(input)
    24  		expected := jsonMarshal(input)
    25  		if got != expected {
    26  			t.Errorf("want %v but got %v", expected, got)
    27  		}
    28  	}
    29  }