tpl: Complete coverage for Humanize - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit b3a70abe40ea6acbeb698fb9acaf6055a9e81d63
DIR parent 7c3dceeaedada1f4e7650864d8e23044c6129e46
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 7 Feb 2016 01:45:37 +0100
tpl: Complete coverage for Humanize
Diffstat:
M tpl/template_funcs_test.go | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
---
DIR diff --git a/tpl/template_funcs_test.go b/tpl/template_funcs_test.go
@@ -1523,18 +1523,33 @@ func TestChomp(t *testing.T) {
}
func TestHumanize(t *testing.T) {
- for _, e := range []struct {
- in, exp string
+ for i, this := range []struct {
+ in, expect interface{}
}{
{"MyCamelPost", "My camel post"},
{"myLowerCamelPost", "My lower camel post"},
{"my-dash-post", "My dash post"},
{"my_underscore_post", "My underscore post"},
{"posts/my-first-post", "Posts/my first post"},
+ {tstNoStringer{}, false},
} {
- res, err := Humanize(e.in)
- assert.Nil(t, err)
- assert.Equal(t, e.exp, res)
+
+ result, err := Humanize(this.in)
+
+ if b, ok := this.expect.(bool); ok && !b {
+ if err == nil {
+ t.Errorf("[%d] Humanize didn't return an expected error", i)
+ }
+ } else {
+ if err != nil {
+ t.Errorf("[%d] failed: %s", i, err)
+ continue
+ }
+ if result != this.expect {
+ t.Errorf("[%d] Humanize got %v but expected %v", i, result, this.expect)
+ }
+ }
+
}
}