mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 14:34:05 +08:00
Add pangram check tests (#3267)
This commit is contained in:
@ -3,22 +3,15 @@ package com.thealgorithms.strings;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static com.thealgorithms.strings.Pangram.isPangram;
|
||||
|
||||
|
||||
public class PangramTest {
|
||||
@Test
|
||||
public void isPangram() {
|
||||
String fullAlphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
String notFullAlphabet = "abcdefghiklmnopqrstuvwxyz";
|
||||
String fullMixedCaseAlphabet = "a BCDE fghIjkLMnop qrSTuv WXYz";
|
||||
String sentence1 = "The quick brown fox jumps over the lazy dog";
|
||||
String sentence2 = "The quick brown fox jumps over the lazy gentleman"; // missing letter d
|
||||
|
||||
assertTrue(Pangram.isPangram(fullAlphabet));
|
||||
assertFalse(Pangram.isPangram(notFullAlphabet));
|
||||
assertTrue(Pangram.isPangram(fullMixedCaseAlphabet));
|
||||
assertTrue(Pangram.isPangram(sentence1));
|
||||
assertFalse(Pangram.isPangram(sentence2));
|
||||
|
||||
public void testPangram() {
|
||||
assertTrue(isPangram("The quick brown fox jumps over the lazy dog"));
|
||||
assertFalse(isPangram("The quick brown fox jumps over the azy dog")); // L is missing
|
||||
assertFalse(isPangram("+-1234 This string is not alphabetical"));
|
||||
assertFalse(isPangram("\u0000/\\ Invalid characters are alright too"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user