Skip to content

Commit 0081676

Browse files
authored
Sync tests for practice exercise markdown (exercism#2615)
1 parent 8e2ab27 commit 0081676

4 files changed

Lines changed: 69 additions & 4 deletions

File tree

exercises/practice/markdown/.meta/src/reference/java/Markdown.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ private String parseHeader(String markdown) {
5757
return null;
5858
}
5959

60+
if (count > 6) {
61+
return parseParagraph(markdown);
62+
}
63+
6064
return wrap(markdown.substring(count + 1), "h" + Integer.toString(count));
6165
}
6266

exercises/practice/markdown/.meta/tests.toml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

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

30+
[9df3f500-0622-4696-81a7-d5babd9b5f49]
31+
description = "with h3 header level"
32+
33+
[50862777-a5e8-42e9-a3b8-4ba6fcd0ed03]
34+
description = "with h4 header level"
35+
36+
[ee1c23ac-4c86-4f2a-8b9c-403548d4ab82]
37+
description = "with h5 header level"
38+
2339
[13b5f410-33f5-44f0-a6a7-cfd4ab74b5d5]
2440
description = "with h6 header level"
2541

42+
[6dca5d10-5c22-4e2a-ac2b-bd6f21e61939]
43+
description = "with h7 header level"
44+
include = false
45+
46+
[81c0c4db-435e-4d77-860d-45afacdad810]
47+
description = "h7 header level is a paragraph"
48+
reimplements = "6dca5d10-5c22-4e2a-ac2b-bd6f21e61939"
49+
2650
[25288a2b-8edc-45db-84cf-0b6c6ee034d6]
2751
description = "unordered lists"
2852

exercises/practice/markdown/src/main/java/Markdown.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ private String parseHeader(String markdown) {
4747
{
4848
count++;
4949
}
50-
50+
51+
if (count > 6) { return "<p>" + markdown + "</p>"; }
5152
if (count == 0) { return null; }
5253

5354
return "<h" + Integer.toString(count) + ">" + markdown.substring(count + 1) + "</h" + Integer.toString(count)+ ">";

exercises/practice/markdown/src/test/java/MarkdownTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,33 @@ public void withH2HeaderLevel() {
6666
assertThat(markdown.parse(input)).isEqualTo(expected);
6767
}
6868

69+
@Ignore("Remove to run test")
70+
@Test
71+
public void withH3HeaderLevel() {
72+
String input = "### This will be an h3";
73+
String expected = "<h3>This will be an h3</h3>";
74+
75+
assertThat(markdown.parse(input)).isEqualTo(expected);
76+
}
77+
78+
@Ignore("Remove to run test")
79+
@Test
80+
public void withH4HeaderLevel() {
81+
String input = "#### This will be an h4";
82+
String expected = "<h4>This will be an h4</h4>";
83+
84+
assertThat(markdown.parse(input)).isEqualTo(expected);
85+
}
86+
87+
@Ignore("Remove to run test")
88+
@Test
89+
public void withH5HeaderLevel() {
90+
String input = "##### This will be an h5";
91+
String expected = "<h5>This will be an h5</h5>";
92+
93+
assertThat(markdown.parse(input)).isEqualTo(expected);
94+
}
95+
6996
@Ignore("Remove to run test")
7097
@Test
7198
public void withH6HeaderLevel() {
@@ -75,6 +102,15 @@ public void withH6HeaderLevel() {
75102
assertThat(markdown.parse(input)).isEqualTo(expected);
76103
}
77104

105+
@Ignore("Remove to run test")
106+
@Test
107+
public void h7HeaderLevelIsAParagraph() {
108+
String input = "####### This will not be an h7";
109+
String expected = "<p>####### This will not be an h7</p>";
110+
111+
assertThat(markdown.parse(input)).isEqualTo(expected);
112+
}
113+
78114
@Ignore("Remove to run test")
79115
@Test
80116
public void unorderedLists() {

0 commit comments

Comments
 (0)