File: dasherize_test.go

package info (click to toggle)
golang-github-gobuffalo-flect 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 352 kB
  • sloc: makefile: 49
file content (29 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package flect

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func Test_Dasherize(t *testing.T) {
	table := []tt{
		{"", ""},
		{"admin/WidgetID", "admin-widget-id"},
		{"Donald E. Knuth", "donald-e-knuth"},
		{"Random text with *(bad)* characters", "random-text-with-bad-characters"},
		{"Trailing bad characters!@#", "trailing-bad-characters"},
		{"!@#Leading bad characters", "leading-bad-characters"},
		{"Squeeze   separators", "squeeze-separators"},
		{"Test with + sign", "test-with-sign"},
		{"Test with malformed utf8 \251", "test-with-malformed-utf8"},
	}

	for _, tt := range table {
		t.Run(tt.act, func(st *testing.T) {
			r := require.New(st)
			r.Equal(tt.exp, Dasherize(tt.act))
			r.Equal(tt.exp, Dasherize(tt.exp))
		})
	}
}