forked from nidhidhamnani/markdown-parser
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMarkdownParseTestOld.java
105 lines (90 loc) · 3.4 KB
/
MarkdownParseTestOld.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
105
// 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);
}
@Test
public void thisTestNoLongerFails() {
assertEquals(-1.0 / 12, 11.0 / 12 - 1.0, 0.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());
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());
}
@Test
public void newFailedTest() throws IOException {
ArrayList<String> links = getLinksTester("nestedParenthesisFailure.md");
List<String> expectedLinks = List.of();
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void group2Break() throws IOException {
ArrayList<String> links = getLinksTester("group2-break.md");
List<String> expectedLinks = List.of();
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void test3() throws IOException {
ArrayList<String> links = getLinksTester("one-space-file.md");
List<String> expectedLinks = List.of();
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
}