Place the code for BAEL-2876 to java-strings-2 (#6911)
* Add the code for article BAEL-2876 * Move BAEL-2876 from core-java-8-2 to java-strings-2 * Remove ICU from the pom of core-java-8-2 * Replace the char é by its unicode encoding
This commit is contained in:
committed by
maibin
parent
a32176e25b
commit
7eba063308
@@ -0,0 +1,74 @@
|
||||
package com.baeldung.localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.localization.ICUFormat;
|
||||
|
||||
public class ICUFormatUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenInUK_whenAliceSendsNothing_thenCorrectMessage() {
|
||||
assertEquals("Alice has sent you no messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 0 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInUK_whenAliceSendsOneMessage_thenCorrectMessage() {
|
||||
assertEquals("Alice has sent you a message.", ICUFormat.getLabel(Locale.UK, new Object[] { "Alice", "female", 1 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInUK_whenBobSendsSixMessages_thenCorrectMessage() {
|
||||
assertEquals("Bob has sent you 6 messages.", ICUFormat.getLabel(Locale.UK, new Object[] { "Bob", "male", 6 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInItaly_whenAliceSendsNothing_thenCorrectMessage() {
|
||||
assertEquals("Alice non ti ha inviato nessun messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 0 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInItaly_whenAliceSendsOneMessage_thenCorrectMessage() {
|
||||
assertEquals("Alice ti ha inviato un messaggio.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Alice", "female", 1 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInItaly_whenBobSendsSixMessages_thenCorrectMessage() {
|
||||
assertEquals("Bob ti ha inviato 6 messaggi.", ICUFormat.getLabel(Locale.ITALY, new Object[] { "Bob", "male", 6 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInFrance_whenAliceSendsNothing_thenCorrectMessage() {
|
||||
assertEquals("Alice ne vous a envoyé aucun message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 0 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInFrance_whenAliceSendsOneMessage_thenCorrectMessage() {
|
||||
assertEquals("Alice vous a envoyé un message.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Alice", "female", 1 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInFrance_whenBobSendsSixMessages_thenCorrectMessage() {
|
||||
assertEquals("Bob vous a envoyé 6 messages.", ICUFormat.getLabel(Locale.FRANCE, new Object[] { "Bob", "male", 6 }));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenInPoland_whenAliceSendsNothing_thenCorrectMessage() {
|
||||
assertEquals("Alice nie wysłała ci żadnej wiadomości.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 0 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInPoland_whenAliceSendsOneMessage_thenCorrectMessage() {
|
||||
assertEquals("Alice wysłała ci wiadomość.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Alice", "female", 1 }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenInPoland_whenBobSendsSixMessages_thenCorrectMessage() {
|
||||
assertEquals("Bob wysłał ci 6 wiadomości.", ICUFormat.getLabel(Locale.forLanguageTag("pl-PL"), new Object[] { "Bob", "male", 6 }));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user