forked from nidhidhamnani/markdown-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParserQuiz.java
58 lines (50 loc) · 1.86 KB
/
ParserQuiz.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
58
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);
}
}