Skip to content

Commit

Permalink
✅ test: add function string4j test #5
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jul 1, 2024
1 parent b114974 commit 2a9ba01
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions plugin/src/test/groovy/org/unify4j/String4jTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.unify4j;

import org.junit.Test;
import org.unify4j.common.String4j;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class String4jTest {

@Test
public void testStripAccents_NullInput() {
assertNull(String4j.stripAccents(null));
}

@Test
public void testStripAccents_EmptyString() {
assertEquals("", String4j.stripAccents(""));
}

@Test
public void testStripAccents_NoAccents() {
assertEquals("abcdefg", String4j.stripAccents("abcdefg"));
}

@Test
public void testStripAccents_WithAccents() {
assertEquals("aeiou", String4j.stripAccents("áéíóú"));
assertEquals("aeiou", String4j.stripAccents("àèìòù"));
assertEquals("aeiou", String4j.stripAccents("âêîôû"));
assertEquals("aeiou", String4j.stripAccents("äëïöü"));
}

@Test
public void testStripAccents_MixedCharacters() {
assertEquals("Cafe", String4j.stripAccents("Café"));
assertEquals("Jose", String4j.stripAccents("José"));
assertEquals("Garcon", String4j.stripAccents("Garçon"));
}

@Test
public void testStripAccents_ComplexCharacters() {
assertEquals("Donna", String4j.stripAccents("Dõñna"));
assertEquals("Cu Chulainn", String4j.stripAccents("Cú Chulainn"));
}

@Test
public void testUnAccents_EmptyString() {
assertEquals("", String4j.unAccents(""));
}

@Test
public void testUnAccents_NoNonASCII() {
assertEquals("abcdefg", String4j.unAccents("abcdefg"));
}

@Test
public void testUnAccents_WithAccents() {
assertEquals("aeiou", String4j.unAccents("áéíóú"));
assertEquals("aeiou", String4j.unAccents("àèìòù"));
assertEquals("aeiou", String4j.unAccents("âêîôû"));
assertEquals("aeiou", String4j.unAccents("äëïöü"));
}

@Test
public void testUnAccents_MixedCharacters() {
assertEquals("Cafe", String4j.unAccents("Café"));
assertEquals("Jose", String4j.unAccents("José"));
assertEquals("Garcon", String4j.unAccents("Garçon"));
}

@Test
public void testUnAccents_ComplexCharacters() {
assertEquals("Donna", String4j.unAccents("Dõñna"));
assertEquals("Cu Chulainn", String4j.unAccents("Cú Chulainn"));
}

@Test
public void testUnAccents_WithNonASCII() {
assertEquals("abc123", String4j.unAccents("ábç123"));
assertEquals("Hello World", String4j.unAccents("Hëllö Wörld"));
assertEquals("ASCIIOnly", String4j.unAccents("ASCIIÖnly"));
}

@Test
public void testUnAccents_OnlyNonASCII() {
assertEquals("aeioun", String4j.unAccents("áéíóúñ"));
assertEquals("oau", String4j.unAccents("öäüß"));
assertEquals("cccsz", String4j.unAccents("çćčšž"));
}
}

0 comments on commit 2a9ba01

Please sign in to comment.