BAEL-4301

- Updated assertTrue to assertEqual
- Added examples
This commit is contained in:
unknown 2020-12-30 13:32:07 +05:30
parent 7bb2282d24
commit 1cc511ae5e
2 changed files with 28 additions and 6 deletions

View File

@ -3,35 +3,36 @@ package com.baeldung.character;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
public class CharacterGeneralCategoryTypeUnitTest { public class CharacterGeneralCategoryTypeUnitTest {
@Test @Test
public void givenACharacter_whenUpperCaseLetter_thenAssertTrue() { public void givenACharacter_whenUpperCaseLetter_thenAssertTrue() {
assertTrue(Character.getType('U') == Character.UPPERCASE_LETTER); assertEquals(Character.UPPERCASE_LETTER, Character.getType('U'));
} }
@Test @Test
public void givenACharacter_whenLowerCaseLetter_thenAssertTrue() { public void givenACharacter_whenLowerCaseLetter_thenAssertTrue() {
assertTrue(Character.getType('u') == Character.LOWERCASE_LETTER); assertEquals(Character.LOWERCASE_LETTER, Character.getType('u'));
} }
@Test @Test
public void givenACharacter_whenTitleCaseLetter_thenAssertTrue() { public void givenACharacter_whenTitleCaseLetter_thenAssertTrue() {
assertTrue(Character.getType('\u01f2') == Character.TITLECASE_LETTER); assertEquals(Character.TITLECASE_LETTER, Character.getType('\u01f2'));
} }
@Test @Test
public void givenACharacter_whenModifierLetter_thenAssertTrue() { public void givenACharacter_whenModifierLetter_thenAssertTrue() {
assertTrue(Character.getType('\u02b0') == Character.MODIFIER_LETTER); assertEquals(Character.MODIFIER_LETTER, Character.getType('\u02b0'));
} }
@Test @Test
public void givenACharacter_whenOtherLetter_thenAssertTrue() { public void givenACharacter_whenOtherLetter_thenAssertTrue() {
assertTrue(Character.getType('\u05d0') == Character.OTHER_LETTER); assertEquals(Character.OTHER_LETTER, Character.getType('\u05d0'));
} }
@Test @Test
public void givenACharacter_whenLetterNumber_thenAssertTrue() { public void givenACharacter_whenLetterNumber_thenAssertTrue() {
assertTrue(Character.getType('\u2164') == Character.LETTER_NUMBER); assertEquals(Character.LETTER_NUMBER, Character.getType('\u2164'));
} }
} }

View File

@ -6,6 +6,27 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
public class IsLetterOrAlphabetUnitTest { public class IsLetterOrAlphabetUnitTest {
@Test
public void givenACharacter_whenUpperCaseLetter_thenAssertIsAlphabeticTrue() {
assertTrue(Character.isAlphabetic('A'));
}
@Test
public void givenACharacter_whenTitleCaseLetter_thenAssertIsAlphabeticTrue() {
assertTrue(Character.isAlphabetic('\u01f2'));
}
@Test
public void givenACharacter_whenLowerCaseLetter_thenAssertIsLetterTrue() {
assertTrue(Character.isAlphabetic('a'));
}
@Test
public void givenACharacter_whenModifierLetter_thenAssertIsLetterTrue() {
assertTrue(Character.isAlphabetic('\u02b0'));
}
@Test @Test
public void givenACharacter_whenLetter_thenAssertIsLetterTrue() { public void givenACharacter_whenLetter_thenAssertIsLetterTrue() {
assertTrue(Character.isLetter('a')); assertTrue(Character.isLetter('a'));