123456789101112131415161718192021222324252627 |
- /*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- */
- 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)
- }
- })
- }
- }
|