aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorj-james2022-10-17 13:54:35 +0000
committerj-james2022-10-17 13:54:35 +0000
commitbfa72127cf120f0e98410b45a043b95ad522b729 (patch)
tree877f2a3e38d2a65213794fa0877c84e434c9611b /src/test
parent453372247c8c173c16fa2234b9645bf7a542ed8d (diff)
Sweeping refactor to check CheckStyle boxes
Diffstat (limited to 'src/test')
-rw-r--r--src/test/model/CssParserTest.java3
-rw-r--r--src/test/model/HtmlParserTest.java17
2 files changed, 12 insertions, 8 deletions
diff --git a/src/test/model/CssParserTest.java b/src/test/model/CssParserTest.java
index 2852da5..fa395f6 100644
--- a/src/test/model/CssParserTest.java
+++ b/src/test/model/CssParserTest.java
@@ -10,6 +10,7 @@ public class CssParserTest {
@Test
void testIdiomaticCss() {
var idiomaticCss = "body { background-color: #f0f0f2; margin: 0; padding: 0; font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;}div { width: 600px; margin: 5em auto; padding: 2em; background-color: #fdfdff; border-radius: 0.5em; box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);}a:link, a:visited { color: #38488f; text-decoration: none;}@media (max - width : 700px) { div { margin: 0 auto; width: auto; }}";
- System.out.println(CssParser.parseLL(idiomaticCss));
+ CssParser parser = new CssParser();
+ System.out.println(parser.parseCSS(idiomaticCss));
}
}
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) {