test: trim surrogate chunk fixtures · openclaw/openclaw@dadcfb5
steipete
·
2026-04-18
·
via Recent Commits to openclaw:main
File tree
2 files changed
lines changed
packages/memory-host-sdk/src/host
2 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|
@@ -368,11 +368,10 @@ describe("chunkMarkdown", () => {
|
368368});
|
369369it("does not break surrogate pairs when splitting long CJK lines", () => {
|
370370// "𠀀" (U+20000) is a surrogate pair: 2 UTF-16 code units per character.
|
371-// A line of 500 such characters = 1000 UTF-16 code units.
|
372-// With tokens=99 (odd), the fine-split must not cut inside a pair.
|
371+// With an odd token budget, the fine-split must not cut inside a pair.
|
373372const surrogateChar = "\u{20000}"; // 𠀀
|
374-const longLine = surrogateChar.repeat(500);
|
375-const chunks = chunkMarkdown(longLine, { tokens: 99, overlap: 0 });
|
373+const longLine = surrogateChar.repeat(120);
|
374+const chunks = chunkMarkdown(longLine, { tokens: 31, overlap: 0 });
|
376375for (const chunk of chunks) {
|
377376// No chunk should contain the Unicode replacement character U+FFFD,
|
378377// which would indicate a broken surrogate pair.
|
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -360,11 +360,10 @@ describe("chunkMarkdown", () => {
|
360360});
|
361361it("does not break surrogate pairs when splitting long CJK lines", () => {
|
362362// "𠀀" (U+20000) is a surrogate pair: 2 UTF-16 code units per character.
|
363-// A line of 500 such characters = 1000 UTF-16 code units.
|
364-// With tokens=99 (odd), the fine-split must not cut inside a pair.
|
363+// With an odd token budget, the fine-split must not cut inside a pair.
|
365364const surrogateChar = "\u{20000}"; // 𠀀
|
366-const longLine = surrogateChar.repeat(500);
|
367-const chunks = chunkMarkdown(longLine, { tokens: 99, overlap: 0 });
|
365+const longLine = surrogateChar.repeat(120);
|
366+const chunks = chunkMarkdown(longLine, { tokens: 31, overlap: 0 });
|
368367for (const chunk of chunks) {
|
369368// No chunk should contain the Unicode replacement character U+FFFD,
|
370369// which would indicate a broken surrogate pair.
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。