1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 14:34:40 +01:00
gojekyll/helpers/strings_test.go

28 lines
733 B
Go
Raw Normal View History

2017-06-17 01:17:22 +02:00
package helpers
2017-06-11 22:00:03 +02:00
import (
"testing"
"github.com/stretchr/testify/require"
2017-06-11 22:00:03 +02:00
)
2017-06-16 01:49:04 +02:00
func TestSlugify(t *testing.T) {
require.Equal(t, "abc", Slugify("abc"))
require.Equal(t, "ab-c", Slugify("ab.c"))
require.Equal(t, "ab-c", Slugify("ab-c"))
require.Equal(t, "ab-c", Slugify("ab()[]c"))
require.Equal(t, "ab123-cde-f-g", Slugify("ab123(cde)[]f.g"))
2017-06-16 01:49:04 +02:00
}
2017-06-11 22:00:03 +02:00
func TestLeftPad(t *testing.T) {
require.Equal(t, "abc", LeftPad("abc", 0))
require.Equal(t, "abc", LeftPad("abc", 3))
require.Equal(t, " abc", LeftPad("abc", 6))
2017-06-11 22:00:03 +02:00
}
func TestStringArrayToMap(t *testing.T) {
input := []string{"a", "b", "c"}
expected := map[string]bool{"a": true, "b": true, "c": true}
2017-06-17 02:06:55 +02:00
actual := StringArrayToMap(input)
require.Equal(t, expected, actual)
2017-06-11 22:00:03 +02:00
}