shithub: hugo

Download patch

ref: f85d1a7da25fb1d0d6491eabee2860058095fbec
parent: c641ffea3af2ab16c6449574ea865f2ef10a448e
author: bep <[email protected]>
date: Tue Mar 10 19:17:39 EDT 2015

parser: add some frontmatter test cases

--- a/parser/frontmatter.go
+++ b/parser/frontmatter.go
@@ -128,8 +128,6 @@
 	switch FormatSanitize(kind) {
 	case "yaml":
 		return rune([]byte(YAML_LEAD)[0])
-	case "toml":
-		return rune([]byte(TOML_LEAD)[0])
 	case "json":
 		return rune([]byte(JSON_LEAD)[0])
 	default:
--- /dev/null
+++ b/parser/frontmatter_test.go
@@ -1,0 +1,25 @@
+package parser
+
+import (
+	"testing"
+)
+
+func TestFormatToLeadRune(t *testing.T) {
+	for i, this := range []struct {
+		kind   string
+		expect rune
+	}{
+		{"yaml", '-'},
+		{"yml", '-'},
+		{"toml", '+'},
+		{"json", '{'},
+		{"js", '{'},
+		{"unknown", '+'},
+	} {
+		result := FormatToLeadRune(this.kind)
+
+		if result != this.expect {
+			t.Errorf("[%d] Got %q but expected %q", i, result, this.expect)
+		}
+	}
+}