feat: Add an AI-Proxy Wasm plugin (#921)

Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
Kent Dong
2024-05-14 17:00:12 +08:00
committed by GitHub
parent 5c7736980c
commit 333f9b48f3
21 changed files with 2124 additions and 1 deletions

View 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)
})
}
}