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
116 lines (97 loc) · 3.57 KB
/
MarkdownParseTest.java
File metadata and controls
116 lines (97 loc) · 3.57 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
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;
public class MarkdownParseTest {
//@Test
public void addition(){
assertEquals(5,3+2);
}
//@Test
public void test_getLink() throws IOException{
String[] args = new String[1];
args[0] = "test-file8.md";
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(content);
String[] expected = new String[1];
expected[0] = "a link on the first line";
//expected[1] = "some-thing.html";
String[] actual = new String[links.size()];
for (int i = 0; i < actual.length; i++){
actual[i] = links.get(i);
}
assertArrayEquals(expected, actual);
}
//@Test
public void failingTest() throws IOException{
String[] args = new String[1];
args[0] = "test5-file.md";
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(content);
String[] expected = new String[1];
expected[0] = "hello.com";
//expected[1] = "some-thing.html";
String[] actual = new String[links.size()];
for (int i = 0; i < actual.length; i++){
actual[i] = links.get(i);
}
assertArrayEquals(expected, actual);
}
@Test
public void test_md1() throws IOException{
String[] args = new String[1];
args[0] = "report-test-1.md";
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(content);
String[] expected = new String[3];
expected[0] = "`google.com";
expected[1] = "google.com";
expected[2] = "ucsd.edu";
String[] actual = new String[links.size()];
for (int i = 0; i < actual.length; i++){
actual[i] = links.get(i);
}
assertArrayEquals(expected, actual);
}
//@Test
public void test_md2() throws IOException{
String[] args = new String[1];
args[0] = "report-test-2.md";
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(content);
String[] expected = new String[4];
expected[0] = "a.com";
expected[1] = "b.com";
expected[2] = "a.com(())";
expected[3] = "example.com";
String[] actual = new String[links.size()];
for (int i = 0; i < actual.length; i++){
actual[i] = links.get(i);
}
assertArrayEquals(expected, actual);
}
//@Test
public void test_md3() throws IOException{
String[] args = new String[1];
args[0] = "report-test-3.md";
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(content);
String[] expected = new String[4];
expected[0] = "https://www.twitter.com";
expected[1] = "https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/scheduleb.com";
expected[2] = "github.com";
expected[3] = "https://cse.ucsd.edu/";
String[] actual = new String[links.size()];
for (int i = 0; i < actual.length; i++){
actual[i] = links.get(i);
}
assertArrayEquals(expected, actual);
}
}