From bfa72127cf120f0e98410b45a043b95ad522b729 Mon Sep 17 00:00:00 2001 From: j-james Date: Mon, 17 Oct 2022 06:54:35 -0700 Subject: Sweeping refactor to check CheckStyle boxes --- src/test/model/CssParserTest.java | 3 ++- src/test/model/HtmlParserTest.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/test') 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 = "

Hello, world!

"; @@ -18,26 +16,31 @@ public class HtmlParserTest { @Test void testIdiomaticHtml() { String[] idiomaticHtmlArray = {"","","","","","

","Hello,world!","

","",""}; - 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 = {"","","","",""}; - 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 = {"","","","","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 tree) { for (Node node : tree) { if (node instanceof ElementNode) { -- cgit v1.2.3-70-g09d2