From: bep Date: Tue, 10 Mar 2015 22:17:39 +0000 (+0100) Subject: parser: add some frontmatter test cases X-Git-Tag: v0.14~209 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f85d1a7da25fb1d0d6491eabee2860058095fbec;p=brevno-suite%2Fhugo parser: add some frontmatter test cases --- diff --git a/parser/frontmatter.go b/parser/frontmatter.go index 20978670..94bb60bb 100644 --- a/parser/frontmatter.go +++ b/parser/frontmatter.go @@ -128,8 +128,6 @@ func FormatToLeadRune(kind string) rune { 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: diff --git a/parser/frontmatter_test.go b/parser/frontmatter_test.go new file mode 100644 index 00000000..33db0a24 --- /dev/null +++ b/parser/frontmatter_test.go @@ -0,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) + } + } +}