CSE15L

Link to my markdown-parse repository

Link to the one I reviewed in week 7

For Snippet1:

Expected Output:

[url.com, `google.com, google.com, ucsd.edu]

Code in MarkdownParseTest.java:

@Test
    public void getLinksTest_snip1() throws IOException {
        Path fileName = Path.of("test-Snippet1.md");
        String content = Files.readString(fileName);
        List<String> result = List.of("url.com","`google.com","google.com","ucsd.edu");
        assertEquals(result, MarkdownParse.getLinks(content));
    }

For My implementation: The test passed

image

For the Implementation I Reviewed in Week 7: The test failed

image

For Snippet2:

Expected Output:

[a.com, a.com(()), example.com]

Code in MarkdownParseTest.java:

@Test
    public void getLinksTest_snip2() throws IOException {
        Path fileName = Path.of("test-Snippet2.md");
        String content = Files.readString(fileName);
        List<String> result = List.of("a.com","a.com(())","example.com");
        assertEquals(result, MarkdownParse.getLinks(content));
    }

For My implementation: The test failed image

For the Implementation I Reviewed in Week 7: The test failed

image

For Snippet3:

Expected Output:

[https://www.twitter.com, https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/schedule, https://cse.ucsd.edu/]

Code in MarkdownParseTest.java:

@Test
    public void getLinksTest_snip3() throws IOException {
        Path fileName = Path.of("test-Snippet3.md");
        String content = Files.readString(fileName);
        List<String> result = List.of("https://www.twitter.com","https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/schedule","https://cse.ucsd.edu/");
        assertEquals(result, MarkdownParse.getLinks(content));
    }

For My implementation: The test failed image

image

For the Implementation I Reviewed in Week 7: The test failed image

image

Answer the questions:

  1. My program passed the Snippet1 test case.
  2. For snippet2, I think is possible to make it work by a samll edit, we just need to add a if statement to check whether the close parentheses is the last on or not. We just need to consider the first open parentheses and the last close parentheses, and treat all others between them as part of the link.
  3. For snippet3, I don’t think we can fix it within 10 line code, since we need two if statement to check both parentheses and brackets for deciding whether it is the true symbol of the link or it is some text needed to be ignore. And also, we need to edit the code to make it ignore the line breaks.