diff --git a/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/executor/TemplateRoleSplitterTest.kt b/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/executor/TemplateRoleSplitterTest.kt index 035a3262..ef474bcf 100644 --- a/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/executor/TemplateRoleSplitterTest.kt +++ b/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/executor/TemplateRoleSplitterTest.kt @@ -22,6 +22,38 @@ class TemplateRoleSplitterTest { } + @Test + fun should_splitInputIntoSections() { + // given + val input = "```system```\nYou are a helpful assistant.\n\n```user```\n${'$'}{question}\n" + val expectedSections = mapOf( + "system" to "You are a helpful assistant.\n\n", + "user" to "${'$'}{question}\n\n" + ) + + // when + val sections = TemplateRoleSplitter().split(input) + + // then + assertEquals(expectedSections, sections) + } + + @Test + fun should_handleRemainingContentAfterLastSection() { + // given + val input = "```system```\nYou are a helpful assistant.\n\n```user```\n${'$'}{question}\nRemaining content" + val expectedSections = mapOf( + "system" to "You are a helpful assistant.\n\n", + "user" to "${'$'}{question}\nRemaining content\n" + ) + + // when + val sections = TemplateRoleSplitter().split(input) + + // then + assertEquals(expectedSections, sections) + } + @Test fun `should split input into sections`() { // given diff --git a/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/role/TemplateRoleSplitterTest.kt b/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/role/TemplateRoleSplitterTest.kt deleted file mode 100644 index ff75149a..00000000 --- a/llm-modules/prompt-script/src/test/kotlin/cc/unitmesh/prompt/role/TemplateRoleSplitterTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -package cc.unitmesh.prompt.role; - -import cc.unitmesh.prompt.executor.TemplateRoleSplitter -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.Assertions.assertEquals - -class TemplateRoleSplitterTest { - - @Test - fun should_splitInputIntoSections() { - // given - val input = "```system```\nYou are a helpful assistant.\n\n```user```\n${'$'}{question}\n" - val expectedSections = mapOf( - "system" to "You are a helpful assistant.\n\n", - "user" to "${'$'}{question}\n\n" - ) - - // when - val sections = TemplateRoleSplitter().split(input) - - // then - assertEquals(expectedSections, sections) - } - - @Test - fun should_handleRemainingContentAfterLastSection() { - // given - val input = "```system```\nYou are a helpful assistant.\n\n```user```\n${'$'}{question}\nRemaining content" - val expectedSections = mapOf( - "system" to "You are a helpful assistant.\n\n", - "user" to "${'$'}{question}\nRemaining content\n" - ) - - // when - val sections = TemplateRoleSplitter().split(input) - - // then - assertEquals(expectedSections, sections) - } - - @Test - fun should_handleEmptyInput() { - // given - val input = "" - val expectedSections = emptyMap() - - // when - val sections = TemplateRoleSplitter().split(input) - - // then - assertEquals(expectedSections, sections) - } -} \ No newline at end of file