aboutsummaryrefslogtreecommitdiff
path: root/src/test/model/HtmlLexerTest.java
diff options
context:
space:
mode:
authorj-james2022-10-17 06:25:45 +0000
committerj-james2022-10-17 06:27:55 +0000
commit3e9bb5fae16c35938bc1f7f7669c12cc355c9331 (patch)
tree82e1ab837579e7762071ea97c064c0750a38c106 /src/test/model/HtmlLexerTest.java
parent0845be5ec0215fb43f9dbdef00b22a733d4080b3 (diff)
Basic prototypes of HTML/CSS lexers
Diffstat (limited to 'src/test/model/HtmlLexerTest.java')
-rw-r--r--src/test/model/HtmlLexerTest.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/test/model/HtmlLexerTest.java b/src/test/model/HtmlLexerTest.java
new file mode 100644
index 0000000..9dd5574
--- /dev/null
+++ b/src/test/model/HtmlLexerTest.java
@@ -0,0 +1,69 @@
+package model;
+
+import model.html.HtmlLexer;
+
+import org.junit.jupiter.api.*;
+
+import java.util.Arrays;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class HtmlLexerTest {
+ String idiomaticHtml = "<!DOCTYPE html><html><head></head><body><p>Hello,world!</p></body></html>";
+ String brokenHtml = "<html><foo><bar></bar><ba";
+ String trailingTextHtml = "<html><foo><bar></bar>ba";
+
+ @Test
+ void testIdiomaticHtml() {
+ String[] idiomaticHtmlArray = {"<!DOCTYPE html>","<html>","<head>","</head>","<body>","<p>","Hello,world!","</p>","</body>","</html>"};
+ assertEquals(HtmlLexer.lex(idiomaticHtml), Arrays.asList(idiomaticHtmlArray));
+ }
+
+ @Test
+ void testBrokenHtml() {
+ String[] brokenHtmlArray = {"<html>","<foo>","<bar>","</bar>","<ba>"};
+ assertEquals(HtmlLexer.lex(brokenHtml), Arrays.asList(brokenHtmlArray));
+ }
+
+ @Test
+ void testTrailingTextHtml() {
+ String[] trailingTextHtmlArray = {"<html>","<foo>","<bar>","</bar>","ba"};
+ assertEquals(HtmlLexer.lex(trailingTextHtml), Arrays.asList(trailingTextHtmlArray));
+ }
+
+/**
+ FoodServicesCard c1;
+ FoodServicesCard c2;
+ FoodServicesCard c3;
+
+ @BeforeEach
+ void runBefore() {
+ c1 = new FoodServicesCard(0);
+ c2 = new FoodServicesCard(100);
+ c3 = new FoodServicesCard(2000);
+ }
+
+ @Test
+ void testReloadingAndPurchasing() {
+ assertFalse(c1.makePurchase(100));
+ assertEquals(c1.getBalance(), 0);
+ c2.reload(10);
+ assertEquals(c2.getBalance(), 110);
+ assertTrue(c3.makePurchase(1400));
+ assertEquals(c3.getBalance(), 600);
+ }
+
+ @Test
+ void testRewardPoints() {
+ if (c1.makePurchase(c1.POINTS_NEEDED_FOR_CASH_BACK / 2)) {
+ assertEquals(c1.getRewardPoints(), (c1.POINTS_NEEDED_FOR_CASH_BACK / 2));
+ } else {
+ assertEquals(c1.getRewardPoints(), 0);
+ }
+ c2.makePurchase(c2.POINTS_NEEDED_FOR_CASH_BACK);
+ assertEquals(c2.getRewardPoints(), 0);
+ c3.makePurchase(1200);
+ assertEquals(c3.getRewardPoints(), 1200 % c3.POINTS_NEEDED_FOR_CASH_BACK);
+ }
+ */
+} \ No newline at end of file