MCPcopy
hub / github.com/cweill/gotests / TestExpression_String

Function TestExpression_String

internal/models/models_test.go:8–44  ·  view source on GitHub ↗

Test Expression.String method

(t *testing.T)

Source from the content-addressed store, hash-verified

6
7// Test Expression.String method
8func TestExpression_String(t *testing.T) {
9 tests := []struct {
10 name string
11 expr *Expression
12 want string
13 }{
14 {
15 name: "simple value",
16 expr: &Expression{Value: "int"},
17 want: "int",
18 },
19 {
20 name: "pointer type",
21 expr: &Expression{Value: "string", IsStar: true},
22 want: "*string",
23 },
24 {
25 name: "variadic type",
26 expr: &Expression{Value: "int", IsVariadic: true},
27 want: "[]int",
28 },
29 {
30 name: "variadic pointer (variadic takes precedence)",
31 expr: &Expression{Value: "string", IsStar: true, IsVariadic: true},
32 want: "[]*string",
33 },
34 }
35
36 for _, tt := range tests {
37 t.Run(tt.name, func(t *testing.T) {
38 got := tt.expr.String()
39 if got != tt.want {
40 t.Errorf("Expression.String() = %q, want %q", got, tt.want)
41 }
42 })
43 }
44}
45
46// Test Field.IsWriter method
47func TestField_IsWriter(t *testing.T) {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected