StringFormatterTest.java 715 B

123456789101112131415161718192021222324252627282930
  1. package org.leumasjaffe.format;
  2. import static org.junit.Assert.*;
  3. import org.junit.Test;
  4. import org.leumasjaffe.charsheet.util.StringHelper;
  5. public class StringFormatterTest {
  6. @Test
  7. public void testFormatLiteral() {
  8. assertEquals("{}", new StringFormatter("{{}}").format());
  9. }
  10. @Test
  11. public void testFormatNumbered() {
  12. assertEquals("1,0", new StringFormatter("{1},{0}").format(0, 1));
  13. }
  14. @Test
  15. public void testFormatCondition() {
  16. assertEquals("1", new StringFormatter("{?{}:{}}").format(false, 0, 1));
  17. }
  18. @Test
  19. public void testFormatNumberedCondition() {
  20. assertEquals("0 word + 1 word/2 levels", StringHelper.format("{0} {2} + {1} {2}/{3?level:{4} levels}", 0, 1, "word", false, 2));
  21. }
  22. }