| 1 |
// Copyright 2015 Huan Du. All rights reserved. |
| 2 |
// Licensed under the MIT license that can be found in the LICENSE file. |
| 3 |
|
| 4 |
package xstrings |
| 5 |
|
| 6 |
import ( |
| 7 |
"strings" |
| 8 |
"testing" |
| 9 |
) |
| 10 |
|
| 11 |
type _M map[string]string |
| 12 |
|
| 13 |
const ( |
| 14 |
separator = " ΒΆ " |
| 15 |
) |
| 16 |
|
| 17 |
func runTestCases(t *testing.T, converter func(string) string, cases map[string]string) { |
| 18 |
for k, v := range cases { |
| 19 |
s := converter(k) |
| 20 |
|
| 21 |
if s != v { |
| 22 |
t.Fatalf("case fails. [case:%v]\nshould => %#v\nactual => %#v", k, v, s) |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
func sep(strs ...string) string { |
| 28 |
return strings.Join(strs, separator) |
| 29 |
} |
| 30 |
|
| 31 |
func split(str string) []string { |
| 32 |
return strings.Split(str, separator) |
| 33 |
} |