From 062dc779061b2584bb543fbe77aa0995f0329dfa Mon Sep 17 00:00:00 2001 From: Glavo Date: Mon, 30 Dec 2024 00:09:56 +0800 Subject: [PATCH] Update StringSliceTest --- src/test/java/kala/text/StringSliceTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/test/java/kala/text/StringSliceTest.java b/src/test/java/kala/text/StringSliceTest.java index 4348de55..237dcae5 100644 --- a/src/test/java/kala/text/StringSliceTest.java +++ b/src/test/java/kala/text/StringSliceTest.java @@ -50,16 +50,29 @@ void charAtTest() { @Test void graphemes() { String family = "\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66"; - List expected = List.of("a", "b", "c", " ", "你", "好", " ", family); - StringSlice slice = StringSlice.of("abc 你好 " + family); + + var expected = List.of("a", "b", "c", " ", "你", "好", " ", family, "\uD83D\uDE0A"); + var slice = StringSlice.of("abc 你好 " + family + "\uD83D\uDE0A"); + + var expected2 = List.of("b", "c", " ", "你", "好", " ", family, "\uD83D"); + var slice2 = slice.slice(1, ~1); ArrayList result = new ArrayList<>(); + slice.forEachGrapheme(grapheme -> result.add(grapheme.toString())); assertEquals(expected, result); + result.clear(); + slice2.forEachGrapheme(grapheme -> result.add(grapheme.toString())); + assertEquals(expected2, result); + result.clear(); slice.graphemes().forEach(grapheme -> result.add(grapheme.toString())); assertEquals(expected, result); + + result.clear(); + slice2.graphemes().forEach(grapheme -> result.add(grapheme.toString())); + assertEquals(expected2, result); } @Test