Add pangram check tests (#3267)

This commit is contained in:
0x3C50
2022-09-15 15:31:11 +02:00
committed by GitHub
parent 8f18b92f6e
commit 9c418ba827
2 changed files with 20 additions and 30 deletions

View File

@ -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"));
}
}