2021-10-30 08:42:43 +02:00
|
|
|
package authors
|
2021-10-23 09:17:35 +02:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestGetInitials(t *testing.T) {
|
2021-10-24 06:54:20 +02:00
|
|
|
for input, expectedOutput := range map[string]string{
|
2021-10-23 09:17:35 +02:00
|
|
|
"Jesse Duffield": "JD",
|
|
|
|
"Jesse Duffield Man": "JD",
|
|
|
|
"JesseDuffield": "Je",
|
|
|
|
"J": "J",
|
2021-10-24 06:54:20 +02:00
|
|
|
"六书六書": "六",
|
|
|
|
"書": "書",
|
2021-10-23 09:17:35 +02:00
|
|
|
"": "",
|
|
|
|
} {
|
2021-10-24 06:54:20 +02:00
|
|
|
output := getInitials(input)
|
|
|
|
if output != expectedOutput {
|
|
|
|
t.Errorf("Expected %s to be %s", output, expectedOutput)
|
2021-10-23 09:17:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|