forked from ucsd-cse15l-w22/markdown-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MarkdownParseTest.java
57 lines (55 loc) · 2.16 KB
/
MarkdownParseTest.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
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 testNewFile() throws IOException {
Path fileName = Path.of("test-file.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test the links from test-file.md", List.of("https://something.com", "some-page.html"), links);
}
@Test
public void testImageFile() throws IOException {
Path fileName = Path.of("new-file.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test links from new-file.md", List.of("google.com"), links);
}
@Test
public void testNoParen() throws IOException {
Path fileName = Path.of("no-paren.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test links from no-paren.md", List.of(), links);
}
@Test
public void testLinkFirst() throws IOException {
Path fileName = Path.of("link-first.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test links from link-first.md", List.of("firstline.com"), links);
}
@Test
public void testFormat2() throws IOException {
Path fileName = Path.of("testformat2.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test links from testformat2.md", List.of(), links);
}
@Test
public void testVim() throws IOException {
Path fileName = Path.of("testformat2.md");
String contents = Files.readString(fileName);
ArrayList<String> links = MarkdownParse.getLinks(contents);
assertEquals("Test links from testformat2.md (vim version)", List.of(), links);
}
}