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 ef83699 [TEXT-178] StringSubstitutor incorrectly removes some escape characters. ef83699 is described below commit ef8369941ed43c2882782574ee7f2e86147be19c Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jul 4 19:49:36 2020 -0400 [TEXT-178] StringSubstitutor incorrectly removes some escape characters. --- .../apache/commons/text/StringSubstitutorTest.java | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java index c353cff..4970755 100644 --- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java +++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java @@ -38,6 +38,7 @@ import org.apache.commons.text.matcher.StringMatcher; import org.apache.commons.text.matcher.StringMatcherFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @@ -223,6 +224,22 @@ public class StringSubstitutorTest { target.getValueDelimiterMatcher().toString()); } + @Test + public void testGetMinVariableLength() throws IOException { + final StringSubstitutor sub = new StringSubstitutor(); + assertEquals(4, sub.getMinVariableLength()); + sub.setVariablePrefix('a'); + assertEquals(3, sub.getMinVariableLength()); + sub.setVariablePrefix("abc"); + assertEquals(5, sub.getMinVariableLength()); + sub.setVariableSuffix("xyz"); + assertEquals(7, sub.getMinVariableLength()); + sub.setVariablePrefix(StringUtils.EMPTY); + sub.setVariableSuffix(StringUtils.EMPTY); + assertEquals(1, sub.getMinVariableLength()); + } + + /** * Tests get set. */ @@ -880,11 +897,6 @@ public class StringSubstitutorTest { doTestNoReplace("${\n}"); doTestNoReplace("${\b}"); doTestNoReplace("${"); - // TODO this looks like a bug since a $ is removed but this is not a variable. - // doTestNoReplace("$${"); - // doTestNoReplace("$${a"); - // doTestNoReplace("$$${"); - // doTestNoReplace("$$${a"); doTestNoReplace("$}"); doTestNoReplace("$$}"); doTestNoReplace("}"); @@ -900,6 +912,18 @@ public class StringSubstitutorTest { } /** + * Tests interpolation with weird boundary patterns. + */ + @Test + @Disabled + public void testReplaceWeirdPattensJiraText178() throws IOException { + doTestNoReplace("$${"); + doTestNoReplace("$${a"); + doTestNoReplace("$$${"); + doTestNoReplace("$$${a"); + } + + /** * Tests protected. */ @Test