mirror of
https://github.com/alibaba/higress.git
synced 2026-05-27 22:27:29 +08:00
feat: Add an AI-Proxy Wasm plugin (#921)
Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
28
plugins/wasm-go/extensions/ai-proxy/util/json_test.go
Normal file
28
plugins/wasm-go/extensions/ai-proxy/util/json_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestEscapeForJsonString(t *testing.T) {
|
||||
var tests = []struct {
|
||||
input, output string
|
||||
}{
|
||||
{"hello", "hello"},
|
||||
{"hello\"world", "hello\\\"world"},
|
||||
{"h\be\vl\tlo\rworld\n", "h\\be\\vl\\tlo\\rworld\\n"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
// t.Run enables running "subtests", one for each
|
||||
// table entry. These are shown separately
|
||||
// when executing `go test -v`.
|
||||
testName := tt.input
|
||||
t.Run(testName, func(t *testing.T) {
|
||||
output := EscapeStringForJson(tt.input)
|
||||
assert.Equal(t, tt.output, output)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user