File: camel_test.go

package info (click to toggle)
golang-github-grpc-ecosystem-grpc-gateway 2.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,236 kB
  • sloc: javascript: 357; makefile: 147; sh: 26
file content (46 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (2)
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
package casing

import "testing"

func TestCamelIdentifier(t *testing.T) {
	casingTests := []struct {
		name  string
		input string
		want  string
	}{
		{
			"regular snake case identifier",
			"snake_case",
			"SnakeCase",
		},
		{
			"snake case identifier with digit",
			"snake_case_0_enum",
			"SnakeCase_0Enum",
		},
		{
			"regular snake case identifier with package",
			"pathenum.snake_case",
			"pathenum.SnakeCase",
		},
		{
			"snake case identifier with digit and package",
			"pathenum.snake_case_0_enum",
			"pathenum.SnakeCase_0Enum",
		},
		{
			"snake case identifier with digit and multiple dots",
			"path.pathenum.snake_case_0_enum",
			"path.pathenum.SnakeCase_0Enum",
		},
	}

	for _, ct := range casingTests {
		t.Run(ct.name, func(t *testing.T) {
			got := CamelIdentifier(ct.input)
			if ct.want != got {
				t.Errorf("want: %s, got: %s", ct.want, got)
			}
		})
	}
}