diff options
author | j-james | 2022-10-17 13:54:35 +0000 |
---|---|---|
committer | j-james | 2022-10-17 13:54:35 +0000 |
commit | bfa72127cf120f0e98410b45a043b95ad522b729 (patch) | |
tree | 877f2a3e38d2a65213794fa0877c84e434c9611b /src/test/model/HtmlParserTest.java | |
parent | 453372247c8c173c16fa2234b9645bf7a542ed8d (diff) |
Sweeping refactor to check CheckStyle boxes
Diffstat (limited to 'src/test/model/HtmlParserTest.java')
-rw-r--r-- | src/test/model/HtmlParserTest.java | 17 |
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) { |