mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Add tests for Chomp
This commit is contained in:
@@ -9,6 +9,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type tstNoStringer struct {
|
||||||
|
}
|
||||||
|
|
||||||
func TestGt(t *testing.T) {
|
func TestGt(t *testing.T) {
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
left interface{}
|
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) {
|
func TestSafeHtml(t *testing.T) {
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
str string
|
str string
|
||||||
|
Reference in New Issue
Block a user