@@ -106,6 +106,7 @@ func Test_splitJoin(t *testing.T) {
106
106
pascal string
107
107
pascalGo string
108
108
snake string
109
+ header string
109
110
}{
110
111
{
111
112
// everything empty
@@ -115,30 +116,35 @@ func Test_splitJoin(t *testing.T) {
115
116
pascal : "A" ,
116
117
camel : "a" ,
117
118
snake : "a" ,
119
+ header : "A" ,
118
120
},
119
121
{
120
122
input : "A" ,
121
123
pascal : "A" ,
122
124
camel : "a" ,
123
125
snake : "a" ,
126
+ header : "A" ,
124
127
},
125
128
{
126
129
input : "a_a" ,
127
130
pascal : "AA" ,
128
131
camel : "aA" ,
129
132
snake : "a_a" ,
133
+ header : "A-A" ,
130
134
},
131
135
{
132
136
input : "__a___a_" ,
133
137
pascal : "AA" ,
134
138
camel : "aA" ,
135
139
snake : "a_a" ,
140
+ header : "A-A" ,
136
141
},
137
142
{
138
143
input : "aa_bbb" ,
139
144
pascal : "AaBbb" ,
140
145
camel : "aaBbb" ,
141
146
snake : "aa_bbb" ,
147
+ header : "Aa-Bbb" ,
142
148
},
143
149
{
144
150
input : "aa_id" ,
@@ -147,18 +153,21 @@ func Test_splitJoin(t *testing.T) {
147
153
camel : "aaId" ,
148
154
camelGo : "aaID" ,
149
155
snake : "aa_id" ,
156
+ header : "Aa-ID" ,
150
157
},
151
158
{
152
159
input : "fooBar" ,
153
160
pascal : "FooBar" ,
154
161
camel : "fooBar" ,
155
162
snake : "foo_bar" ,
163
+ header : "Foo-Bar" ,
156
164
},
157
165
{
158
166
input : "FooBAR" ,
159
167
pascal : "FooBar" ,
160
168
camel : "fooBar" ,
161
169
snake : "foo_bar" ,
170
+ header : "Foo-Bar" ,
162
171
},
163
172
{
164
173
input : "fooUrl" ,
@@ -167,6 +176,7 @@ func Test_splitJoin(t *testing.T) {
167
176
camel : "fooUrl" ,
168
177
camelGo : "fooURL" ,
169
178
snake : "foo_url" ,
179
+ header : "Foo-URL" ,
170
180
},
171
181
{
172
182
input : "fooURL" ,
@@ -175,13 +185,15 @@ func Test_splitJoin(t *testing.T) {
175
185
camel : "fooUrl" ,
176
186
camelGo : "fooURL" ,
177
187
snake : "foo_url" ,
188
+ header : "Foo-URL" ,
178
189
},
179
190
{
180
191
input : "url10" ,
181
192
pascal : "Url10" ,
182
193
pascalGo : "URL10" ,
183
194
camel : "url10" ,
184
195
snake : "url_10" ,
196
+ header : "URL-10" ,
185
197
},
186
198
{
187
199
input : "url_id" ,
@@ -190,23 +202,40 @@ func Test_splitJoin(t *testing.T) {
190
202
camel : "urlId" ,
191
203
camelGo : "urlID" ,
192
204
snake : "url_id" ,
205
+ header : "URL-ID" ,
193
206
},
194
207
}
195
208
for _ , tt := range tests {
196
209
t .Run (tt .input , func (t * testing.T ) {
197
- require . Equal ( t , tt . pascal , ToPascalCase ( tt . input ))
198
- require .Equal (t , tt .camel , ToCamelCase (tt .input ))
199
- require . Equal ( t , tt . snake , ToSnakeCase ( tt . input ) )
210
+ t . Run ( "ToPascalCase" , func ( t * testing. T ) {
211
+ require .Equal (t , tt .pascal , ToPascalCase (tt .input ))
212
+ } )
200
213
201
- if tt .pascalGo == "" {
202
- tt .pascalGo = tt .pascal
203
- }
204
- require .Equal (t , tt .pascalGo , ToPascalGoCase (tt .input ))
214
+ t .Run ("ToCamelCase" , func (t * testing.T ) {
215
+ require .Equal (t , tt .camel , ToCamelCase (tt .input ))
216
+ })
205
217
206
- if tt .camelGo == "" {
207
- tt .camelGo = tt .camel
208
- }
209
- require .Equal (t , tt .camelGo , ToCamelGoCase (tt .input ))
218
+ t .Run ("ToSnakeCase" , func (t * testing.T ) {
219
+ require .Equal (t , tt .snake , ToSnakeCase (tt .input ))
220
+ })
221
+
222
+ t .Run ("ToPascalGoCase" , func (t * testing.T ) {
223
+ if tt .pascalGo == "" {
224
+ tt .pascalGo = tt .pascal
225
+ }
226
+ require .Equal (t , tt .pascalGo , ToPascalGoCase (tt .input ))
227
+ })
228
+
229
+ t .Run ("ToCamelGoCase" , func (t * testing.T ) {
230
+ if tt .camelGo == "" {
231
+ tt .camelGo = tt .camel
232
+ }
233
+ require .Equal (t , tt .camelGo , ToCamelGoCase (tt .input ))
234
+ })
235
+
236
+ t .Run ("ToHeaderField" , func (t * testing.T ) {
237
+ require .Equal (t , tt .header , ToHeaderField (tt .input ))
238
+ })
210
239
})
211
240
}
212
241
}
0 commit comments