35 lines
890 B
Go
35 lines
890 B
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package content
|
|
|
|
import "testing"
|
|
|
|
// TestCategorySlug checks the name that goes into a category address.
|
|
func TestCategorySlug(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
want string
|
|
wantErr bool
|
|
}{
|
|
{"Linux Day", "linux-day", false},
|
|
{"FLUG", "flug", false},
|
|
{"Università", "universita", false},
|
|
{"Crème brûlée", "creme-brulee", false},
|
|
{"C++", "c", false},
|
|
{" Spaced out ", "spaced-out", false},
|
|
{"Straße", "strasse", false},
|
|
{"", "", true},
|
|
{"+++", "", true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := CategorySlug(tt.name)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("CategorySlug(%q) error = %v, wantErr %v", tt.name, err, tt.wantErr)
|
|
}
|
|
if got != tt.want {
|
|
t.Errorf("CategorySlug(%q) = %q, want %q", tt.name, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|