1
// Copyright 2022 The Gitea Authors. All rights reserved.
2
// SPDX-License-Identifier: MIT
9
"github.com/stretchr/testify/assert"
12
func TestToSnakeCase(t *testing.T) {
13
cases := map[string]string{
14
// all old cases from the legacy package
15
"HTTPServer": "http_server",
16
"_camelCase": "_camel_case",
17
"NoHTTPS": "no_https",
19
"_AnotherTES_TCaseP": "_another_tes_t_case_p",
21
"_HELLO_WORLD_": "_hello_world_",
22
"HELLO_WORLD": "hello_world",
23
"HELLO____WORLD": "hello____world",
27
" sentence case ": "__sentence_case__",
28
" Mixed-hyphen case _and SENTENCE_case and UPPER-case": "_mixed_hyphen_case__and_sentence_case_and_upper_case",
41
"TheCase2": "the_case2",
42
"ObjIDs": "obj_i_ds", // the strange database column name which already exists
44
for input, expected := range cases {
45
assert.Equal(t, expected, ToSnakeCase(input))