forked from ucsd-cse15l-w22/markdown-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MarkdownParseTest.java
104 lines (92 loc) · 3.64 KB
/
MarkdownParseTest.java
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
103
104
import static org.junit.Assert.*;
import org.junit.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class MarkdownParseTest {
@Test
public void addition() {
assertEquals(2, 1 + 1);
}
// Testing
@Test
public void testGetLinks() throws IOException {
Path fileName = Path.of("./assets/test-file.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of("https://something.com", "some-page.html");
assertEquals(realLinks, links);
}
@Test
public void testGetLinksBreaking() throws IOException {
Path fileName = Path.of("./assets/breaking_tests.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of("https://google.com/(())a()shd", "https://something()test()");
assertEquals(realLinks, links);
}
@Test
public void testGetLinks2() throws IOException {
Path fileName = Path.of("./assets/test-file2.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of("https://something.com", "some-page.html");
assertEquals(realLinks, links);
}
@Test
public void testGetLinks3() throws IOException {
Path fileName = Path.of("./assets/test-file3.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of();
assertEquals(realLinks, links);
}
@Test
public void testGetLinks4() throws IOException {
Path fileName = Path.of("./assets/test-file4.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of();
assertEquals(realLinks, links);
}
@Test
public void testGetLinks5() throws IOException {
Path fileName = Path.of("./assets/test-file5.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of();
assertEquals(realLinks, links);
}
@Test
public void testGetLinks6() throws IOException {
Path fileName = Path.of("./assets/test-file6.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of();
assertEquals(realLinks, links);
}
@Test
public void testGetLinks7() throws IOException {
Path fileName = Path.of("./assets/test-file7.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of();
assertEquals(realLinks, links);
}
@Test
public void testGetLinks8() throws IOException {
Path fileName = Path.of("./assets/test-file8.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
List<String> realLinks = List.of("a link on the first line");
assertEquals(realLinks, links);
}
@Test
public void testNoFile() throws IOException {
// String contents= Files.readString(Path.of("./assets/test-file.md"));
List<String> expect = List.of();
assertEquals(MarkdownParse.getLinks(""), expect);
}
}