12345678910111213141516171819202122 |
- package main
- import (
- "testing"
- )
- func TestScrubName(t *testing.T) {
- table := []struct{ descr, input, expected string }{
- {"Does the needful", "lr", "lr"},
- {"Trims leading underscores", "_lr", "lr"},
- {"Trims trailing underscores", "lr_", "lr"},
- {"Sends hyphens to underscores", "lr-1", "lr_1"},
- {"Sends spaces to underscores", "lr 1", "lr_1"},
- }
- for _, row := range table {
- t.Run(row.descr, func(t *testing.T) {
- if s := scrubName(row.input); s != row.expected {
- t.Errorf("expected '%s'; got '%s'\n", row.expected, s)
- }
- })
- }
- }
|