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 e245913 More tests. e245913 is described below commit e245913ff2dec37dbe20c1687a86f0547d773885 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jul 4 19:42:41 2020 -0400 More tests. --- .../apache/commons/text/StringSubstitutorTest.java | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java index 1111d65..c353cff 100644 --- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java +++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java @@ -53,6 +53,7 @@ public class StringSubstitutorTest { private static final String CLASSIC_RESULT = "The quick brown fox jumps over the lazy dog."; private static final String CLASSIC_TEMPLATE = "The ${animal} jumps over the ${target}."; private static final String EMPTY_EXPR = "${}"; + protected Map<String, String> values; private void assertEqualsCharSeq(final CharSequence expected, final CharSequence actual) { @@ -181,7 +182,11 @@ public class StringSubstitutorTest { values = new HashMap<>(); // shortest key and value. values.put("a", "1"); + values.put("aa", "11"); + values.put("aaa", "111"); values.put("b", "2"); + values.put("bb", "22"); + values.put("bbb", "222"); // normal key and value. values.put("animal", ACTUAL_ANIMAL); values.put("target", ACTUAL_TARGET); @@ -660,10 +665,26 @@ public class StringSubstitutorTest { * Tests simple key replace. */ @Test - public void testReplaceSimpleShortest() throws IOException { + public void testReplaceSimpleKeySize1() throws IOException { doTestReplace("1", "${a}", false); } + /** + * Tests simple key replace. + */ + @Test + public void testReplaceSimpleKeySize2() throws IOException { + doTestReplace("11", "${aa}", false); + } + + /** + * Tests simple key replace. + */ + @Test + public void testReplaceSimpleKeySize3() throws IOException { + doTestReplace("111", "${aaa}", false); + } + @Test public void testReplaceTakingCharSequenceReturningNull() { final StringSubstitutor strSubstitutor = new StringSubstitutor((StringLookup) null); @@ -804,7 +825,8 @@ public class StringSubstitutorTest { */ @Test public void testReplaceVariablesCount2() throws IOException { - doTestReplace("12", "${a}${b}", false); + //doTestReplace("12", "${a}${b}", false); + doTestReplace("1122", "${aa}${bb}", false); doTestReplace(ACTUAL_ANIMAL + ACTUAL_ANIMAL, "${animal}${animal}", false); doTestReplace(ACTUAL_TARGET + ACTUAL_TARGET, "${target}${target}", false); doTestReplace(ACTUAL_ANIMAL + ACTUAL_TARGET, "${animal}${target}", false); @@ -816,6 +838,7 @@ public class StringSubstitutorTest { @Test public void testReplaceVariablesCount2NonAdjacent() throws IOException { doTestReplace("1 2", "${a} ${b}", false); + doTestReplace("11 22", "${aa} ${bb}", false); doTestReplace(ACTUAL_ANIMAL + " " + ACTUAL_ANIMAL, "${animal} ${animal}", false); doTestReplace(ACTUAL_ANIMAL + " " + ACTUAL_ANIMAL, "${animal} ${animal}", false); doTestReplace(ACTUAL_ANIMAL + " " + ACTUAL_ANIMAL, "${animal} ${animal}", false); @@ -827,6 +850,7 @@ public class StringSubstitutorTest { @Test public void testReplaceVariablesCount3() throws IOException { doTestReplace("121", "${a}${b}${a}", false); + doTestReplace("112211", "${aa}${bb}${aa}", false); doTestReplace(ACTUAL_ANIMAL + ACTUAL_ANIMAL + ACTUAL_ANIMAL, "${animal}${animal}${animal}", false); doTestReplace(ACTUAL_TARGET + ACTUAL_TARGET + ACTUAL_TARGET, "${target}${target}${target}", false); } @@ -837,6 +861,7 @@ public class StringSubstitutorTest { @Test public void testReplaceVariablesCount3NonAdjacent() throws IOException { doTestReplace("1 2 1", "${a} ${b} ${a}", false); + doTestReplace("11 22 11", "${aa} ${bb} ${aa}", false); doTestReplace(ACTUAL_ANIMAL + " " + ACTUAL_ANIMAL + " " + ACTUAL_ANIMAL, "${animal} ${animal} ${animal}", false); doTestReplace(ACTUAL_TARGET + " " + ACTUAL_TARGET + " " + ACTUAL_TARGET, "${target} ${target} ${target}",