Skip to content

Commit

Permalink
Add test case StringParser
Browse files Browse the repository at this point in the history
  • Loading branch information
hemantDwivedi committed Sep 14, 2023
1 parent a276957 commit 754f90a
Showing 1 changed file with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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;
Expand All @@ -8,8 +11,6 @@

import com.edgechain.lib.openai.parser.StringParser;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
public class StringParserTest {

Expand Down Expand Up @@ -100,31 +101,23 @@ public void StringParser_GetFinalAnswer_ReturnsExpectedValue() {
}

@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();
@DisplayName("Test string parser with multi-thoughts, actions and observation")
public void stringParser_MultiContents_ReturnExpectedValues(){
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 stringParser = new StringParser(input);

String[] thoughts = stringParser.getThoughts();
String[] actions = stringParser.getActions();
String[] observations = stringParser.getObservations();

assertEquals(3, thoughts.length);
assertEquals(3, actions.length);
Expand Down

0 comments on commit 754f90a

Please sign in to comment.