-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f574478
commit 95753ae
Showing
3 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/test/java/bugs/stackoverflow/belisarius/filters/TextRemovedFilterTest.Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package bugs.stackoverflow.belisarius.filters; | ||
|
||
import java.io.IOException; | ||
|
||
import bugs.stackoverflow.belisarius.models.Post; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class RepeatedWordFilterTest { | ||
@Test | ||
public void hitTest() throws IOException { | ||
Post post1 = FilterTestUtils.getSamplePost( | ||
"<p>This is a normal edit to my question</p>", | ||
"<p>This is my question</p>", | ||
"title", | ||
null, | ||
"added some important info", | ||
"question" | ||
); | ||
|
||
// https://higgs.sobotics.org/Hippo/report/84303 | ||
Post post2 = FilterTestUtils.getSamplePost( | ||
"This text has nothing to do with the above one.", | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, " | ||
+ "sed do eiusmod tempor incididunt ut labore et dolore magna " | ||
+ "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " | ||
+ "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis " | ||
+ "aute irure dolor in reprehenderit in voluptate velit esse cillum " | ||
+ "dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat " | ||
+ "non proident, sunt in culpa qui officia deserunt mollit anim id " | ||
+ "est laborum.", | ||
"Does this code work?", | ||
null, | ||
"deleted 169 characters in body", | ||
"answer" | ||
); | ||
|
||
Post post3 = FilterTestUtils.getSamplePost( | ||
"I removed my question", | ||
"<p>" + "This is a valid question no doubt. ".repeat(100) + "</p>", | ||
"How can I do this?", | ||
null, | ||
"deleted my question", | ||
"question" | ||
); | ||
|
||
|
||
assertEquals(new TextRemovedFilter(0, post1).isHit(), false); | ||
assertEquals(new TextRemovedFilter(0, post2).isHit(), true); | ||
|
||
TextRemovedFilter filter3 = new TextRemovedFilter(0, post3); | ||
assertEquals(filter3.isHit(), true); | ||
// total weight is always 1.0 | ||
assertEquals(filter3.getTotalScore(), 1.0); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/test/java/bugs/stackoverflow/belisarius/filters/VeryLongWordFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package bugs.stackoverflow.belisarius.filters; | ||
|
||
import java.io.IOException; | ||
|
||
import bugs.stackoverflow.belisarius.models.Post; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class VeryLongWordFilterTest { | ||
@Test | ||
public void hitTest() throws IOException { | ||
Post post1 = FilterTestUtils.getSamplePost( | ||
"<p>This is my answerwithaveryveryveryveryverylongwordthatwillbecaught</p>", | ||
"<p>This is my answer</p>", | ||
"title", | ||
null, | ||
"added some important info", | ||
"answer" | ||
); | ||
|
||
// very long word already existed | ||
Post post2 = FilterTestUtils.getSamplePost( | ||
"this is my question thisisaveryverylongwordwhichismorethanfiftycharacters", | ||
"thisisaveryverylongwordwhichismorethanfiftycharacters this is my question", | ||
"Does this code work?", | ||
null, | ||
"deleted some characters in body", | ||
"question" | ||
); | ||
|
||
Post post3 = FilterTestUtils.getSamplePost( | ||
"<p>This is my question and thisisnotalongword.</p>", | ||
"<p>This is my question</p>", | ||
"How can I do this?", | ||
null, | ||
"deleted my question", | ||
"question" | ||
); | ||
|
||
// very long word inside HTML tag | ||
Post post4 = FilterTestUtils.getSamplePost( | ||
"<p>This is my question and <code>thisisaveryverylongwordwhichismorethanfiftycharacters</code>.</p>", | ||
"<p>This is my question</p>", | ||
"How can I do this?", | ||
null, | ||
"deleted my question", | ||
"question" | ||
); | ||
|
||
assertEquals(new VeryLongWordFilter(0, post2).isHit(), false); | ||
assertEquals(new VeryLongWordFilter(0, post3).isHit(), false); | ||
assertEquals(new VeryLongWordFilter(0, post4).isHit(), false); | ||
|
||
VeryLongWordFilter filter1 = new VeryLongWordFilter(0, post1); | ||
assertEquals(filter1.isHit(), true); | ||
// total weight is always 1.0 | ||
assertEquals(filter1.getTotalScore(), 1.0); | ||
} | ||
} |