BAEL-4301
- Created a new module core-java-char in core-java-modules modules - Added Unit Tests for Character#isAlphabetic and Character#isLetter methods
This commit is contained in:
parent
69d7f51947
commit
7bb2282d24
|
@ -0,0 +1,6 @@
|
|||
## Core Java Character
|
||||
|
||||
This module contains articles about Java Character Class
|
||||
|
||||
### Relevant Articles:
|
||||
- Character#isAlphabetic vs Character#isLetter
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-char</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-char</name>
|
||||
<packaging>jar</packaging>
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${openjdk.jmh.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${openjdk.jmh.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
||||
<assertj.version>3.11.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,37 @@
|
|||
package com.baeldung.character;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CharacterGeneralCategoryTypeUnitTest {
|
||||
@Test
|
||||
public void givenACharacter_whenUpperCaseLetter_thenAssertTrue() {
|
||||
assertTrue(Character.getType('U') == Character.UPPERCASE_LETTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenLowerCaseLetter_thenAssertTrue() {
|
||||
assertTrue(Character.getType('u') == Character.LOWERCASE_LETTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenTitleCaseLetter_thenAssertTrue() {
|
||||
assertTrue(Character.getType('\u01f2') == Character.TITLECASE_LETTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenModifierLetter_thenAssertTrue() {
|
||||
assertTrue(Character.getType('\u02b0') == Character.MODIFIER_LETTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenOtherLetter_thenAssertTrue() {
|
||||
assertTrue(Character.getType('\u05d0') == Character.OTHER_LETTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenLetterNumber_thenAssertTrue() {
|
||||
assertTrue(Character.getType('\u2164') == Character.LETTER_NUMBER);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.java14.character;
|
||||
package com.baeldung.character;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -6,25 +6,23 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class IsLetterOrAlphabetUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenLetter_thenAssertIsLetterTrue() {
|
||||
assertTrue(Character.isLetter(65));
|
||||
assertTrue(Character.isLetter('a'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenLetter_thenAssertIsAlphabeticTrue() {
|
||||
assertTrue(Character.isAlphabetic(65));
|
||||
assertTrue(Character.isAlphabetic('a'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenAlphabeticAndNotLetter_thenAssertIsLetterFalse() {
|
||||
assertFalse(Character.isLetter(837));
|
||||
assertFalse(Character.isLetter('\u2164'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenACharacter_whenAlphabeticAndNotLetter_thenAssertIsAlphabeticTrue() {
|
||||
assertTrue(Character.isAlphabetic(837));
|
||||
assertTrue(Character.isAlphabetic('\u2164'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -29,7 +29,8 @@
|
|||
<module>core-java-arrays-convert</module>
|
||||
<module>core-java-arrays-operations-basic</module>
|
||||
<module>core-java-arrays-operations-advanced</module>
|
||||
|
||||
|
||||
<module>core-java-char</module>
|
||||
<module>core-java-collections</module>
|
||||
<module>core-java-collections-2</module>
|
||||
<module>core-java-collections-3</module>
|
||||
|
|
Loading…
Reference in New Issue