BAEL-2536-addressed review comments
This commit is contained in:
parent
693da95f44
commit
082724abec
|
@ -15,10 +15,10 @@ public class Pangram {
|
||||||
Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT];
|
Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT];
|
||||||
Arrays.fill(alphabetMarker, false);
|
Arrays.fill(alphabetMarker, false);
|
||||||
int alphabetIndex = 0;
|
int alphabetIndex = 0;
|
||||||
str = str.toUpperCase();
|
String strUpper = str.toUpperCase();
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
if ('A' <= str.charAt(i) && str.charAt(i) <= 'Z') {
|
if ('A' <= strUpper.charAt(i) && strUpper.charAt(i) <= 'Z') {
|
||||||
alphabetIndex = str.charAt(i) - 'A';
|
alphabetIndex = strUpper.charAt(i) - 'A';
|
||||||
alphabetMarker[alphabetIndex] = true;
|
alphabetMarker[alphabetIndex] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,17 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class PangramUnitTest {
|
public class PangramUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenValidString_isPanagram_shouldReturnSuccess() {
|
public void givenValidString_isPangram_shouldReturnSuccess() {
|
||||||
String input = "Two driven jocks help fax my big quiz";
|
String input = "Two driven jocks help fax my big quiz";
|
||||||
assertTrue(Pangram.isPangram(input));
|
assertTrue(Pangram.isPangram(input));
|
||||||
assertTrue(Pangram.isPangramWithStreams(input));
|
assertTrue(Pangram.isPangramWithStreams(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenNullString_isPanagram_shouldReturnFailure() {
|
public void givenNullString_isPangram_shouldReturnFailure() {
|
||||||
String input = null;
|
String input = null;
|
||||||
assertFalse(Pangram.isPangram(input));
|
assertFalse(Pangram.isPangram(input));
|
||||||
assertFalse(Pangram.isPangramWithStreams(input));
|
assertFalse(Pangram.isPangramWithStreams(input));
|
||||||
|
@ -23,20 +22,20 @@ public class PangramUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() {
|
public void givenPerfectPangramString_isPerfectPangram_shouldReturnSuccess() {
|
||||||
String input = "abcdefghijklmNoPqrStuVwxyz";
|
String input = "abcdefghijklmNoPqrStuVwxyz";
|
||||||
assertTrue(Pangram.isPerfectPangram(input));
|
assertTrue(Pangram.isPerfectPangram(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenNonPanagramString_isPanagram_shouldReturnFailure() {
|
public void givenNonPangramString_isPangram_shouldReturnFailure() {
|
||||||
String input = "invalid panagram";
|
String input = "invalid pangram";
|
||||||
assertFalse(Pangram.isPangram(input));
|
assertFalse(Pangram.isPangram(input));
|
||||||
assertFalse(Pangram.isPangramWithStreams(input));
|
assertFalse(Pangram.isPangramWithStreams(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPanagram_isPerfectPanagram_shouldReturnFailure() {
|
public void givenPangram_isPerfectPangram_shouldReturnFailure() {
|
||||||
String input = "Two driven jocks help fax my big quiz";
|
String input = "Two driven jocks help fax my big quiz";
|
||||||
assertFalse(Pangram.isPerfectPangram(input));
|
assertFalse(Pangram.isPerfectPangram(input));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue