This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push: new 5986774 More tests. 5986774 is described below commit 59867743362093ab7a569c50affb8693f912d989 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Jun 29 11:48:47 2020 -0400 More tests. --- .../apache/commons/text/StringSubstitutorTest.java | 62 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java index e478bde..3cbe36c 100644 --- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java +++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java @@ -265,8 +265,8 @@ public class StringSubstitutorTest { * Tests when no variable name. */ @Test - public void testReplaceEmptyKeyExtra1() throws IOException { - final String expected = EMPTY_EXPR + " "; + public void testReplaceEmptyKeyExtraFirst() throws IOException { + final String expected = "." + EMPTY_EXPR; assertEquals(expected, replace(new StringSubstitutor(values), expected)); } @@ -274,8 +274,8 @@ public class StringSubstitutorTest { * Tests when no variable name. */ @Test - public void testReplaceEmptyKeyExtra2() throws IOException { - final String expected = " " + EMPTY_EXPR; + public void testReplaceEmptyKeyExtraLast() throws IOException { + final String expected = EMPTY_EXPR + "."; assertEquals(expected, replace(new StringSubstitutor(values), expected)); } @@ -620,6 +620,60 @@ public class StringSubstitutorTest { } /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownKeyOnly() throws IOException { + final String expected = "${person}"; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownKeyOnlyExtraFirst() throws IOException { + final String expected = ".${person}"; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownKeyOnlyExtraLast() throws IOException { + final String expected = "${person}."; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownShortestKeyOnly() throws IOException { + final String expected = "${U}"; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownShortestKeyOnlyExtraFirst() throws IOException { + final String expected = ".${U}"; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** + * Tests unknown key replace. + */ + @Test + public void testReplaceUnknownShortestKeyOnlyExtraLast() throws IOException { + final String expected = "${U}."; + assertEquals(expected, replace(new StringSubstitutor(values), expected)); + } + + /** * Tests interpolation with weird boundary patterns. */ @Test