FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
FormatInfo fi = new FormatInfo();
@Test public void testMinOnly() { { FormatInfo fi = FormatInfo.valueOf("49"); FormatInfo witness = new FormatInfo(); witness.setMin(49); assertEquals(witness, fi); } { FormatInfo fi = FormatInfo.valueOf("-587"); FormatInfo witness = new FormatInfo(); witness.setMin(587); witness.setLeftPad(false); assertEquals(witness, fi); } }
@Test public void testOptions1() throws Exception { Parser<Object> p = new Parser("%45x{a, b}"); Node t = p.parse(); SimpleKeywordNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); List<String> ol = new ArrayList<String>(); ol.add("a"); ol.add("b"); witness.setOptions(ol); assertEquals(witness, t); }
@Test public void testBasic() { { FormatInfo fi = FormatInfo.valueOf("45"); FormatInfo witness = new FormatInfo(); witness.setMin(45); assertEquals(witness, fi); } { FormatInfo fi = FormatInfo.valueOf("4.5"); FormatInfo witness = new FormatInfo(); witness.setMin(4); witness.setMax(5); assertEquals(witness, fi); } }
@Test public void testOptions0() throws Exception { Parser<Object> p = new Parser("%45x{'test '}"); Node t = p.parse(); SimpleKeywordNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); List<String> ol = new ArrayList<String>(); ol.add("test "); witness.setOptions(ol); assertEquals(witness, t); }
@Test public void testMaxOnly() { { FormatInfo fi = FormatInfo.valueOf(".49"); FormatInfo witness = new FormatInfo(); witness.setMax(49); assertEquals(witness, fi); } { FormatInfo fi = FormatInfo.valueOf(".-5"); FormatInfo witness = new FormatInfo(); witness.setMax(5); witness.setLeftTruncate(false); assertEquals(witness, fi); } } }
@Test public void testLevel() { { DynamicConverter<ILoggingEvent> converter = new LevelConverter(); StringBuilder buf = new StringBuilder(); converter.write(buf, le); assertEquals("INFO", buf.toString()); } { DynamicConverter<ILoggingEvent> converter = new LevelConverter(); converter.setFormattingInfo(new FormatInfo(1, 1, true, false)); StringBuilder buf = new StringBuilder(); converter.write(buf, le); assertEquals("I", buf.toString()); } }
@Test public void testRightPad() { { FormatInfo fi = FormatInfo.valueOf("-40"); FormatInfo witness = new FormatInfo(); witness.setMin(40); witness.setLeftPad(false); assertEquals(witness, fi); } { FormatInfo fi = FormatInfo.valueOf("-12.5"); FormatInfo witness = new FormatInfo(); witness.setMin(12); witness.setMax(5); witness.setLeftPad(false); assertEquals(witness, fi); } { FormatInfo fi = FormatInfo.valueOf("-14.-5"); FormatInfo witness = new FormatInfo(); witness.setMin(14); witness.setMax(5); witness.setLeftPad(false); witness.setLeftTruncate(false); assertEquals(witness, fi); } }
Node t = p.parse(); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(45, Integer.MAX_VALUE)); assertEquals(witness, t); Node t = p.parse(); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5)); assertEquals(witness, t); Node t = p.parse(); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, true)); assertEquals(witness, t); Node t = p.parse(); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, false)); assertEquals(witness, t); Node t = p.parse(); FormattingNode witness = new SimpleKeywordNode("x"); witness.setFormatInfo(new FormatInfo(4, 5, false, true)); Node n = witness.next = new Node(Node.LITERAL, " "); n = n.next = new SimpleKeywordNode("y"); ((FormattingNode) n).setFormatInfo(new FormatInfo(12, Integer.MAX_VALUE)); assertEquals(witness, t);
@Test public void testCompositeFormatting() throws Exception { Parser<Object> p = new Parser("hello%5(XYZ)"); Node t = p.parse(); Node witness = new Node(Node.LITERAL, "hello"); CompositeNode composite = new CompositeNode(BARE); composite.setFormatInfo(new FormatInfo(5, Integer.MAX_VALUE)); Node child = new Node(Node.LITERAL, "XYZ"); composite.setChildNode(child); witness.next = composite; assertEquals(witness, t); }