forked from ucsd-cse15l-w22/markdown-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownParseTest.java
More file actions
102 lines (88 loc) · 4.26 KB
/
MarkdownParseTest.java
File metadata and controls
102 lines (88 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import static org.junit.Assert.*;
import org.junit.*;
import java.util.ArrayList;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class MarkdownParseTest {
@Test
public void addition() {
assertEquals(2, 1 + 1);
}
@Test
public void subtraction() {
assertEquals(10, 20-10);
}
@Test
public void testGetLinks1() throws IOException {
String fileContents = Files.readString(Path.of("test3.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertTrue("ArrayList should contain no elements", testOutput.isEmpty());
}
@Test
public void testGetLinks2() throws IOException {
String fileContents = Files.readString(Path.of("test4.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in array", "math18.com", testOutput.get(0));
assertEquals("Array should only contain one element", 1, testOutput.size());
}
@Test
public void testLabReportTest1() throws IOException {
String fileContents = Files.readString(Path.of("lab-report-test-1.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in array", "`google.com", testOutput.get(0));
assertEquals("Check second element in array", "google.com", testOutput.get(1));
assertEquals("Check third element in array", "ucsd.edu", testOutput.get(2));
assertEquals("Array should contain three elements", 3, testOutput.size());
}
@Test
public void testLabReportTest2() throws IOException {
String fileContents = Files.readString(Path.of("lab-report-test-2.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in array", "a.com", testOutput.get(0));
assertEquals("Check second element in array", "a.com(())", testOutput.get(1));
assertEquals("Check third element in array", "example.com", testOutput.get(2));
assertEquals("Array should contain three elements", 3, testOutput.size());
}
@Test
public void testLabReportTest3() throws IOException {
String fileContents = Files.readString(Path.of("lab-report-test-3.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in array", "https://ucsd-cse15l-w22.github.io/", testOutput.get(0));
assertEquals("Array should contain one element", 1, testOutput.size());
}
}
/*import static org.junit.Assert.*;
import org.junit.*;
import java.util.ArrayList;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class MarkdownParseTest {
@Test
public void addition() {
assertEquals(2, 1 + 1);
}
@Test
public void testGetLinks1() throws IOException {
String fileContents = Files.readString(Path.of("/Users/aprilhsu/Documents/GitHub/markdown-parse/test-file.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in ArrayList", "https://something.com", testOutput.get(0));
assertEquals("Check second element in ArrayList", "some-page.html", testOutput.get(1));
assertEquals("ArrayList should only contain two elements", 2, testOutput.size());
}
@Test
public void testGetLinks2() throws IOException {
String fileContents = Files.readString(Path.of("/Users/aprilhsu/Documents/GitHub/markdown-parse/test2.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertEquals("Check first element in ArrayList", "https://so(meth)ing.com", testOutput.get(0));
assertEquals("ArrayList should only contain one element", 1, testOutput.size());
}
@Test
public void testGetLinks3() throws IOException {
String fileContents = Files.readString(Path.of("/Users/aprilhsu/Documents/GitHub/markdown-parse/test3.md"));
ArrayList<String> testOutput = MarkdownParse.getLinks(fileContents.split("\n"));
assertTrue("ArrayList should contain no elements", testOutput.isEmpty());
}
}
*/