From b631ab41d9f6cc60fe6b5aac29211b3c8cc78461 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 17 Jul 2016 12:46:48 -0500 Subject: [PATCH] Add test for ST.format Also remove incorrect examples from the documentation of this method. Fixes #113 --- src/org/stringtemplate/v4/ST.java | 2 -- test/org/stringtemplate/v4/test/TestCoreBasics.java | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/stringtemplate/v4/ST.java b/src/org/stringtemplate/v4/ST.java index 38c6d239..2d47d597 100644 --- a/src/org/stringtemplate/v4/ST.java +++ b/src/org/stringtemplate/v4/ST.java @@ -561,9 +561,7 @@ public String toString() { /** *
-	 * ST.format("name, phone | <name>:<phone>", n, p);
 	 * ST.format("<%1>:<%2>", n, p);
-	 * ST.format("<name>:<phone>", "name", x, "phone", y);
 	 * 
*/ public static String format(String template, Object... attributes) { diff --git a/test/org/stringtemplate/v4/test/TestCoreBasics.java b/test/org/stringtemplate/v4/test/TestCoreBasics.java index 32886204..ae33eb49 100644 --- a/test/org/stringtemplate/v4/test/TestCoreBasics.java +++ b/test/org/stringtemplate/v4/test/TestCoreBasics.java @@ -1064,4 +1064,12 @@ public class TestCoreBasics extends BaseTest { st2.add("arg1", "value"); assertEquals("simple template", st2.render()); } + + @Test public void testFormat_PositionalArguments() { + String n = "n"; + String p = "p"; + String expected = "n:p"; + String actual = ST.format("<%1>:<%2>", n, p); + assertEquals(expected, actual); + } }