BAEL-5765 - Updating scan a char unit tests (#12751)

* BAEL-5765 Adding scan a char unit tests

* BAEL-5765 updated class name as per the convention

* BAEL-5765 updated test cases naming strategy

* BAEL-5765 updated variable name
This commit is contained in:
Kumar Prabhash Anand 2022-09-23 18:45:58 +02:00 committed by GitHub
parent d5ad2e0ed8
commit c85e6ff506
1 changed files with 6 additions and 6 deletions

View File

@ -9,30 +9,30 @@ import org.junit.jupiter.api.Test;
public class ScanACharacterUnitTest { public class ScanACharacterUnitTest {
// given - input scanner source, no need to scan from console // given - input scanner source, no need to scan from console
String Input = new StringBuilder().append("abc\n") String input = new StringBuilder().append("abc\n")
.append("mno\n") .append("mno\n")
.append("xyz\n") .append("xyz\n")
.toString(); .toString();
@Test @Test
public void givenInputSource_whenScanCharUsingNext_thenOneCharIsRead() { public void givenInputSource_whenScanCharUsingNext_thenOneCharIsRead() {
Scanner sc = new Scanner(Input); Scanner sc = new Scanner(input);
char c = sc.next().charAt(0); char c = sc.next().charAt(0);
assertEquals('a', c); assertEquals('a', c);
} }
@Test @Test
public void givenInputSource_whenScanCharUsingFindInLine_thenOneCharIsRead() { public void givenInputSource_whenScanCharUsingFindInLine_thenOneCharIsRead() {
Scanner sc = new Scanner(Input); Scanner sc = new Scanner(input);
char c = sc.findInLine(".").charAt(0); char c = sc.findInLine(".").charAt(0);
assertEquals('a', c); assertEquals('a', c);
} }
@Test @Test
public void givenInputSource_whenScanCharUsingUseDelimiter_thenOneCharIsRead() { public void givenInputSource_whenScanCharUsingUseDelimiter_thenOneCharIsRead() {
Scanner sc = new Scanner(Input); Scanner sc = new Scanner(input);
String c = sc.useDelimiter("").next(); char c = sc.useDelimiter("").next().charAt(0);
assertEquals("a", c); assertEquals('a', c);
} }
} }