Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-01-20 14:07:49 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-01-20 14:07:49 +0300
commita6bf6f52cefc2c81b8a97931d2d49b43e517348f (patch)
treecdc38a6031ba8b23f7a4dc063e84aa631b1abbc0 /tpl
parent42b33102cf619e08c6b6a49a50a0995e8f14773f (diff)
Add tests for Chomp
Diffstat (limited to 'tpl')
-rw-r--r--tpl/template_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/tpl/template_test.go b/tpl/template_test.go
index 159d6cf53..9a726f3fa 100644
--- a/tpl/template_test.go
+++ b/tpl/template_test.go
@@ -9,6 +9,9 @@ import (
"testing"
)
+type tstNoStringer struct {
+}
+
func TestGt(t *testing.T) {
for i, this := range []struct {
left interface{}
@@ -828,6 +831,27 @@ func TestMarkdownify(t *testing.T) {
}
}
+func TestChomp(t *testing.T) {
+ base := "\n This is\na story "
+ for i, item := range []string{
+ "\n",
+ "\r",
+ "\r\n",
+ } {
+ chomped, _ := Chomp(base + item)
+
+ if chomped != base {
+ t.Errorf("[%d] Chomp failed, got '%v'", i, chomped)
+ }
+
+ _, err := Chomp(tstNoStringer{})
+
+ if err == nil {
+ t.Errorf("Chomp should fail")
+ }
+ }
+}
+
func TestSafeHtml(t *testing.T) {
for i, this := range []struct {
str string