package slugify import ( "testing" ) func TestSlugify(t *testing.T) { results := make(map[string]string) results["hello-playground"] = "Hello, playground" results["00a4bc92-3695-5702-9ddf-6719fdf11567"] = "๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ Hello, it's paradise" results["61db60b5-f1e7-5853-9b81-0f074fc268ea"] = "๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ" results["f09f98a2"] = "๐Ÿ˜ข -" results["a"] = "?,a . \n " results["0a68eb57-c88a-5f34-9e9d-27f85e68af4f"] = "" // empty input has a slug! results["3cbb528a-0ebf-54ad-bed2-2a188cd1824e"] = "ๆ–นๅ‘็›คๅพŒ้ข hi this is a test ุฎู„ู ุงู„ู…ู‚ูˆ" results["cong-hoa-xa-hoi-chu-nghia-viet-nam"] = "Cแป™ng hรฒa xรฃ hแป™i chแปง nghฤฉa Viแป‡t Nam" results["noi-nang-canh-canh-ben-long-bieng-khuay"] = "Nแป—i nร ng canh cรกnh bรชn lรฒng biแบฟng khuรขy" // This line in a poem called Truyen Kieu results["hello-playground"] = "Hello / playground" results["hello-playground"] = "Hello % playground" results["hello-and-playground"] = "Hello & //% playground" results["hello-2a-23-playground"] = "Hello *# playground" for slug, original := range results { actual := Slugify(original) if actual != slug { t.Errorf("Expected '%s', got: %s", slug, actual) } } } func BenchmarkSlugify(b *testing.B) { for i := 0; i < b.N; i++ { Slugify("Hello, world!") } } func BenchmarkSlugifyLongString(b *testing.B) { for i := 0; i < b.N; i++ { Slugify(` ๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ Hello, it's paradise ๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ Hello, it's paradise ๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ Hello, it's paradise ๐Ÿ˜ข ๐Ÿ˜ฃ ๐Ÿ˜ค ๐Ÿ˜ฅ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ฌ Hello, it's paradise Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sapien nisl, laoreet quis vestibulum ut, cursus in turpis. Sed magna mi, blandit id nisi vel, imperdiet mollis turpis. Fusce vel fringilla mauris. Donec cursus rhoncus bibendum. Aliquam erat volutpat. Maecenas faucibus turpis ex, quis lacinia ligula ultrices non. Sed gravida justo augue. Nulla bibendum dignissim tellus vitae lobortis. Suspendisse fermentum vel purus in pulvinar. Vivamus eu fermentum purus, sit amet tempor orci. Praesent congue convallis turpis, ac ullamcorper lorem semper id. `) } }