forked from nidhidhamnani/markdown-parser
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMarkdownParseTest.java
More file actions
54 lines (46 loc) · 1.56 KB
/
Copy pathMarkdownParseTest.java
File metadata and controls
54 lines (46 loc) · 1.56 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
// 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 {
@Test
public void snippet1Test() throws IOException {
ArrayList<String> links = getLinksTester("snippet-1.md");
List<String> expectedLinks = List.of(
"`google.com",
"google.com",
"ucsd.edu"
);
System.out.println(links.toArray());
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void snippet2Test() throws IOException {
ArrayList<String> links = getLinksTester("snippet-2.md");
List<String> expectedLinks = List.of(
"a.com",
"a.com(())",
"example.com"
);
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
@Test
public void snippet3Test() throws IOException {
ArrayList<String> links = getLinksTester("snippet-3.md");
List<String> expectedLinks = List.of(
"https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/schedule"
);
assertArrayEquals(expectedLinks.toArray(), links.toArray());
}
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;
}
}