From 0081676e3643820161c027f9c0c2ab1b10ce7037 Mon Sep 17 00:00:00 2001 From: Manuel Maxera <95315128+manumafe98@users.noreply.github.com> Date: Mon, 1 Jan 2024 16:10:42 -0300 Subject: [PATCH] Sync tests for practice exercise ``markdown`` (#2615) --- .../.meta/src/reference/java/Markdown.java | 4 +++ exercises/practice/markdown/.meta/tests.toml | 30 ++++++++++++++-- .../markdown/src/main/java/Markdown.java | 3 +- .../markdown/src/test/java/MarkdownTest.java | 36 +++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/exercises/practice/markdown/.meta/src/reference/java/Markdown.java b/exercises/practice/markdown/.meta/src/reference/java/Markdown.java index 7ba2e1a09..284b17efc 100644 --- a/exercises/practice/markdown/.meta/src/reference/java/Markdown.java +++ b/exercises/practice/markdown/.meta/src/reference/java/Markdown.java @@ -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)); } diff --git a/exercises/practice/markdown/.meta/tests.toml b/exercises/practice/markdown/.meta/tests.toml index fecbcf500..28b7baa72 100644 --- a/exercises/practice/markdown/.meta/tests.toml +++ b/exercises/practice/markdown/.meta/tests.toml @@ -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" @@ -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" diff --git a/exercises/practice/markdown/src/main/java/Markdown.java b/exercises/practice/markdown/src/main/java/Markdown.java index db77fb0e7..3ec749d17 100644 --- a/exercises/practice/markdown/src/main/java/Markdown.java +++ b/exercises/practice/markdown/src/main/java/Markdown.java @@ -47,7 +47,8 @@ private String parseHeader(String markdown) { { count++; } - + + if (count > 6) { return "
" + markdown + "
"; } if (count == 0) { return null; } return "####### This will not be an h7
"; + + assertThat(markdown.parse(input)).isEqualTo(expected); + } + @Ignore("Remove to run test") @Test public void unorderedLists() {