Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync tests for practice exercise markdown #2615

Merged
merged 3 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ private String parseHeader(String markdown) {
return null;
}

if (count > 6) {
return parseParagraph(markdown);
}

return wrap(markdown.substring(count + 1), "h" + Integer.toString(count));
}

Expand Down
30 changes: 27 additions & 3 deletions exercises/practice/markdown/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[e75c8103-a6b8-45d9-84ad-e68520545f6e]
description = "parses normal text as a paragraph"
Expand All @@ -20,9 +27,26 @@ description = "with h1 header level"
[d0f7a31f-6935-44ac-8a9a-1e8ab16af77f]
description = "with h2 header level"

[9df3f500-0622-4696-81a7-d5babd9b5f49]
description = "with h3 header level"

[50862777-a5e8-42e9-a3b8-4ba6fcd0ed03]
description = "with h4 header level"

[ee1c23ac-4c86-4f2a-8b9c-403548d4ab82]
description = "with h5 header level"

[13b5f410-33f5-44f0-a6a7-cfd4ab74b5d5]
description = "with h6 header level"

[6dca5d10-5c22-4e2a-ac2b-bd6f21e61939]
description = "with h7 header level"
include = false

[81c0c4db-435e-4d77-860d-45afacdad810]
description = "h7 header level is a paragraph"
reimplements = "6dca5d10-5c22-4e2a-ac2b-bd6f21e61939"

[25288a2b-8edc-45db-84cf-0b6c6ee034d6]
description = "unordered lists"

Expand Down
3 changes: 2 additions & 1 deletion exercises/practice/markdown/src/main/java/Markdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ private String parseHeader(String markdown) {
{
count++;
}


if (count > 6) { return "<p>" + markdown + "</p>"; }
if (count == 0) { return null; }

return "<h" + Integer.toString(count) + ">" + markdown.substring(count + 1) + "</h" + Integer.toString(count)+ ">";
Expand Down
36 changes: 36 additions & 0 deletions exercises/practice/markdown/src/test/java/MarkdownTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ public void withH2HeaderLevel() {
assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void withH3HeaderLevel() {
String input = "### This will be an h3";
String expected = "<h3>This will be an h3</h3>";

assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void withH4HeaderLevel() {
String input = "#### This will be an h4";
String expected = "<h4>This will be an h4</h4>";

assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void withH5HeaderLevel() {
String input = "##### This will be an h5";
String expected = "<h5>This will be an h5</h5>";

assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void withH6HeaderLevel() {
Expand All @@ -75,6 +102,15 @@ public void withH6HeaderLevel() {
assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void h7HeaderLevelIsAParagraph() {
String input = "####### This will not be an h7";
String expected = "<p>####### This will not be an h7</p>";

assertThat(markdown.parse(input)).isEqualTo(expected);
}

@Ignore("Remove to run test")
@Test
public void unorderedLists() {
Expand Down