field_test.go 849 Bytes
Newer Older
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
//go:build windows || darwin

package format

import "testing"

func TestKebabCase(t *testing.T) {
	tests := []struct {
		input    string
		expected string
	}{
		{"already-kebab-case", "already-kebab-case"},
		{"simpleCamelCase", "simple-camel-case"},
		{"PascalCase", "pascal-case"},
		{"camelCaseWithNumber123", "camel-case-with-number123"},
		{"APIResponse", "api-response"},
		{"mixedCASE", "mixed-case"},
		{"WithACRONYMS", "with-acronyms"},
		{"ALLCAPS", "allcaps"},
		{"camelCaseWITHMixedACRONYMS", "camel-case-with-mixed-acronyms"},
		{"numbers123in456string", "numbers123in456string"},
		{"5", "5"},
		{"S", "s"},
	}

	for _, tt := range tests {
		t.Run(tt.input, func(t *testing.T) {
			result := KebabCase(tt.input)
			if result != tt.expected {
				t.Errorf("toKebabCase(%q) = %q, want %q", tt.input, result, tt.expected)
			}
		})
	}
}