package org.leumasjaffe.format; import static org.junit.Assert.*; import org.junit.Test; import org.leumasjaffe.charsheet.util.StringHelper; public class StringFormatterTest { @Test public void testFormatLiteral() { assertEquals("{}", new StringFormatter("{{}}").format()); } @Test public void testFormatNumbered() { assertEquals("1,0", new StringFormatter("{1},{0}").format(0, 1)); } @Test public void testFormatCondition() { assertEquals("1", new StringFormatter("{?{}:{}}").format(false, 0, 1)); } @Test public void testFormatNumberedCondition() { assertEquals("0 word + 1 word/2 levels", StringHelper.format("{0} {2} + {1} {2}/{3?level:{4} levels}", 0, 1, "word", false, 2)); } @Test public void testFormatIntegerCompareCondition() { assertEquals("true", StringHelper.format("{>1?true:false}", 2)); } }