forked from matthew-d-stringer/markdown-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarkdownParseTest.java
78 lines (67 loc) · 2.47 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
// Imports tools from junit
import static org.junit.Assert.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
// Class definition
public class MarkdownParseTest {
// Defines following function as a Test
@Test
// Method definition
public void addition() {
// Checks that 1+1 = 2
assertEquals(2, 1 + 1);
}
private ArrayList<String> getLinksTester(String fileName) throws IOException {
Path file = Path.of(fileName);
String content = Files.readString(file);
ArrayList<String> links = MarkdownParse.getLinks(content);
return links;
}
@Test
public void testFileTest() throws IOException {
ArrayList<String> links = getLinksTester("test-file.md");
List<String> expectedLinks = List.of(
"https://something.com",
"some-thing.html");
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void breakingFileTest() throws IOException {
ArrayList<String> links = getLinksTester("breaking-file.md");
List<String> expectedLinks = List.of(
"https://something.com",
"some-thing.html");
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void imageBugTester() throws IOException {
ArrayList<String> links = getLinksTester("image-bug.md");
List<String> expectedLinks = List.of(
"https://something.com",
"some-thing.html");
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void spacedLinkTester() throws IOException {
ArrayList<String> links = getLinksTester("spaced-link.md");
List<String> expectedLinks = List.of();
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void noLinksTester() throws IOException {
ArrayList<String> links = getLinksTester("no-links.md");
List<String> expectedLinks = List.of();
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void spacedLinkTester2() throws IOException {
ArrayList<String> links = getLinksTester("spaced-links-with-other-links.md");
List<String> expectedLinks = List.of(
"google.com");
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
}