Files
CLIProxyAPI/internal/translator/common/bytes_test.go
T
Dmitry Rubtsov 613255e0d0 perf(translator): build input and messages arrays in a single pass
- Replaced per-item `sjson.SetRawBytes(out, "input.-1"/"messages.-1", ...)` appends, which reparsed and rewrote the growing output document on every conversation item, causing O(n^2) work on long histories.
- Applied the same approach to both interactions translation directions and the OpenAI Responses to Chat Completions path.
2026-07-15 16:34:47 +06:00

24 lines
576 B
Go

package common
import "testing"
func TestJoinRawArray(t *testing.T) {
tests := []struct {
name string
items [][]byte
want string
}{
{name: "empty", want: "[]"},
{name: "single", items: [][]byte{[]byte(`{"id":1}`)}, want: `[{"id":1}]`},
{name: "multiple", items: [][]byte{[]byte(`{"id":1}`), []byte(`{"id":2}`)}, want: `[{"id":1},{"id":2}]`},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := string(JoinRawArray(test.items)); got != test.want {
t.Fatalf("JoinRawArray() = %s, want %s", got, test.want)
}
})
}
}