From 8bcdce311d1e5e8d2a3290e29de9a12dfeb32819 Mon Sep 17 00:00:00 2001 From: xiaocairush Date: Sun, 18 Jun 2023 11:10:16 +0800 Subject: [PATCH] =?UTF-8?q?feat;=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/common/algorithm/ac/ACTrieTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mallchat-common/src/test/java/com/abin/mallchat/common/common/algorithm/ac/ACTrieTest.java b/mallchat-common/src/test/java/com/abin/mallchat/common/common/algorithm/ac/ACTrieTest.java index 04da0f7..2fb749f 100644 --- a/mallchat-common/src/test/java/com/abin/mallchat/common/common/algorithm/ac/ACTrieTest.java +++ b/mallchat-common/src/test/java/com/abin/mallchat/common/common/algorithm/ac/ACTrieTest.java @@ -44,6 +44,17 @@ public class ACTrieTest { checkResult(matchResults.get(1), 1, 4, ALPHABET.get(1), text); } + @Test + public void test_VariousKeywordsMultiMatch2() { + final ACTrie trie = trie(ALPHABET); + final String text = "abcde"; + List matchResults = trie.matches(text); + assertEquals(3, matchResults.size()); + checkResult(matchResults.get(0), 0, 3, ALPHABET.get(0), text); + checkResult(matchResults.get(1), 1, 4, ALPHABET.get(1), text); + checkResult(matchResults.get(2), 2, 5, ALPHABET.get(2), text); + } + private void checkResult(MatchResult matchResult, int expectedStart, int expectedEnd, String expectedKeyword, String text) { assertEquals("Start of match should have been " + expectedStart, expectedStart, matchResult.getStartIndex()); assertEquals("End of match should have been " + expectedEnd, expectedEnd, matchResult.getEndIndex());