aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/HtmlParserTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/model/HtmlParserTest.java')
-rw-r--r--src/test/model/HtmlParserTest.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/model/HtmlParserTest.java b/src/test/model/HtmlParserTest.java
index 4b05cfb..58b4555 100644
--- a/src/test/model/HtmlParserTest.java
+++ b/src/test/model/HtmlParserTest.java
@@ -7,8 +7,6 @@ import org.junit.jupiter.api.Test;
import java.util.*;
-import static org.junit.jupiter.api.Assertions.*;
-
public class HtmlParserTest {
String idiomaticHtml = "<!DOCTYPE html><html><head></head><body><p>Hello, world!</p></body></html>";
@@ -18,26 +16,31 @@ public class HtmlParserTest {
@Test
void testIdiomaticHtml() {
String[] idiomaticHtmlArray = {"<!DOCTYPE html>","<html>","<head>","</head>","<body>","<p>","Hello,world!","</p>","</body>","</html>"};
- var parsedHtml = HtmlParser.parseHtmlLL(idiomaticHtml);
- displayHtmlTree(parsedHtml);
- System.out.println(HtmlParser.parseHtmlLL(idiomaticHtml));
+ HtmlParser parser = new HtmlParser();
+ displayHtmlTree(parser.parseHtml(idiomaticHtml));
// assertEquals(HtmlParser.parseHtmlLL(idiomaticHtml), Arrays.asList(idiomaticHtmlArray));
}
@Test
void testBrokenHtml() {
String[] brokenHtmlArray = {"<html>","<foo>","<bar>","</bar>","<ba>"};
- System.out.println(HtmlParser.parseHtmlLL(brokenHtml));
+ HtmlParser parser = new HtmlParser();
+ displayHtmlTree(parser.parseHtml(brokenHtml));
// assertEquals(HtmlParser.parseHtmlLL(brokenHtml), Arrays.asList(brokenHtmlArray));
}
@Test
void testTrailingTextHtml() {
String[] trailingTextHtmlArray = {"<html>","<foo>","<bar>","</bar>","ba"};
- System.out.println(HtmlParser.parseHtmlLL(trailingTextHtml));
+ HtmlParser parser = new HtmlParser();
+ displayHtmlTree(parser.parseHtml(trailingTextHtml));
// assertEquals(HtmlParser.parseHtmlLL(trailingTextHtml), Arrays.asList(trailingTextHtmlArray));
}
+ /**
+ * Simple helper function for debugging.
+ * EFFECTS: prints a representation of the tree to the console for debugging purposes
+ */
private void displayHtmlTree(ArrayList<Node> tree) {
for (Node node : tree) {
if (node instanceof ElementNode) {