Exemplo n.º 1
0
func TestPascalToSnake(t *testing.T) {
	for _, spec := range []struct {
		input, want string
	}{
		{input: "value", want: "Value"},
		{input: "prefixed_value", want: "PrefixedValue"},
		{input: "foo_id", want: "FooId"},
	} {
		got := utilities.PascalFromSnake(spec.input)
		if got != spec.want {
			t.Errorf("utilities.PascalFromSnake(%q) = %q; want %q", spec.input, got, spec.want)
		}
	}
}
Exemplo n.º 2
0
// LHS returns a left-hand-side expression in go for this field.
func (c FieldPathComponent) LHS() string {
	if c.Target.Message.File.proto2() {
		return fmt.Sprintf("Get%s()", utilities.PascalFromSnake(c.Name))
	}
	return utilities.PascalFromSnake(c.Name)
}
Exemplo n.º 3
0
// RHS returns a right-hand-side expression in go for this field.
func (c FieldPathComponent) RHS() string {
	return utilities.PascalFromSnake(c.Name)
}