You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2026/10/09 04:25:44 UTC
(rocketmq-dashboard) branch rocketmq-studio updated: test(ai): cover the surrogate split the title cap comment claimed (#5752)
This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new 504e29078 test(ai): cover the surrogate split the title cap comment claimed (#5752)
504e29078 is described below
commit 504e29078ae1c921c825ba1e2cf8122183f7eeae
Author: lizhimins <70...@qq.com>
AuthorDate: Fri Oct 9 12:25:38 2026 +0800
test(ai): cover the surrogate split the title cap comment claimed (#5752)
---
.../studio/ops/ai/conversation/AiConversationServiceTest.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/server/src/test/java/org/apache/rocketmq/studio/ops/ai/conversation/AiConversationServiceTest.java b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/conversation/AiConversationServiceTest.java
index 61d51ee21..926657b1f 100644
--- a/server/src/test/java/org/apache/rocketmq/studio/ops/ai/conversation/AiConversationServiceTest.java
+++ b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/conversation/AiConversationServiceTest.java
@@ -243,10 +243,16 @@ class AiConversationServiceTest {
@Test
void capTitleShouldCutOnCodePointBoundariesTest() {
String emoji = String.valueOf(Character.toChars(0x1F600));
- // 512 code points of emoji-bearing text; the old 512-UTF-16-unit cut split the last emoji.
+ // 32 x (15 y + 1 emoji) fills the 512-code-point budget exactly, but it is 544 UTF-16
+ // units, so the old unit-based cut stopped after 30 groups plus two y's: it lost code
+ // points here rather than splitting an emoji. The next case covers the split itself.
String mixed = ("y".repeat(15) + emoji).repeat(32);
assertThat(AiConversationService.capTitle(mixed + emoji + "z".repeat(600)))
.isEqualTo(mixed);
+ // A three-unit period puts the old 512-unit cut in the middle of a surrogate pair
+ // (512 = 3 x 170 + 2); the cap must drop the whole character instead of storing half of one.
+ assertThat(AiConversationService.capTitle(("y" + emoji).repeat(300)))
+ .isEqualTo(("y" + emoji).repeat(256));
// 511 ASCII characters plus one emoji is exactly the 512-code-point budget; appending one
// more emoji must drop it whole instead of leaving half a surrogate pair behind.
assertThat(AiConversationService.capTitle("y".repeat(511) + emoji + emoji))