Skip to content

Commit f5fc1f1

Browse files
introfogyulian-gaponenko
authored andcommitted
Add tests to LoggerHelperTest
DEVSIX-5628 Autoported commit. Original commit hash: [3e134e7b5]
1 parent c7f0215 commit f5fc1f1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

itext.tests/itext.pdftest.tests/itext/test/LoggerHelperTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ You should have received a copy of the GNU Affero General Public License
2424

2525
namespace iText.Test {
2626
public class LoggerHelperTest : ExtendedITextTest {
27+
[NUnit.Framework.Test]
28+
public virtual void NotEqualMessageWithSimilarStartTest() {
29+
String pattern = "There might be a message: {0} with text.";
30+
String example = "There might be a message: TEMP with text. And add some other text.";
31+
NUnit.Framework.Assert.IsFalse(LogListenerHelper.EqualsMessageByTemplate(example, pattern));
32+
}
33+
34+
[NUnit.Framework.Test]
35+
public virtual void NotEqualMessageWithSimilarEndTest() {
36+
String pattern = "a message: {0} with text.";
37+
String example = "There might be a message: TEMP with text.";
38+
NUnit.Framework.Assert.IsFalse(LogListenerHelper.EqualsMessageByTemplate(example, pattern));
39+
}
40+
2741
[NUnit.Framework.Test]
2842
public virtual void EqualsMessageByTemplate() {
2943
String pattern = "There might be a message: {0}";

itext/itext.pdftest/itext/test/LogListenerHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static bool EqualsMessageByTemplate(string message, string template)
8181
if (template.Contains("{") && template.Contains("}"))
8282
{
8383
String templateWithoutParameters = Regex.Replace(Regex.Escape(template).Replace("''", "'"), "\\\\\\{[0-9]+?\\}", "(.)*?");
84+
templateWithoutParameters = "^" + templateWithoutParameters + "$";
8485
return Regex.IsMatch(message, templateWithoutParameters, RegexOptions.Singleline);
8586
}
8687

0 commit comments

Comments
 (0)