diff --git a/FlySpring/edgechain-app/src/test/java/com/edgechain/parser/StringParserTest.java b/FlySpring/edgechain-app/src/test/java/com/edgechain/parser/StringParserTest.java index e7f4162ad..1f0d2e211 100644 --- a/FlySpring/edgechain-app/src/test/java/com/edgechain/parser/StringParserTest.java +++ b/FlySpring/edgechain-app/src/test/java/com/edgechain/parser/StringParserTest.java @@ -1,8 +1,5 @@ package com.edgechain.parser; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -11,6 +8,8 @@ import com.edgechain.lib.openai.parser.StringParser; +import static org.junit.jupiter.api.Assertions.*; + @SpringBootTest public class StringParserTest { @@ -99,4 +98,36 @@ public void StringParser_GetFinalAnswer_ReturnsExpectedValue() { assertNotNull(finalAnswer); assertEquals("Final Answer", finalAnswer); } + + @Test + @DisplayName("Test String parser with empty input") + public void StringParser_EmptyInput_ReturnExpectedValue(){ + String input = ""; + assertThrows(Exception.class, () -> new StringParser(input)); + } + + @Test + @DisplayName("Test string parser with multiple thoughts, actions, and observations") + public void StringParser_MultipleContents_ReturnsExpectedValues() { + String input = + "Thought 1: Lorem ipsum\n" + + "Action 1: [Search: Content for action 1]\n" + + "Observation 1: Some observation\n" + + "Thought 2: Dolor sit amet\n" + + "Action 2: [Search: Content for action 2]\n" + + "Observation 2: Another observation" + + "Thought 3: Dolor sit amet\n" + + "Action 3: [Search: Content for action 2]\n" + + "Observation 3: Another observation"; + + StringParser parser = new StringParser(input); + + String[] thoughts = parser.getThoughts(); + String[] actions = parser.getActions(); + String[] observations = parser.getObservations(); + + assertEquals(3, thoughts.length); + assertEquals(3, actions.length); + assertEquals(3, observations.length); + } }