BAEL-2536-addressed review comments

This commit is contained in:
Varun Jain 2019-01-05 10:38:13 +05:30
parent 693da95f44
commit 082724abec
2 changed files with 17 additions and 18 deletions

View File

@ -15,10 +15,10 @@ public class Pangram {
Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT];
Arrays.fill(alphabetMarker, false);
int alphabetIndex = 0;
str = str.toUpperCase();
String strUpper = str.toUpperCase();
for (int i = 0; i < str.length(); i++) {
if ('A' <= str.charAt(i) && str.charAt(i) <= 'Z') {
alphabetIndex = str.charAt(i) - 'A';
if ('A' <= strUpper.charAt(i) && strUpper.charAt(i) <= 'Z') {
alphabetIndex = strUpper.charAt(i) - 'A';
alphabetMarker[alphabetIndex] = true;
}
}

View File

@ -4,39 +4,38 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class PangramUnitTest {
@Test
public void givenValidString_isPanagram_shouldReturnSuccess() {
public void givenValidString_isPangram_shouldReturnSuccess() {
String input = "Two driven jocks help fax my big quiz";
assertTrue(Pangram.isPangram(input));
assertTrue(Pangram.isPangramWithStreams(input));
assertTrue(Pangram.isPangram(input));
assertTrue(Pangram.isPangramWithStreams(input));
}
@Test
public void givenNullString_isPanagram_shouldReturnFailure() {
public void givenNullString_isPangram_shouldReturnFailure() {
String input = null;
assertFalse(Pangram.isPangram(input));
assertFalse(Pangram.isPangramWithStreams(input));
assertFalse(Pangram.isPerfectPangram(input));
}
@Test
public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() {
public void givenPerfectPangramString_isPerfectPangram_shouldReturnSuccess() {
String input = "abcdefghijklmNoPqrStuVwxyz";
assertTrue(Pangram.isPerfectPangram(input));
assertTrue(Pangram.isPerfectPangram(input));
}
@Test
public void givenNonPanagramString_isPanagram_shouldReturnFailure() {
String input = "invalid panagram";
public void givenNonPangramString_isPangram_shouldReturnFailure() {
String input = "invalid pangram";
assertFalse(Pangram.isPangram(input));
assertFalse(Pangram.isPangramWithStreams(input));
}
@Test
public void givenPanagram_isPerfectPanagram_shouldReturnFailure() {
public void givenPangram_isPerfectPangram_shouldReturnFailure() {
String input = "Two driven jocks help fax my big quiz";
assertFalse(Pangram.isPerfectPangram(input));
}