From e93d8f1624b42bddac18c29086bc8e7d84c69f28 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sat, 31 Oct 2015 14:35:21 -0700 Subject: [PATCH] Make test values more readable, add additional test cases. --- block_test.go | 109 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/block_test.go b/block_test.go index 486917c..b33c257 100644 --- a/block_test.go +++ b/block_test.go @@ -14,6 +14,7 @@ package blackfriday import ( + "strings" "testing" ) @@ -1066,10 +1067,13 @@ func TestFencedCodeBlock(t *testing.T) { } func TestFencedCodeInsideBlockquotes(t *testing.T) { + cat := func(s ...string) string { return strings.Join(s, "\n") } var tests = []string{ - "> ```go\n" + - "package moo\n\n" + - "```\n", + cat("> ```go", + "package moo", + "", + "```", + ""), `
package moo
 
@@ -1077,13 +1081,14 @@ func TestFencedCodeInsideBlockquotes(t *testing.T) {
 
`, // ------------------------------------------- - "> foo\n" + - "> \n" + - "> ```go\n" + - "package moo\n" + - "```\n" + - "> \n" + - "> goo.\n", + cat("> foo", + "> ", + "> ```go", + "package moo", + "```", + "> ", + "> goo.", + ""), `

foo

@@ -1094,31 +1099,35 @@ func TestFencedCodeInsideBlockquotes(t *testing.T) {
`, // ------------------------------------------- - "> foo\n" + - "> \n" + - "> quote\n" + - "continues\n" + - "```\n", - "
\n" + - "

foo

\n\n" + - "

quote\n" + - "continues\n" + - "```

\n" + - "
\n", + cat("> foo", + "> ", + "> quote", + "continues", + "```", + ""), + `
+

foo

- "> foo\n" + - "> \n" + - "> ```go\n" + - "package moo\n" + - "```\n" + - "> \n" + - "> goo.\n" + - "> \n" + - "> ```go\n" + - "package zoo\n" + - "```\n" + - "> \n" + - "> woo.\n", +

quote +continues +` + "```" + `

+
+`, + // ------------------------------------------- + cat("> foo", + "> ", + "> ```go", + "package moo", + "```", + "> ", + "> goo.", + "> ", + "> ```go", + "package zoo", + "```", + "> ", + "> woo.", + ""), `

foo

@@ -1134,6 +1143,38 @@ func TestFencedCodeInsideBlockquotes(t *testing.T) {
`, } + + // These 2 alternative forms of blockquoted fenced code blocks should produce same output. + forms := [2]string{ + cat("> plain quoted text", + "> ```fenced", + "code", + " with leading single space correctly preserved", + "okay", + "```", + "> rest of quoted text"), + cat("> plain quoted text", + "> ```fenced", + "> code", + "> with leading single space correctly preserved", + "> okay", + "> ```", + "> rest of quoted text"), + } + want := `
+

plain quoted text

+ +
code
+ with leading single space correctly preserved
+okay
+
+ +

rest of quoted text

+
+` + tests = append(tests, forms[0], want) + tests = append(tests, forms[1], want) + doTestsBlock(t, tests, EXTENSION_FENCED_CODE) }