Test Expression.String method
(t *testing.T)
| 6 | |
| 7 | // Test Expression.String method |
| 8 | func 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 |
| 47 | func TestField_IsWriter(t *testing.T) { |