mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-25 02:24:47 +00:00
46 lines
999 B
Go
46 lines
999 B
Go
|
package helpers
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestMakePath(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
input string
|
||
|
expected string
|
||
|
}{
|
||
|
{" foo bar ", "foo-bar"},
|
||
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
||
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
||
|
{"foo/bar.html", "foo/bar.html"},
|
||
|
{"трям/трям", "трям/трям"},
|
||
|
}
|
||
|
|
||
|
for _, test := range tests {
|
||
|
output := MakePath(test.input)
|
||
|
if output != test.expected {
|
||
|
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestUrlize(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
input string
|
||
|
expected string
|
||
|
}{
|
||
|
{" foo bar ", "foo-bar"},
|
||
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
||
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
||
|
{"foo/bar.html", "foo/bar.html"},
|
||
|
{"трям/трям", "%D1%82%D1%80%D1%8F%D0%BC/%D1%82%D1%80%D1%8F%D0%BC"},
|
||
|
}
|
||
|
|
||
|
for _, test := range tests {
|
||
|
output := Urlize(test.input)
|
||
|
if output != test.expected {
|
||
|
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||
|
}
|
||
|
}
|
||
|
}
|