forked from nidhidhamnani/markdown-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownParseTest.java
More file actions
144 lines (141 loc) · 4.86 KB
/
MarkdownParseTest.java
File metadata and controls
144 lines (141 loc) · 4.86 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import static org.junit.Assert.*;
import org.junit.*;
import java.util.ArrayList;
import java.beans.Transient;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
//hello
public class MarkdownParseTest {
ArrayList<String> expectedLinks;
ArrayList<String> gottenLinks;
MarkdownParse mrkdwnPrse = new MarkdownParse();
@Before
public void setup()
{
gottenLinks = new ArrayList<String>();
expectedLinks = new ArrayList<String>();
}
@Test
public void addition() {
assertEquals(2, 1 + 1);
}
public ArrayList<String> getGottenLinks (String fileName) throws IOException
{
Path filePath = Path.of(fileName);
String content = Files.readString(filePath);
return mrkdwnPrse.getLinks(content);
}
@Test
public void getLinksTestFile() throws IOException{
expectedLinks.add("https://something.com");
expectedLinks.add("some-thing.html");
gottenLinks = getGottenLinks("test-file.md");
for(int i = 0; i < expectedLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinksbreakingTests() throws IOException{
expectedLinks.add("linkwithaspace.html");
gottenLinks = getGottenLinks("breakingTests.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void testBackticks() throws IOException
{
expectedLinks.add("'google.com");
expectedLinks.add("google.com");
expectedLinks.add("ucsd.edu");
gottenLinks = getGottenLinks("test-backticks.md");
assertEquals(expectedLinks, gottenLinks);
}
@Test
public void testLong() throws IOException
{
expectedLinks.add("https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/schedule");
gottenLinks = getGottenLinks("test-long.md");
assertEquals(expectedLinks, gottenLinks);
}
@Test
public void testNested() throws IOException{
expectedLinks.add("a.com");
expectedLinks.add("a.com(())");
expectedLinks.add("example.com");
gottenLinks = getGottenLinks("test-nestedLinks.md");
assertEquals(expectedLinks, gottenLinks);
}
@Test
public void getLinkTestFile2() throws IOException{
expectedLinks.add("https://something.com");
expectedLinks.add("some-page.html");
gottenLinks = getGottenLinks("test-file2.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile3() throws IOException{
gottenLinks = getGottenLinks("test-file3.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile4() throws IOException{
gottenLinks = getGottenLinks("test-file4.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile5() throws IOException{
gottenLinks = getGottenLinks("test-file5.md");
System.out.println(gottenLinks);
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile6() throws IOException{
gottenLinks = getGottenLinks("test-file6.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile7() throws IOException{
gottenLinks = getGottenLinks("test-file7.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
@Test
public void getLinkTestFile8() throws IOException{
expectedLinks.add("a link on the first line");
gottenLinks = getGottenLinks("test-file8.md");
for(int i = 0; i < gottenLinks.size(); i++)
{
assertEquals(i + "th link didn't match for test-file", expectedLinks.get(i),
gottenLinks.get(i));
}
}
}