forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake_test.go
74 lines (68 loc) · 1.26 KB
/
snake_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package names
import (
"testing"
)
func TestToSnakeCase(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
input string
expected string
}{
{
name: "empty",
input: "",
expected: "",
},
{
name: "All lower",
input: "lower",
expected: "lower",
},
{
name: "Initial upper",
input: "Lower",
expected: "lower",
},
{
name: "Two words",
input: "TwoWords",
expected: "two_words",
},
{
name: "A long one",
input: "GlobalReplicationGroupDescription",
expected: "global_replication_group_description",
},
{
name: "Including a digit",
input: "S3Bucket",
expected: "s3_bucket",
},
{
name: "ARN",
input: "ARN",
expected: "arn",
},
{
name: "ResourceArn",
input: "ResourceArn",
expected: "resource_arn",
},
{
name: "ResourceARN",
input: "ResourceARN",
expected: "resource_arn",
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
if got, want := ToSnakeCase(testCase.input), testCase.expected; got != want {
t.Errorf("got: %s, expected: %s", got, want)
}
})
}
}