Skip to content

Commit

Permalink
trnc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmunoz committed Jun 19, 2018
1 parent a697ef5 commit 039a43e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/org/xnap/commons/i18n/I18nTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,38 @@ public void testTrnApostropheWithPlaceholder()
assertEquals("It's friday! Yes it's friday!", i18nEN.trn("It's {0}! Yes it's {0}!", "Foos", 1, "friday"));
}

public void testTrnc()
{
assertEquals("Foo", i18nEN.trnc("ctx", "Foo", "{0} Bars", 1));
assertEquals("{0} Bars", i18nEN.trnc("ctx", "Foo", "{0} Bars", 2));
assertEquals("2 Bars", i18nEN.trnc("ctx", "Foo", "{0} Bars", 2, new Integer(2)));
}

public void testTrnc1()
{
assertEquals("Foo foo ", i18nEN.trnc("ctx", "Foo {0} ", "Foos {0}", 1, "foo"));
}

public void testTrnc2()
{
assertEquals("Foo bar foo", i18nEN.trnc("ctx", "Foo {1} {0}", "Foos", 1, "foo", "bar"));
assertEquals("Foo foo bar", i18nEN.trnc("ctx", "Foo {0} {1}", "Foos", 1, "foo", "bar"));
}

public void testTrnc3()
{
assertEquals("Foo bar baz foo", i18nEN.trnc("ctx", "Foo {1} {2} {0}", "Foos", 1, "foo", "bar", "baz"));
assertEquals("Foo foo bar baz", i18nEN.trnc("ctx", "Foo {0} {1} {2}", "Foos", 1, "foo", "bar", "baz"));
}

public void testTrnc4()
{
assertEquals("Foo bar baz boing foo", i18nEN
.trnc("ctx", "Foo {1} {2} {3} {0}", "Foos", 1, "foo", "bar", "baz", "boing"));
assertEquals("Foo foo bar baz boing", i18nEN
.trnc("ctx", "Foo {0} {1} {2} {3}", "Foos", 1, "foo", "bar", "baz", "boing"));
}

public void testSetEmptyResources()
{
// this should load the empty resource bundle
Expand Down

0 comments on commit 039a43e

Please sign in to comment.