Skip to content

Commit 02e8a29

Browse files
ars18wrwiText-CI
authored andcommitted
Optimize jsoup buffer test
There is no need in checking the issue for strings of length equal to 12, 13, ..., n We can check it for a string of length m, where m - is the length for which the issue can be reproduced. The change has been introduced in a view of a test failing on Android (30+ versions) DEVSIX-6565 Autoported commit. Original commit hash: [01507c54e]
1 parent 643869b commit 02e8a29

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/jsoup/parser/ParserItTest.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@ You should have received a copy of the GNU Affero General Public License
2929
namespace iText.StyledXmlParser.Jsoup.Parser {
3030
/// <summary>Longer running Parser tests.</summary>
3131
public class ParserItTest : ExtendedITextTest {
32-
[NUnit.Framework.Test]
3332
public virtual void TestIssue1251() {
3433
// https://github.com/jhy/jsoup/issues/1251
35-
StringBuilder str = new StringBuilder("<a href=\"\"ca");
36-
for (int countSpaces = 0; countSpaces < 100000; countSpaces++) {
37-
try {
38-
iText.StyledXmlParser.Jsoup.Parser.Parser.HtmlParser().SetTrackErrors(1).ParseInput(str.ToString(), "");
39-
}
40-
catch (Exception e) {
41-
throw new AssertionException("failed at length " + str.Length, e);
42-
}
43-
str.Insert(countSpaces, ' ');
34+
String testString = "<a href=\"\"ca";
35+
StringBuilder str = new StringBuilder();
36+
// initial max length of the buffer is 2**15 * 0.75 = 24576
37+
int spacesToReproduceIssue = 24577 - testString.Length;
38+
for (int i = 0; i < spacesToReproduceIssue; i++) {
39+
str.Append(" ");
40+
}
41+
str.Append(testString);
42+
try {
43+
iText.StyledXmlParser.Jsoup.Parser.Parser.HtmlParser().SetTrackErrors(1).ParseInput(str.ToString(), "");
44+
}
45+
catch (Exception e) {
46+
throw new AssertionException("failed at length " + str.Length, e);
4447
}
4548
}
4649

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8029098ff9314fedfed2cadb0408f1a5635b84b5
1+
01507c54e3b0590356f4fdd2417285d6564905ec

0 commit comments

Comments
 (0)