Add unit test for Toggle italic for last bold + italic in a row of multiple marked elements

Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
Stefan Niedermann 2021-06-25 12:49:33 +02:00
parent 4d7260464c
commit 11d878fac9

View file

@ -98,53 +98,77 @@ public class MarkdownUtilTest extends TestCase {
final Map<String, Boolean> lines = new HashMap<>();
lines.put(" - [ ] a", true);
lines.put(" - [x] a", true);
lines.put(" - [X] a", true);
lines.put(" * [ ] a", true);
lines.put(" * [x] a", true);
lines.put(" * [X] a", true);
lines.put(" + [ ] a", true);
lines.put(" + [x] a", true);
lines.put(" + [X] a", true);
lines.put("- [ ] a", true);
lines.put("- [x] a", true);
lines.put("- [X] a", true);
lines.put("* [ ] a", true);
lines.put("* [x] a", true);
lines.put("* [X] a", true);
lines.put("+ [ ] a", true);
lines.put("+ [x] a", true);
lines.put("+ [X] a", true);
lines.put(" - [ ] ", true);
lines.put(" - [x] ", true);
lines.put(" - [X] ", true);
lines.put(" * [ ] ", true);
lines.put(" * [x] ", true);
lines.put(" * [X] ", true);
lines.put(" + [ ] ", true);
lines.put(" + [x] ", true);
lines.put(" + [X] ", true);
lines.put(" - [ ]", true);
lines.put(" - [x]", true);
lines.put(" - [X]", true);
lines.put(" * [ ]", true);
lines.put(" * [x]", true);
lines.put(" * [X]", true);
lines.put(" + [ ]", true);
lines.put(" + [x]", true);
lines.put(" + [X]", true);
lines.put("- [ ] ", true);
lines.put("- [x] ", true);
lines.put("- [X] ", true);
lines.put("* [ ] ", true);
lines.put("* [x] ", true);
lines.put("* [X] ", true);
lines.put("+ [ ] ", true);
lines.put("+ [x] ", true);
lines.put("+ [X] ", true);
lines.put("- [ ]", true);
lines.put("- [x]", true);
lines.put("- [X]", true);
lines.put("* [ ]", true);
lines.put("* [x]", true);
lines.put("* [X]", true);
lines.put("+ [ ]", true);
lines.put("+ [x]", true);
lines.put("+ [X]", true);
lines.put("-[ ] ", false);
lines.put("-[x] ", false);
lines.put("-[X] ", false);
lines.put("*[ ] ", false);
lines.put("*[x] ", false);
lines.put("*[X] ", false);
lines.put("+[ ] ", false);
lines.put("+[x] ", false);
lines.put("+[X] ", false);
lines.put("-[ ]", false);
lines.put("-[x]", false);
lines.put("-[X]", false);
lines.put("*[ ]", false);
lines.put("*[x]", false);
lines.put("*[X]", false);
lines.put("+[ ]", false);
lines.put("+[x]", false);
lines.put("+[X]", false);
lines.put("- [] ", false);
lines.put("* [] ", false);
@ -331,6 +355,11 @@ public class MarkdownUtilTest extends TestCase {
assertEquals(24, MarkdownUtil.togglePunctuation(builder, 18, 23, "*"));
assertEquals("Lorem **Ipsum** ***Dolor***", builder.toString());
// Toggle italic for last bold + italic in a row of multiple marked elements
builder = new SpannableStringBuilder("Lorem **Ipsum** ***Dolor***");
assertEquals(23, MarkdownUtil.togglePunctuation(builder, 19, 24, "*"));
assertEquals("Lorem **Ipsum** **Dolor**", builder.toString());
// Multiline
builder = new SpannableStringBuilder("**Bold**\nItalic");