-
Notifications
You must be signed in to change notification settings - Fork 36
/
converters_test.go
38 lines (34 loc) · 735 Bytes
/
converters_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sflags
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCamelToFlag(t *testing.T) {
data := []struct {
Src string
Exp string
}{
{"ValueValue2Value3", "value-value2-value3"},
{
"ValueValue2Value3Value4Value5Value6Value7",
"value-value2-value3-value4-value5-value6-value7",
},
{"Value", "value"},
{"IP", "ip"},
}
for _, d := range data {
assert.Equal(t, d.Exp, camelToFlag(d.Src, defaultFlagDivider))
}
}
func TestFlagToEnv(t *testing.T) {
data := []struct {
Src string
Exp string
}{
{"value-value2-value3", "VALUE_VALUE2_VALUE3"},
{"value", "VALUE"},
}
for _, d := range data {
assert.Equal(t, d.Exp, flagToEnv(d.Src, defaultFlagDivider, defaultEnvDivider))
}
}