forked from ucsd-cse15l-w22/markdown-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownParseTest.java
More file actions
131 lines (111 loc) · 4.17 KB
/
MarkdownParseTest.java
File metadata and controls
131 lines (111 loc) · 4.17 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
/*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.List;
public class MarkdownParseTest {
@Test
public void testFile1() throws IOException {
String contents= Files.readString(Path.of("./test-file.md"));
List<String> expect = List.of("https://something.com", "some-page.html");
assertEquals(MarkdownParse.getLinks(contents), expect);
}
@Test
public void testFile2() throws IOException {
String contents= Files.readString(Path.of("./test-file2.md"));
List<String> expect = List.of("https://something.com", "some-page.html");
assertEquals(MarkdownParse.getLinks(contents), expect);
}
@Test
public void testSingleImage() throws IOException {
String contents= Files.readString(Path.of("./test-single-image.md"));
List<String> expect = List.of();
assertEquals(MarkdownParse.getLinks(contents), expect);
}
@Test
public void testLinkAtBeginning() {
String contents= "[link title](a.com)";
List<String> expect = List.of("a.com");
assertEquals(MarkdownParse.getLinks(contents), expect);
}
@Test
public void testSpaceInURL() {
String contents = "[title](space in-url.com)";
List<String> expect = List.of();
assertEquals(MarkdownParse.getLinks(contents), expect);
}
@Test
public void testSpaceAfterParen() {
String contents = "[title]( space-in-url.com)";
List<String> expect = List.of("space-in-url.com");
assertEquals(expect, MarkdownParse.getLinks(contents));
}
@Test
public void testSpaceBeforeParen() {
String contents = "[title] (should-not-count.com)";
List<String> expect = List.of();
assertEquals(MarkdownParse.getLinks(contents), expect);
}
}*/
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);
}
@Test
public void getLinks() throws IOException{
Path fileName = Path.of("./test-file.md");
String contents = Files.readString(fileName);
assertEquals(List.of("https://something.com", "some-page.html"), MarkdownParse.getLinks(contents));
}
@Test
public void getLinks1() throws IOException{
Path fileName = Path.of("./test2-file.md");
String contents = Files.readString(fileName);
assertEquals( List.of("link.com"), MarkdownParse.getLinks(contents));
}
@Test
public void getLinks2() throws IOException{
Path fileName = Path.of("./test3-file.md");
String contents = Files.readString(fileName);
assertEquals(List.of("link.com"), MarkdownParse.getLinks(contents));
}
@Test
public void getLinks3() throws IOException{
Path fileName = Path.of("./test4-file.md");
String contents = Files.readString(fileName);
assertEquals(List.of(), MarkdownParse.getLinks(contents));
}
//markdownParseTest for Snippet1.md
@Test
public void getLinks4() throws IOException{
Path fileName = Path.of("./snippet1.md");
String contents = Files.readString(fileName);
List<String> expect = List.of("`google.com","google.com", "ucsd.edu");
assertEquals(expect, MarkdownParse.getLinks(contents));
}
//markdownParseTest for Snippet2.md
@Test
public void getLinks5() throws IOException{
Path fileName = Path.of("./snippet2.md");
String contents = Files.readString(fileName);
List<String> expect = List.of("a.com","a.com(())","example.com");
assertEquals(expect, MarkdownParse.getLinks(contents));
}
//markdownParseTest for Snippet3.md
@Test
public void getLinks6() throws IOException{
Path fileName = Path.of("./snippet3.md");
String contents = Files.readString(fileName);
List<String> expect = List.of("https://ucsd-cse15l-w22.github.io/");
assertEquals(expect, MarkdownParse.getLinks(contents));
}
}