ref: 26856c3b7555d3b1973de2349af7d680d755e58a
parent: 4b1780bf698465688d15d10a22d705f997dc64a5
author: bep <[email protected]>
date: Tue Jan 20 07:23:27 EST 2015
Add tests for Trim
--- a/tpl/template_test.go
+++ b/tpl/template_test.go
@@ -4,6 +4,7 @@
"bytes"
"errors"
"fmt"
+ "github.com/stretchr/testify/assert"
"html/template"
"reflect"
"testing"
@@ -850,6 +851,16 @@
t.Errorf("Chomp should fail")
}
}
+}
+
+func TestTrim(t *testing.T) {
+ v, _ := Trim("1234 my way 13", "123")
+ assert.Equal(t, "4 my way ", v)
+ v, _ = Trim(" my way ", " ")
+ v, _ = Trim(1234, "14")
+ assert.Equal(t, "23", v)
+ _, e := Trim(tstNoStringer{}, " ")
+ assert.NotNil(t, e, "tstNoStringer isn't trimmable")
}
func TestSafeHtml(t *testing.T) {